Write PDF/X-4 when PDFX is '4', keeping the transparency, layers and colour fonts PDF/X-1a strips - #324
Open
jakejackson1 wants to merge 3 commits into
Open
Write PDF/X-4 when PDFX is '4', keeping the transparency, layers and colour fonts PDF/X-1a strips#324jakejackson1 wants to merge 3 commits into
jakejackson1 wants to merge 3 commits into
Conversation
…colour fonts PDF/X-1a strips PDFX now takes '4' for PDF/X-4 (ISO 15930-7) beside true or '1a' for PDF/X-1a:2003, which is unchanged apart from what PDF/X forbids of every version: JavaScript, active form fields, and annotations within the BleedBox or TrimBox are now removed, and images are no longer interpolated. PDF/X-4 is written as PDF 1.6 with the pdfxid metadata, and embeds its output intent's profile: the SWOP2006 Coated #3 profile from the ICC registry where ICCProfile names none. It keeps opacity, watermarks, colours with transparency, PNG alpha and layers. Colour fonts are drawn in colour, and pages are blended in the output intent's colour space. DeviceRGB is permitted only against an RGB output intent, so otherwise RGB images and colour glyphs are written in an ICC-based sRGB colour space, while RGB colours are converted to CMYK as for PDF/X-1a. Ported from jakejackson1#7. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
isPdfx1a() replaces the repeated "PDF/X but not PDF/X-4" test, the colour restrictors hand an alpha colour under PDF/X-4 to the plain one, and PdfX4Test reads objects through PageStreams. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PDFXnow takes'4'for PDF/X-4 (ISO 15930-7).trueand'1a'still give PDF/X-1a:2003, and any other string is refused. Under PDF/X-4, mPDF:PDFXis set after the header has been written, the catalog carries/Version /1.6instead.pdfxidXMP schema,pdf:Trapped,xmpMM:VersionID,xmpMM:RenditionClassandxmpMM:InstanceID.ICCProfileit uses the bundledSWOP2006_Coated3v2.icc, the IDEAlliance CMYK printer profile from the ICC registry. The profile is redistributable but may not be modified; its licence is indata/iccprofiles/NOTICE.md.rgba()colours (as CMYK plus alpha), PNG alpha (/SMask) and layers. Each layer configuration is named./Group … /CS /DeviceCMYK, or RGB/Gray when the intent is RGB/Gray.Some rules apply to every PDF/X version, so they also change PDF/X-1a output:
/Interpolate true.Under
PDFXauto = falseeach removal becomes a warning, and the document is refused.What changed compared with jakejackson1#7
ColorFormats::inColor()off for all PDF/X, but PDF/X-4 permits transparency. The catch is that PDF/X-4 allows DeviceRGB only when the output intent is RGB. So with a CMYK intent, the RGB in colour glyphs is written in an ICC-based sRGB colour space:GlyphResources::rgb();BaseWriter::calibratedRgb().printonly/screenonly/hidden) stays refused. It depends on/ASusage apps, and print-only content would not print without them.BaseWriter::date()already gives one date for both./TR//HTguard was dropped, since nothing in mPDF writes those keys.PDFXis no longer rewritten to a boolean in the constructor.isPdfx4()andisPdfx1a()read it, so settingPDFX = '4'after construction still works, as it already does for colour fonts under PDF/A. The page box geometry is not refactored;printedArea()works out the BleedBox/TrimBox on its own. This keeps the change clear of the shared PDF/A/PDF/X code the PDF/UA port also touches.Testing
tests/Mpdf/PdfX4Test.php(24 tests). It covers:/N 4, and the profile'sprtr/CMYK header;composer testpasses (3151 tests, 5 skips). The skips were already there: generator/ICU checks. The snapshot group passes (85).composer csis clean. PHPStan 2.2 reports no errors, with no baseline change.pdfinforeports the PDF/X-4 document asPDF subtype: PDF/X-4.Open questions
ICCProfilegrows by about 2.2 MB. Should we keep this default, or requireICCProfilefor PDF/X-4?dc:title). mPDF does not enforce this, for either version.🤖 Generated with Claude Code