WeasyPrint icon indicating copy to clipboard operation
WeasyPrint copied to clipboard

PDF/A-1b validation failed when generating PDF with image

Open julien-gonzalez opened this issue 1 year ago • 1 comments

Hello,

Following issue #2175, I'm trying to generate PDF/A-1b documents. I've stumbled upon a problem, when I include an image in my document.

I've tested my case against both WeasyPrint v62.2 and main, using the following command : weasyprint --pdf-variant pdf/a-1b --pdf-identifier 043ff313-a121-4bb0-a24a-872c3d7b0b32 simple-page.html result.pdf

In both versions, the generated document doesn't pass PDF/A-1 validation (against https://demo.verapdf.org/).

Case in v62.2 : case-62-2.zip Case in main branch : case-main.zip

The 2 following rules are problematic :

Rule 6.4-2

An XObject dictionary shall not contain the SMask key

Rule 6.2.4-3

If an Image dictionary contains the Interpolate key, its value shall be false

Thank you for your help and the work you're doing to improve PDF/A-1 support.

julien-gonzalez avatar Jun 13 '24 08:06 julien-gonzalez

Hi!

The two problems are a bit different.

  • Rule 6.2.4-3 is actually covered by #1661: using html { image-rendering: crisp-edges } will fix the problem. We should set this automatically for PDF/A generation, but it’s not done yet. At least the workaround should be easy to apply for you.

  • Rule 6.4-2 is more complicated. PDF/A-1 doesn’t allow the use of transparent images, contrary to PDF/A-2. If you have the possibility to modify images before they’re integrated in your HTML file, the best solution would be to remove the alpha channel from your images before calling WeasyPrint. Otherwise, it’s probably possible to do this with a custom URL fetcher in WeasyPrint with Pillow. In both cases, you’ll have to find a solution if your documents actually need this transparency.

liZe avatar Jun 14 '24 09:06 liZe

Let’s track these problems in #1661! We should at least advertise about unsupported features in different PDF/A and PDF/UA versions when generating documents.

liZe avatar Jul 03 '24 19:07 liZe