Skip to content

Support PDF/X-4 for print production - #1809

Merged
andreasrosdalw merged 1 commit into
LibrePDF:masterfrom
andreasrosdal:pdfx4-support
Dec 2, 2026
Merged

andreasrosdalw merged 1 commit into
LibrePDF:masterfrom
andreasrosdal:pdfx4-support

Conversation

@andreasrosdal

@andreasrosdal andreasrosdal commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Description of the new Feature/Bugfix

Adds PDF/X-4 (ISO 15930-7:2010), the current exchange format for print production. Printing presses and prepress workflows ask for it, and it is the default PDF/X profile in Acrobat, InDesign and Ghostscript. OpenPDF supported only PDF/X-1a:2001 and PDF/X-3:2002, which forbid transparency and layers.

Usage

PdfWriter writer = PdfWriter.getInstance(document, out);
writer.setPDFXConformance(PdfWriter.PDFX4);
document.open();
writer.setOutputIntents("FOGRA39", null, "http://www.color.org",
        "Coated FOGRA39 (ISO 12647-2:2004)", ICC_Profile.getInstance(fogra39Bytes));
// text with embedded fonts, transparency, layers, ...
document.close();   // writes the PDF/X-4 XMP metadata

What OpenPDF does for PDFX4

Requirement of ISO 15930-7 Implementation
PDF 1.6 setPDFXConformance(PDFX4) sets the version to 1.6
Transparency, soft masks and layers are allowed allowed, as for PDF/A-2 and PDF/A-3 since #1807
Fonts embedded, no encryption the existing PDF/X checks
Output intent GTS_PDFX with an embedded ICC profile checked on close: a missing profile throws a PdfXConformanceException. PDF/X-1a and PDF/X-3 still get the default SWOP intent without a profile.
TrimBox or ArtBox on every page the existing PDF/X handling
Info: /GTS_PDFXVersion (PDF/X-4), /Trapped, /Title, /CreationDate, /ModDate written. /ModDate was missing for every PDF/X level and is now added.
XMP: pdfxid:GTS_PDFXVersion, xmpMM:DocumentID, xmpMM:VersionID, xmpMM:RenditionClass, pdf:Trapped, xmp:CreateDate, xmp:ModifyDate, xmp:MetadataDate, dc:title written by createXmpMetadata(), which close() calls for PDF/X-4 if no metadata was set

Limitations

  • No validator in CI. veraPDF validates PDF/A and PDF/UA but not PDF/X, so the tests check the requirements in the written file (see below). Before a release, a maintainer could check a sample file with a PDF/X preflight, such as Acrobat Preflight or callas pdfToolbox.
  • As for PDF/X-3, OpenPDF does not check that device colours match the output intent, for example DeviceRGB with a CMYK output intent. Users need ICC based or CMYK colour for a CMYK printing condition.

Other changes

  • XmpWriter writes pdf:Trapped when the info dictionary has /Trapped (new constant PdfSchema.TRAPPED).
  • PdfWriter.isPdfX4() and PdfXConformanceImp.isPdfX4().

Unit-Tests for the new Feature/Bugfix

New PdfX4Test:

  • A PDF/X-4 document with an embedded font, transparency (opacity and the Multiply blend mode), CMYK colour and a layer: %PDF-1.6 header, the info entries, every required XMP property, the GTS_PDFX output intent with DestOutputProfile, a TrimBox, no encryption.
  • XMP metadata and /Trapped that the user set are kept.
  • An output intent without an ICC profile is rejected.
  • A font that is not embedded is rejected.
  • PDF/X-1a still rejects transparency.

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

@codacy-production

codacy-production Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 28 complexity · 1 duplication

Metric Results
Complexity 28
Duplication 1

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.

PDF/X-4 (ISO 15930-7:2010) is the current exchange format for print
production. Unlike PDF/X-1a and PDF/X-3, which OpenPDF already
supports, it allows transparency, layers and ICC based colour.

- PdfWriter.PDFX4 writes the document as PDF 1.6.
- Transparency, soft masks and layers are allowed, as for PDF/A-2 and
  PDF/A-3. Fonts must still be embedded and encryption is refused.
- The info dictionary gets /GTS_PDFXVersion (PDF/X-4), /Trapped and,
  for every PDF/X level, the /ModDate that PDF/X requires.
- The XMP metadata is created when the document is closed, unless it
  was set before. For PDF/X-4 it has pdfxid:GTS_PDFXVersion,
  xmpMM:DocumentID, VersionID and RenditionClass, xmp:MetadataDate and
  pdf:Trapped.
- An output intent with an ICC profile is required. Closing the
  document without one throws a PdfXConformanceException.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sonarqubecloud

sonarqubecloud Bot commented Dec 2, 2026

Copy link
Copy Markdown

@andreasrosdalw
andreasrosdalw merged commit 53839ed 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