Load a PDF in Processing

edited December 2014 in Library Questions

Hi,

I'm working on a program that basically has to open a pdf, draw some shapes and save it. It isn't possible doing it with the built-in library because it is only for exporting. Searching around I found the PDFBox library that should be able to do those things and there is my dumb question:

How can I install this library in Processing? I put the .jar file downloaded from http://pdfbox.apache.org/download.cgi#recent into the libraries folder and I restarted Processing, but I can't see it in Sketch>Import Library...

Answers

  • edited December 2014

    I made it work adding the .jar as file in the sketch, but now I have another problem xD

    I'm writing this simple but not working code just to see how the library works:

    /======================================

    import org.apache.pdfbox.pdmodel.*;

    import java.io.File;

    File f = new File("/Volumes/Jumpeter HDD/Dropbox/MONTAGGIO/PALAZZI/4.pdf");

    PDDocument pdf = null;

    void setup() {

    size(600, 400);

    //String s = "/Volumes/Jumpeter HDD/Dropbox/MONTAGGIO/PALAZZI/4.pdf";

    pdf = PDDocument.load(f);

    }

    void draw() {

    }

    //======================================

    It gives me this error: "Unhandled exeption type IOExeption" both if I load with the String or the File, WHY?

  • edited December 2014 Answer ✓

    You have to handle the exception... FAQ: What is an exception? (and what are "unhandled exceptions")

    Other useful reading: Processing forum rules and advices

Sign In or Register to comment.