Can't get PDFBox CreatePDFA example to work - Color profile not found

2.6k Views Asked by At

I'm trying to get the example for creating a PDF/A document with Apache PDFBox up an running (CreatePDFA.java).

For this I copied the example class as is into a project module that includes a maven-dependency on PDFBox in version 2.0.0-RC3. I only changed the method signature and used a fixed font, filename and message instead of args[].

When trying to run the code I get an NPE in Line 107 because it cant't load the color profile (InputStream is null) When I check the included library in the project details I can see the resources folder, but it does not contain the expected file, namely "pdfa/sRGB Color Space Profile.icm".

Screenshot of PDFBox resources in the project

Unfortunately, google-ing the problem only turned up more references to always the same example implementation, but after a while I acutally found what seems to be the needed file on apache.googlesource.com

I copied the file to our own resource directory and then used this line of code instead:

InputStream colorProfile = CreatePdfA.class.getResourceAsStream("/pdfa/sRGB Color Space Profile.icm");

This finally stopped the NPE - the file is apparently found - but now I get another exception which says:

java.lang.IllegalArgumentException: Invalid ICC Profile Data

Here, I'm stuck. I had hoped that this would work just out of the box, but it seems like I am missing something. Any ideas?

1

There are 1 best solutions below

0
On

You already answered one part of the problem yourself: put the file into your resource directory.

The second problem may be a bad repository mirror or a transfer problem (binary to ascii). Here's the official repository URL with the ICC profile from the example: https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/resources/org/apache/pdfbox/resources/pdfa/