PDF on exported application

edited November 2013 in Library Questions

Hello everybody,

I'm having an issue with Processing (v 2.1) and PDF on exported application.

The PDF will be exported when this code is run via the IDE but not when exported as an app

import processing.pdf.*;
void setup() {
  PGraphics pdf = createGraphics(458, 649, PDF, "output.pdf");
  pdf.beginDraw();
  pdf.fill(0);
  pdf.rect(0, 0, 100, 100);
  pdf.dispose();
  pdf.endDraw();
}

Any ideas?

Thank you!

Answers

  • (the same code works fine in previous versions of Processing)

  • Is a simple sketch (no libraries) exported in your version of Processing working for you?

  • edited November 2013

    Perhaps it works, but the file goes to an unexpected place...

    You can try and put an absolute path for the file name, at least for testing purpose.

    You can also use paths like:

    // See where it goes, add "output.pdf" to it
    println(System.getProperty("user.home"));
    
  • edited December 2013

    Thanks for your help PhilHo. Sorry I didn't reply earlier but I'm not receiving notifications from the forum.

    I've tried that and it shows the same location both through the IDE and the app. The pdf file doesn't get saved on apps exported by processing 2.1 (it works on previous versions).

    Here's the code I'm using:

    import processing.pdf.*;
        void setup() {
          size(300,300);
          PGraphics pdf = createGraphics(458, 649, PDF, "output.pdf");
          pdf.beginDraw();
          pdf.fill(0);
          pdf.rect(0, 0, 100, 100);
          pdf.dispose();
          pdf.endDraw();
    
        }
        void draw() {
          background(0);
          text(System.getProperty("user.home"), 100, 100);
        }
    

    This will save a file when run on the IDE but won't save anything when run as an app.

  • PDF works fine in exported applications, it is the export as application which is broken on Windows for 2.1... Check the Using Processing category, there are a number of topics about this. In one of them, I give a workaround.

  • edited January 2014

    Hi PhiLho, thanks for your help.

    I couldn't find a solution to my problem, I had a look at your answers but the problem still arises when the sketch is exported as an application from Processing 2.1+ both in Mac and Windows

    import processing.pdf.*;
        PGraphics pdf = createGraphics(300, 300, PDF, "output.pdf");
        pdf.beginDraw();
        pdf.background(128, 0, 0);
        pdf.line(50, 50, 250, 250);
        pdf.dispose();
        pdf.endDraw();
    

    As an example, this code would work fine as a sketch but won't save a file when exported

  • edited January 2014

    Actually, I just found out that the file IS exported! But it's the path that needs to be changed (with the current method the file is saved in the user's root)

  • sketchPath refers to the absolute root on Mac OSX

    Here's the issue with a temporary workaround on github https://github.com/processing/processing/issues/2181

Sign In or Register to comment.