How to access PGraphicsPDF type from a library

I'm adding a feature to my Processing library, coded in Java in Eclipse. In my code, I want to be able to start a new page in my PDF output. Processing's documentation says I do the following, where theSketch is my pointer of type PApplet back to my sketch:

 PGraphicsPDF pdf = (PGraphicsPDF) theSketch.g;

But this doesn't compile because the Java compiler reports that PGraphicsPDF is an unknown symbol. Among my many attempted solutions, I copied pdf.jar from the Processing installation (specifically, on my Mac, from /Applications/ into Eclipse's folder Referenced Libraries, added it to the Java Build Path for my project, and imported processing.pdf.* at the top of the file (in addition to processing.core.*), but the compile fails with the error "package processing.pdf does not exist" . Can someone please help me get this code (or something like it) to work?


  • Update: I added pdf.jar to to the classpath.local.include line in, and the code builds successfully. But something is still very weird.

    When I compile, I get the following error. What I find interesting is that the path involves a temporary (tmp) folder which I am unaware of explicitly creating or using:

    /Volumes/Groucho/Programming/Eclipse/workspace/AULib/processing-library-template-0.5.4/tmp/AULib/src/template/library/ package processing.pdf does not exist

    But the library otherwise compiles (and runs) just fine. If I comment out the import of this "non-existing" library, the compilation fails because PGraphicsPDF is an unknown type.

    My guess is that it's not finding the library in this tmp folder, but it's finding it elsewhere, and that's why things are working. But that's just a guess, and I'd rather not release an update to my library until I know it's solid. Can anyone help me understand or resolve the apparent contradiction that a "non-existent" library is necessary to compile my code successfully?

  • edited December 2014

    ... but it's finding it elsewhere, and that's why things are working.

    Dunno whether it helps, but when I import sun.misc.Unsafe; in Processing's IDE, it says:
    "No library found for sun.misc".

    But it works anyways! So I guess it's the same case w/ Eclipse? :-??

    Also, in old Processing versions, like 2.0.3 or 1.5.1, using import static triggered same warning:
    import static javax.swing.JOptionPane.*; -> "No library found for static javax.swing.JOptionPane".

    But lo & behold, works like a charm nonetheless! :O)
    However, import static's warning is fixed now. At least it is in my Processing 2.2.1! =:)

Sign In or Register to comment.