Here is my problem, I've made a java program with the library PdfBox
to make pdf from the image and other pdf
so this work fine, but I want to generate PDF/A-1
. The problem is that I can't embed a color space.
I've tried the code of CreatePDFA.java that is given by PDFBox
// Create output intent
InputStream colorProfile = CreatePDFA.class.getResourceAsStream("colorSpacePath");
PDOutputIntent oi = new PDOutputIntent(doc, colorProfile);
oi.setInfo("sRGB IEC61966-2.1");
oi.setOutputCondition("sRGB IEC61966-2.1");
oi.setOutputConditionIdentifier("sRGB IEC61966-2.1");
oi.setRegistryName("http://www.color.org");
doc.getDocumentCatalog().addOutputIntent(oi);
I get a NullPointerException
at the line:
PDOutputIntent oi = new PDOutputIntent(doc, colorProfile);
Exception:
Exception in thread "main" java.lang.NullPointerException
at java.desktop/java.awt.color.ICC_Profile.getProfileDataFromStream(ICC_Profile.java:1034)
at java.desktop/java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:1016)
at org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent.configureOutputProfile(PDOutputIntent.java:112)
at org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent.<init>(PDOutputIntent.java:49)
at src.Kairos.CreatePDFA.doIt(CreatePDFA.java:124)
at src.Kairos.CreatePDFA.main(CreatePDFA.java:153)
Here is the code that work :
InputStream colorProfile = new FileInputStream(colorSpacePath);
PDOutputIntent oi = new PDOutputIntent(doc, colorProfile);
oi.setInfo("sRGB IEC61966-2.1");
oi.setOutputCondition("sRGB IEC61966-2.1");
oi.setOutputConditionIdentifier("sRGB IEC61966-2.1")
oi.setRegistryName("http://www.color.org");
doc.getDocumentCatalog().addOutputIntent(oi);
colorProfile.close()