Dear all,
over the last years I accumulated technical debt through a modular
system of environments for our cooperative, which I'm now paying off
with the help of AI.
Today I worked on image resolutions and print pdfs with profiles for
print shops and Claude discovered that ConTeXt only stores a color
profile with the id `Custom` in the pdf itself. With other profile ids
it creates a link. The AI proposed a workaround by renaming the id of
profiles in colorprofiles.xml to <id>Custom<i/id>. With this workaround
the profile I use is stored in the pdf.
I know that nobody likes bugreports from the ki but I told Claude to
write it down. I hope it is not utter nonsense.
Here it comes.
# PDF/X-4: output profile with registered id is not embedded,
`/DefaultCMYK` points to a non-stream
ConTeXt LMTX 2026.09.10 10:02, LuaMetaTeX 2.11.10, Linux x86_64.
## Minimal example
Only files from the distribution are needed (`colorprofiles.xml` lists
`ISOcoated_v2_eci.icc` with `<id>FOGRA39</id>`, the profile itself ships
as `colo-imp-isocoated_v2_eci.icc`).
A CMYK JPEG for the figure:
```sh
magick -size 64x64 xc:'cmyk(0%,60%,100%,0%)' -colorspace CMYK cmyk.jpg
```
`pdfx4.tex`:
```tex
\setupbackend
[format=PDF/X-4,
intent=ISO Coated v2 (ECI)]
\setupcolors
[state=start,
cmyk=yes,
rgb=no]
\definecolor[orange][c=0,m=.6,y=1,k=0]
\starttext
\color[orange]{\blackrule[width=2cm,height=1cm]}
\externalfigure[cmyk.jpg][width=2cm]
\stoptext
```
```sh
context pdfx4.tex
qpdf --qdf --object-streams=disable pdfx4.pdf pdfx4-qdf.pdf
```
## What happens
The log says:
```
backend > profiles > setting format 'PDF/X-4' to 'PDF/X-4p'
backend > profiles > setting 'ISOcoated_v2_eci.icc' as default 'cmyk'
color space
backend > profiles > setting output intent to 'ISO Coated v2 (ECI)' with
id 'FOGRA39' for entry 1
```
In the PDF:
```
8 0 obj
<< /OutputConditionIdentifier (FOGRA39) /S /GTS_PDFX /Type /OutputIntent >>
14 0 obj
<< /DefaultCMYK 18 0 R >>
18 0 obj
[ /ICCBased 22 0 R ]
22 0 obj
<< /ProfileCS (cmyk)
/ProfileName (ISO Coated v2 \(ECI\))
/URLs [ << /F (http://www.color.org) /FS /URL >> ] >>
```
and the XMP metadata contains
`<pdfxid:GTS_PDFXVersion>PDF/X-4p</pdfxid:GTS_PDFXVersion>`.
Three problems:
1.**`/ICCBased` refers to a dictionary, not to an ICC stream.** ISO
32000 (8.6.5.5) requires the array element to be a stream containing the
profile.
Poppler rejects it (`pdftoppm pdfx4.pdf p` prints `Syntax Warning: Bad
ICCBased color space (stream)` and `Syntax Error: Bad image parameters`)
and does not render the CMYK image at all; Ghostscript renders it.
Every DeviceCMYK image on such a page is affected, because
`/DefaultCMYK` remaps DeviceCMYK.
In practice this means that print PDFs with CMYK images look
incomplete in Evince, Okular and other Poppler-based viewers: the images
are in the file but not shown.
2.**The output intent has no `/DestOutputProfile`.** The profile is not
embedded, only referenced by name and URL, as for PDF/X-4p.
(For PDF/X-4p, ISO 15930-7 describes the reference as
`/DestOutputProfileRef` in the output intent; none is written.)
3.**`format=PDF/X-4` always becomes PDF/X-4p.** `lpdf-fmt-imp-x4.lmt`
is identical to `lpdf-fmt-imp-x4p.lmt`, including `format = "PDF/X-4p"`.
So the XMP claims PDF/X-4p even when the profile is embedded (see
workaround below).
## What I expected
With `format=PDF/X-4` the output profile embedded as
`/DestOutputProfile` (PDF/X-4 requires an embedded output profile),
`/DefaultCMYK [/ICCBased <that stream>]`, and `GTS_PDFXVersion` `PDF/X-4`.
A reference-only output intent only for an explicit `format=PDF/X-4p`.
## Where it comes from
`includeprofile` in `lpdf-fmt.lmt` treats every profile whose `id` is
not `Custom` as external: it flushes the name/URL dictionary and stores
it in `externalprofiles`.
That same object is then used both for the output intent (without
`DestOutputProfile`) and, via `setting ...
as default 'cmyk' color space`, as the operand of `/ICCBased`.
The comment in the output-intent code says that `<id>Custom</id>` is
the way to force embedding.
## Workaround
`<id>Custom</id>` for the profile, in a copy of `colorprofiles.xml` in
the working directory or in a local tree
(`texmf-local/colors/icc/context/colorprofiles.xml`), gives
`/DestOutputProfile` (an ICC stream with `/N 4`), a valid
`/DefaultCMYK`, and Poppler renders the page without complaint.
The identifier in the output intent is then `Custom` instead of
`FOGRA39`, and the XMP still says `PDF/X-4p` (problem 3).
## Suggestion
Embed the profile for PDF/X-4 regardless of the registered id (keeping
the id as `OutputConditionIdentifier`, which is allowed together with
`DestOutputProfile`), never use the external reference dictionary as an
`/ICCBased` operand, and set `format = "PDF/X-4"` in `lpdf-fmt-imp-x4.lmt`.
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________