Skip to content

Validate PDF/A and PDF/UA output with veraPDF, and fix PDF/A-2 and PDF/A-3 - #1807

Merged
andreasrosdalw merged 2 commits into
LibrePDF:masterfrom
andreasrosdal:verapdf-validation-tests
Dec 2, 2026
Merged

andreasrosdalw merged 2 commits into
LibrePDF:masterfrom
andreasrosdal:verapdf-validation-tests

Conversation

@andreasrosdal

@andreasrosdal andreasrosdal commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Description of the new Feature/Bugfix

Adds veraPDF validation tests for documents created by OpenPDF, and fixes the PDF/A-2 and PDF/A-3 problems that the tests found.

New tests: VeraPdfConformanceTest

Each test creates a document and validates it with veraPDF (validation-model, which is already a test dependency). On failure it prints the rule numbers and messages of the violations.

Test Content Flavour
pdfA1bWithTextImageTableAndLink embedded TrueType font (Identity-H, non-Latin text), JPEG, PdfPTable, link, sRGB output intent, XMP PDF/A-1b
pdfA2b…, pdfA2u…, pdfA3b…, pdfA3u…WithTextImageTableLinkAndTransparency the same, plus a fill with 50% opacity PDF/A-2b, 2u, 3b, 3u
pdfA2b/pdfA3bWithImageWithAlphaChannelAndLayer PNG with an alpha channel (/SMask), a layer with print usage PDF/A-2b, 3b
pdfA1bStillRejectsTransparency, pdfA1bStillRejectsImageWithAlphaChannel PDF/A-1 must still refuse transparency n/a
pdfUa1WithTaggedHeadingAndParagraph tagged Document/H1/P, /Lang, DisplayDocTitle, pdfuaid:part PDF/UA-1

Fixes for PDF/A-2 and PDF/A-3

Before this PR, all PDF/A-2 and PDF/A-3 tests failed:

  1. Transparency, soft masks and layers were rejected. PdfXConformanceImp applied the PDF/X-1a and PDF/A-1 rules to every PDF/A part. Setting a fill opacity threw Transparency is not allowed: /ca = 0.5, adding a PNG with an alpha channel threw The /SMask key is not allowed in images, and adding a layer threw Layers are not allowed. PDF/A-2 and PDF/A-3 allow all three. They are still rejected for PDF/A-1, PDF/X-1a and PDF/X-3.
  2. Incomplete CIDSet (rule 6.2.11.4.2). For subset Identity-H fonts OpenPDF wrote a CIDSet with only the used CIDs. PDF/A-2 and PDF/A-3 require a CIDSet to cover all CIDs in the font program. The CIDSet is optional there, so it is no longer written for PDF/A-2 and PDF/A-3. PDF/A-1, which requires it, and documents that are not PDF/A do not change.
  3. Optional content configuration (rule 6.9). The default configuration dictionary /D gets a /Name (Default), which PDF/A-2 and PDF/A-3 require. For PDF/A, the /AS auto-state array is no longer written, because PDF/A does not allow it.

Everything else about non-PDF/A documents is unchanged, apart from the new /Name entry in the /D dictionary of documents with layers, which is valid in every PDF version.

Unit-Tests for the new Feature/Bugfix

See the table above. ./mvnw -B install passes locally on Java 25 for all modules, and ./mvnw checkstyle:check reports nothing on the changed files. The changelog for 4.0.1 is updated.

Changelog of 4.0.1

A second commit completes changelogs/4.0.1.md: it adds the changes of #1801, #1803, #1804, #1805 and #1806, which were merged without a changelog entry, the pull request numbers, and the contributors of the release.

🤖 Generated with Claude Code

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 30 complexity · 2 duplication

Metric Results
Complexity 30
Duplication 2

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

andreasrosdal and others added 2 commits December 2, 2026 22:28
VeraPdfConformanceTest creates documents with text in an embedded
font, a JPEG image, a table, a link, transparency, an image with an
alpha channel and a layer, and validates them with veraPDF as PDF/A-1b,
PDF/A-2b, PDF/A-2u, PDF/A-3b, PDF/A-3u and PDF/UA-1.

The tests found that PDF/A-2 and PDF/A-3 documents could not be
created with features these standards allow:

- PdfXConformanceImp rejected transparency, images with an /SMask and
  layers for every PDF/A part. Only PDF/A-1, PDF/X-1a and PDF/X-3
  forbid them.
- TrueTypeFontUnicode wrote a CIDSet with only the used CIDs. PDF/A-2
  and PDF/A-3 (6.2.11.4.2) require all CIDs of the font program, and
  the CIDSet is optional there, so it is left out.
- The default optional content configuration had no /Name and could
  have an /AS entry, which PDF/A-2 and PDF/A-3 (6.9) do not allow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add the changes of LibrePDF#1801, LibrePDF#1803, LibrePDF#1804, LibrePDF#1805 and LibrePDF#1806, which were
merged without a changelog entry, the pull request number of LibrePDF#1802 and
LibrePDF#1807, and the contributors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@andreasrosdal
andreasrosdal force-pushed the verapdf-validation-tests branch from fe95e33 to 99a373c Compare December 2, 2026 21:29
@sonarqubecloud

sonarqubecloud Bot commented Dec 2, 2026

Copy link
Copy Markdown

@andreasrosdalw
andreasrosdalw merged commit cf5cd69 into LibrePDF:master Dec 2, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants