How to render PDF in applet

package org.adastraeducation.visualcs.main;
import processing.pdf.PGraphicsPDF;
import processing.core.PApplet; 
import processing.core.PGraphics;
import processing.core.PImage;

public class TestPDFPApplet extends PApplet {
public void setup() {
    size(600,600, PDF);
    g.setPath("dir/test.pdf");
}   
}

the jar files pdf.jar and itext.jar are in the classpath, running in eclipse.

The error (happens regardless whether setPath is called before or after size)

java.lang.RuntimeException: PGraphicsPDF requires a path for the location of the output file.
at processing.pdf.PGraphicsPDF.beginDraw(Unknown Source)
at processing.core.PApplet.handleDraw(PApplet.java:2338)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240)
at processing.core.PApplet.run(PApplet.java:2256)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Animation Thread" java.lang.RuntimeException: Problem saving the PDF file.
at processing.pdf.PGraphicsPDF.beginDraw(Unknown Source)
at processing.core.PApplet.handleDraw(PApplet.java:2338)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240)
at processing.core.PApplet.run(PApplet.java:2256)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at processing.pdf.PGraphicsPDF.dispose(Unknown Source)
at processing.core.PApplet.dispose(PApplet.java:4145)
at processing.core.PApplet.destroy(PApplet.java:1207)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Tagged:
Sign In or Register to comment.