-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using usePdfAConformance resulting in missing fonts and other attributes #326
Comments
In case you're interested in my Font strategy...it's essentially a copy-and-paste of one of the examples. My fonts are located in my classpath: "project-root/src/main/resources/fonts"
|
Hi @mattstjean, Thanks for the detailed write-up! In regards to fonts, I think you're falling victim to #324. Either the font is not under that name ( You could put something like this in a main method to check if it throwing: PDDocument doc = new PDDocument();
try {
PDType0Font.load(doc, new File("/path/to/font.ttf"));
} catch (Exception e) {
e.printStackTrace();
} As to the rest, I've just added a PDF/A testing module using VeraPDF. I used the following code to create the PDF: byte[] pdfBytes;
try (PDDocument doc = new PDDocument()) {
PdfRendererBuilder builder = new PdfRendererBuilder();
builder.usePDDocument(doc);
builder.useFastMode();
//builder.testMode(true);
builder.usePdfAConformance(conform);
builder.useFont(new File("target/test/artefacts/Karla-Bold.ttf"), "TestFont");
builder.withHtmlContent(html, PdfATester.class.getResource("/html/").toString());
try (PdfBoxRenderer renderer = builder.buildPdfRenderer()) {
renderer.createPDFWithoutClosing();
}
try (InputStream colorProfile = PdfATester.class.getResourceAsStream("/colorspaces/sRGB.icc")) {
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);
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
doc.save(baos);
pdfBytes = baos.toByteArray();
} Note: I got the color space file from: The test reports the following problems:
The XMP issue is probably where author is going. They appear to be all simple to fix, except for the In addition, PDF/A1a requires proper tagging. Fortunately, I've just implemented that for PDF/UA so that shouldn't be hard to get working. |
Unfortunately, we are using some structure types introduced in PDF 1.5 so we are not PDF/A1a compliant, at least when using tables.
UPDATE: We are now compliant with PDF/A standards 1 and 2, except for PDF/A1a when using tables. This is because we are using the So I'll have to find a way to factor out their use and then I can finally release RC-18. Additionally, I forgot that we have a builder method to input the color profile, so updated code to use PDF/A standards is something like: PdfRendererBuilder builder = new PdfRendererBuilder();
builder.useFastMode();
//builder.testMode(true);
builder.usePdfAConformance(conform);
builder.useFont(new File("target/test/artefacts/Karla-Bold.ttf"), "TestFont");
builder.withHtmlContent(html, PdfATester.class.getResource("/html/").toString());
try (InputStream colorProfile = PdfATester.class.getResourceAsStream("/colorspaces/sRGB.icc")) {
byte[] colorProfileBytes = IOUtils.toByteArray(colorProfile);
builder.useColorProfile(colorProfileBytes);
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
builder.toStream(baos);
builder.run(); |
Had to move the thead, tbody and tfoot rows directly as children of the table when using PDF version 1.4 or less.
We're now PDF/A1a compliant as well. I've written up some guidelines for PDF/A compliance in the wiki. Note in the example, the addition of this line: builder.usePdfVersion(conform.getPart() == 1 ? 1.4f : 1.5f); I think we can now close this issue. I'll release RC18 this week. Please re-open if you find any more issues with PDF/A. Thanks @mattstjean. |
@danfickle : The initial issue (fonts are missing) still seems to appear if we use builder.usePdfUaAccessbility(true) |
Hi @mattstjean, We can discuss here. Firstly, just making sure you know that |
Thank you for all of the help, @danfickle . Sorry about the delay in responding, I've been very busy and wanted to try it out before responding. I figured out my main issue with the fonts. The first fix was to get them properly (I had been trying all different variants because I wasn't sure why it wasn't working). I landed with:
Then I hit a snag and needed a second fix that wasn't as obvious to me. It was actually caused by the way I had the page counter set up. It's not in my initial example above because I added it after the fonts worked. The way I had it was:
I had it like that and then like:
Both of those didn't work and I was getting a lot of errors saying "Font list empty" or something similar. When I changed it to
it worked. In your html examples you have it that way too, so when I was doing a manual diff between my html and yours - I finally figured it out. I am having an issue now where the document language isn't getting set. When I run the adobe acrobat pro dc accessibility full check, it catches 2 fails: Primary language | Failed | Text language is specified The title I'm not super worried about because when I look at the document properties it does have a value for title. The thing that I'm trying to figure out is why language is not getting set. I get the same 2 fails when I run it on a PDF generated from your all-in-one.html test file.
Let me know if I should open a different issue. |
Closing in favor of #347. The order of properties situation is bizarre. Not sure what is happening. |
Before reading this, I only now saw the disclaimer of "Note: This is pre-release documentation. PDF/UA support will be released with RC-18."...So if this isn't supported yet, I'm sorry for the issue. --- Is there a timeline for RC-18? The project I'm working on requires the PDFs be compliant.
Summary
I am having an issue where when I add the line:
builder.usePdfAConformance(PdfAConformance.PDFA_1_A);
it causes my PDF to render blank, which I am assuming is due to the now-missing fonts.
I am also having issues when trying to include the line:
builder.useFastMode();
it causes the PDF to lose the Author attribute (only when used with PdfAConformance
Let me know if there is anything additional I can provide to get help with this.
Background
useFastMode() without usePdfAConformance
usePdfAConformance(PdfAConformance.PDFA_1_A) without useFastMode()
useFastMode() and usePdfAConformance(PdfAConformance.PDFA_1_A)
Neither useFastMode() nor usePdfAConformance(PdfAConformance.PDFA_1_A)
Application Info
Everything has been working perfectly, I've only run into issues when trying to make the application
Implementation 1
Implementation 2
I have been doing this with a simplified HTML template until I get it to work before I switch back to my real template:
The text was updated successfully, but these errors were encountered: