Skip to content

Debugging against PDFBox

Eliot Jones edited this page Jan 15, 2022 · 1 revision

If you need to debug and compare content stream processing or other file content processing against PDFBox you can clone PDFBox locally and set the following main method to launch in the IntelliJ debugger once you have changed the file path to one you want to use locally:

https://github.com/apache/pdfbox/blob/trunk/examples/src/main/java/org/apache/pdfbox/examples/rendering/CustomGraphicsStreamEngine.java#L57

For example:

    public static void main(String[] args) throws IOException
    {
        File file = new File("C:\\temp\\pdfs\\", "document with error.pdf");

        try (PDDocument doc = Loader.loadPDF(file))
        {
            PDPage page = doc.getPage(0);
            CustomGraphicsStreamEngine engine = new CustomGraphicsStreamEngine(page);
            engine.run();
        }
    }

You will need to install Maven and do a clean install before opening/using the code in Intellij:

https://github.com/apache/pdfbox#build

Clone this wiki locally