Repository navigation
feat(pdf): CMYK PDF and Illustrator files β CMYK JPG and TIFF - #1060
Merged
Merged
Conversation
PDFium renders RGB only, so a print file (a CMYK PDF, or an Illustrator file through its PDF) lost its ink values on the way to JPG or TIFF (#1027). When Ghostscript is installed and PdfPig finds CMYK content on the selected pages (DeviceCMYK colours, four-channel ICC spaces, Separation / DeviceN, CMYK pictures and gradients), PdfiumConverter has the pages rendered with tiff32nc and encodes them the same way as PDFium's. DeviceCMYK values pass through unchanged; a CMYK output intent profile is rendered into and embedded, otherwise the result is untagged CMYK. RGB documents, grayscale presets, other targets and PCs without Ghostscript keep PDFium's rendering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A CMYK PDF or AI β JPG/TIFF that falls back to PDFium's RGB because Ghostscript isn't installed, or failed on the file, now gets a note on the result (notice.cmyk_needs_ghostscript / notice.cmyk_render_failed, in all 19 languages): print work shouldn't change colour unseen. PdfiumConverter.FindGhostscript lets a test see a PC without Ghostscript. The render tests are now CmykRenderTests, next to the pictures β PDF ones in CmykPdfTests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # docs/ENGINES.md
Open
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.
The other half of #1027 (after #1059). A print user's CMYK Illustrator file β JPG came out RGB: AI goes ai β pdf β jpg through PDFium, which renders RGB only. Same for a CMYK PDF.
What changes
Pdf/PdfCmykContent.cs, PdfPig): a document draws in CMYK when its pages (the first 20 selected) use DeviceCMYK colours (k/K, also inside forms), four-channel ICC colour spaces, spot colours (Separation / DeviceN) or CMYK pictures and gradients. Resources are walked with a cap and a cycle check; a PDF PdfPig can't read counts as not CMYK.GhostscriptConverter.RenderCmykAsync): for a JPG or TIFF target, a CMYK document is drawn by Ghostscript'stiff32nc(8-bit CMYK) at the preset's DPI, cut to the crop box, anti-aliased. DeviceCMYK values come out as the document gives them (checked: 0.1 / 0.2 / 0.3 / 0.4 β 25 / 51 / 76 / 102).Encode): quality, resize,_p{n}names, multi-page TIFF, long images, size limits.notice.cmyk_needs_ghostscript/notice.cmyk_render_failed, all 19 languages).Tested
CmykRenderTests(19, run here with the real Ghostscript fetched bybuild/fetch-engines.ps1 -Only ghostscript, none skipped):vector, pdfium, pdf β jpgpdfium.Engines: the whole project 2064 pass, 0 fail (218 skipped for engines not installed here). App localization 214 pass.
dotnet format --verify-no-changesclean.Not in this PR: CMYK EPS / PS β JPG still goes through Ghostscript's
pngalpha(RGB).π€ Generated with Claude Code