Problem creating PDFs "behind the scenes"
in
Core Library Questions
•
2 years ago
I'm trying to create PDFs from my Processing sketch. But, crucially, the PDFs are not recordings of what I'm doing on the main screen. I want to treat them as any other PGraphics and have some code that knows about PGraphics to write on them while the screen shows something completely different.
Here's what I'm trying :
The problem occurs in 4. It throws a NullPointerException :
Is that because I haven't something I should have done? Or is it a bug in the pdf class?
Note that this isn't just a problem for pushMatrix(). If I comment that line, the problem just gets thrown in the next line, the translate. ( Though, interestingly, doesn't happen in the pdf.noFill )
Anyone got any ideas?
cheers
phil
Here's what I'm trying :
- PGraphicsPDF pdf;
- pdf = (PGraphicsPDF)createGraphics(paper_x, paper_y, PDF, "find.pdf");
- pdf.noFill();
- pdf.pushMatrix();
- pdf.translate(width/2,height/2);
- pdf.scale(2);
- myThing.draw(pdf);
- pdf.popMatrix();
The problem occurs in 4. It throws a NullPointerException :
- Exception in thread "Animation Thread" java.lang.NullPointerException
- at processing.core.PGraphicsJava2D.pushMatrix(Unknown Source)
Is that because I haven't something I should have done? Or is it a bug in the pdf class?
Note that this isn't just a problem for pushMatrix(). If I comment that line, the problem just gets thrown in the next line, the translate. ( Though, interestingly, doesn't happen in the pdf.noFill )
Anyone got any ideas?
cheers
phil
1