OpenPrinting / OpenPrinting/libcupsfilters

pdftopdf exits with status 1 (no error message) on PDFs with form fields lacking /N and /BBox

Open
#246 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
17
Forks
71
Avg merge
2d 17h
Merged PRs (30d)
13

Description

pdftopdf exits with status 1 (no error message) on PDFs with form fields lacking /N and /BBox

Summary

pdftopdf terminates with exit status 1 when processing a PDF that contains
AcroForm fields whose appearance streams are missing the required /N entry
and /BBox. It emits only warnings, never an error, and gives no indication
that it is about to fail. The next filter in the chain (ghostscript) receives
an empty stream, reports "Input is empty, outputting empty file" and exits 0.
The job then fails with the generic message universal filter failed., which
points at the wrong component and makes the cause very hard to locate.

The same PDF prints fine after being rewritten by Ghostscript with
-dShowAnnots=false.

Versions

Package Version
libcupsfilters 2.2.1
cups-filters 2.0.1
libppd 2.1.1
cups 2.4.19
ghostscript 10.07.1
Distribution Artix Linux (Arch-based, rolling)

Printer: HP Smart Tank 7000 series, USB, hpcups driver with PPD.
The printer itself is not relevant — the failure happens before any
printer-specific filter is reached.

Steps to reproduce

Invoke the filter chain manually on an affected PDF:

sudo env \
  PPD=/etc/cups/ppd/HP-Smart-Tank-7000-series.ppd \
  CONTENT_TYPE=application/pdf \
  FINAL_CONTENT_TYPE=application/vnd.cups-raster \
  CUPS_DATADIR=/usr/share/cups \
  CUPS_SERVERBIN=/usr/lib/cups \
  /usr/lib/cups/filter/universal 1 user test 1 "" affected.pdf > /dev/null

Actual output

Abbreviated; the annotation block repeats once per form field:

DEBUG: page 1: Contains annotations
DEBUG: Opening field stream 1/4... with obj number 17
Key 'N' not found.
WARNING: Appearance stream is missing required /BBox.
DEBUG: special case ignore annotation with no appearance
...
DEBUG: Opening content stream 1/1...
DEBUG: Opened stream 1, resmap[1]=(nil)
DEBUG: cfFilterChain: pdftopdf completed with status 1.
DEBUG: cfFilterGhostscript: Input is empty, outputting empty file.
DEBUG: cfFilterChain: ghostscript completed with status 0.
ERROR: cfFilterChain: pdftopdf (PID 7025) stopped with status 1
INFO: cfFilterChain: ghostscript (PID 7026) exited with no errors.
ERROR: universal filter failed.

Note that pdftopdf walks both pages to completion and handles every
annotation via the "special case ignore annotation with no appearance"
path, so the failure does not appear to happen at the point where the
malformed annotations are encountered.

Expected behaviour

Either process the document (the malformed annotations are already being
skipped) or fail with a message that names the problem. The current
behaviour produces a misleading error that attributes the failure to the
universal filter.

Additional observations

  • A minimal PDF generated with gs -sDEVICE=pdfwrite passes through the
    same chain without any problem, so the chain itself is intact.
  • Rewriting the file with
    gs -sDEVICE=pdfwrite -dPrinted=false -dShowAnnots=false makes it print
    normally. This is what I am currently using as a workaround.
  • qpdf --flatten-annotations=all does not help — qpdf exits without
    complaint but the malformed appearance streams survive and pdftopdf
    still fails.
  • The failure is independent of the print path: it occurs identically via
    lp, via a PPD-based queue and via a driverless everywhere queue
    (the printer does not accept application/pdf, so PDF conversion runs
    in that case too).
  • Job options make no difference; the failure reproduces with an empty
    option string.

Possible regression

Printing these documents worked on this machine before libcupsfilters was
upgraded from 2.1.1 to 2.2.1. No other component of the print stack changed
in the relevant time window (ghostscript, poppler, cups and cups-filters
were all older than the last known-good print).

I have not verified this by downgrading, so please treat the regression
claim as circumstantial rather than confirmed.

Sample file

The document that triggered this is a personal order confirmation, so I
cannot attach it. Any PDF with AcroForm fields whose appearance streams
lack /N and /BBox should reproduce the issue; the warnings quoted
above are the reliable indicator in the log.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the pdftopdf stage in the universal filter chain and reproduce the failure using the supplied environment and command. Inspect how malformed AcroForm appearance streams are handled and how pdftopdf's status is propagated when the output is empty. Done means the document is processed successfully or the failure clearly identifies the malformed annotations instead of reporting only a generic universal-filter error.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
backend, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.