PDF: [Paper] prints as no ink in print exports

[Paper] was written as DeviceRGB white (`1 1 1 rg`) even in print documents
and PDF/X-4 files: an RGB object in a CMYK print file, which print preflight
rejects. For the Print intent and for PDF/X it is now `0 0 0 0 k` (CMYK, no
ink, still knocking out what lies below); Web and Mobile documents keep RGB
white.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
japbcoelhoandClaude Opus 5.5 authored and Brandon Thomas committed 2026-10-06 09:04:34 -04:00
1 parent f1767a84fd
commit 108e34ff79
2 files changed
+24

No files matched your search

+9
View File
@@ -505,6 +505,11 @@ pub(crate) fn solid_fill(c: krilla::color::Color, opacity: f32) -> Fill {
}
impl Exporter<'_> {
/// A print document, or a PDF/X file (whose output intent is CMYK).
pub(crate) fn for_print(&self) -> bool {
self.doc.settings.intent == designcraft_doc::Intent::Print || self.opts.standard == Standard::PdfX4
}
pub(crate) fn warn(&mut self, w: impl Into<String>) {
let w = w.into();
if !self.warnings.contains(&w) {
@@ -522,6 +527,10 @@ impl Exporter<'_> {
let sw = self.doc.swatch(n)?;
match &sw.value {
SwatchValue::None => return None,
// [Paper] prints no ink (it knocks out what lies below); its colour is only what
// the screen shows. Written as RGB white (`1 1 1 rg`) it would put DeviceRGB in a
// CMYK print file.
SwatchValue::Paper { .. } if self.for_print() => return Some(device(&Color::cmyk(0.0, 0.0, 0.0, 0.0), self.rgb_only)),
SwatchValue::Tint { base, tint: bt } => {
t *= bt;
n = base;
+15
View File
@@ -111,6 +111,21 @@ fn colours_keep_their_space() {
assert!(s.contains("/Separation") && s.contains("/PANTONE#20Test"), "spot as Separation");
}
/// [Paper] went into print PDFs as `1 1 1 rg`, DeviceRGB white.
#[test]
fn paper_prints_as_no_ink() {
let mut d = doc_with_text("x");
add_box(&mut d, Rect::new(36.0, 400.0, 136.0, 500.0), "[Paper]");
let s = uncompressed(&d, PdfOptions::default());
assert!(s.contains("0 0 0 0 k"), "CMYK, no ink");
assert!(!s.contains("1 1 1 rg"), "no RGB white");
// A web document keeps the paper colour.
d.settings.intent = designcraft_doc::Intent::Web;
assert!(uncompressed(&d, PdfOptions::default()).contains("1 1 1 rg"));
// PDF/X has a CMYK output intent whatever the document's intent.
assert!(!uncompressed(&d, PdfOptions { standard: Standard::PdfX4, ..Default::default() }).contains("1 1 1 rg"));
}
#[test]
fn boxes_bleed_and_marks() {
let mut d = doc_with_text("x");