Forum Bugs

Dangling indirect object reference in /Annots (non-commercial license, Prince 16.2)

patrick
We've found that PDFs generated by Prince 16.2 (non-commercial license) contain a dangling indirect object reference in the page's "/Annots" entry. The page dictionary references an object (e.g. "10 0 R" that is never defined in the file's cross-reference table, making the PDF technically invalid per ISO 32000.

How to reproduce:

Run prince on any HTML input — the simplest case is enough:

echo '<html><body><p>Hello</p></body></html>' > input.html
prince input.html -o output.pdf



Inspecting the raw PDF, the page dictionary contains: "/Annots 10 0 R"

But object 10 is never defined. The defined objects are
[1, 2, 3, 4, 5, 8, 9, 11, 12, ...]
— note the gap where objects 6, 7, and 10 should be.

Impact:

Lenient PDF readers (pikepdf/qpdf, Adobe Acrobat) silently repair the missing object, so the PDF appears to work. However, stricter PDF tools crash when they try to resolve the reference. For example, PyPDF2 fails with:

PdfReadWarning: Object 10 0 not defined.
PyPDF2.utils.PdfReadError: Could not find object.


This breaks any workflow that programmatically reads or merges pages from Prince-generated PDFs.

Clarification:

The watermark annotation content itself is fine — the
/Text
and
/Popup
annotations are present in the file. The issue is only that the
/Annots
array object that contains them is referenced from the page dictionary but never written as a defined object.

Environment:

  • Prince 16.2, non-commercial license
  • macOS (arm64)
  • Reproducible with any HTML input, no special flags needed

Reproduction script:

I've put together a self-contained Python script that generates the PDF and verifies the dangling reference: https://gist.github.com/patrick-atticus/50bc04a824e024bc92a31aae0483167b

It only requires Prince on PATH and
pip install pikepdf
.