Skip to content

pdftopdf: read job-sheets as "start,end" and use the CUPS job title - #297

Merged
tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
alviss7:pdftopdf-job-sheets-none
Oct 23, 2026
Merged

tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
alviss7:pdftopdf-job-sheets-none

Conversation

@alviss7

@alviss7 alviss7 commented Oct 22, 2026

Copy link
Copy Markdown

cupsd passes job-sheets as "start,end", so a queue with JobSheets none none
sends "job-sheets=none,none" to the filters. pdftopdf compared the whole
string with "none" and added a banner page at both ends of every job. The
same check guarded both banners, so "standard,none" also got an end banner.

The value is now split on the comma: the first part controls the start
banner, the second the end banner, and a single value only asks for a start
banner (same as cupsd). "none" is matched case-insensitively, like cupsd
does.

The banner also printed "Title: Untitled" and "User: Guest": CUPS gives the
title and user as filter arguments, not as job-name /
job-originating-user-name options. pdftopdf now falls back to
data->job_title and data->job_user.

One behaviour change: "job-sheets=standard" alone used to print a start and
an end banner, it now prints only the start one.

New test: cupsfilters/test-pdftopdf-job-sheets.sh checks the page count for
unset, none, none,none, None,NONE, standard, standard,none, none,standard
and standard,standard, and the banner text. Without the pdftopdf change,
4 of these cases fail (none,none gives 3 pages for a 1-page input).

An open question, which this PR leaves alone: under cupsd, banners are
normally printed by cupsd itself (an extra document through bannertopdf).
For a local queue cupsd does not pass job-sheets to the filters at all; it
only does for a remote queue, where the remote server prints the banner.
In that case a pdftopdf banner for "standard" comes on top of the remote
one. The qpdf-based pdftopdf never generated banners. Should pdftopdf skip
banners when it runs under cupsd? I kept the existing behaviour and only
fixed the parsing.

Fixes #262

CUPS sends job-sheets as "start" or "start,end", so a queue with
JobSheets none none gives the filters "job-sheets=none,none".
pdftopdf compared the whole value with "none", so every such job got a
banner page at the start and another at the end. The same test guarded
both banners, which also printed an end banner for "standard,none".

Split the value on the comma: the first part is the start banner, the
second the end banner, and a single value only asks for a start banner,
as cupsd does.

The banner also showed "Title: Untitled" and "User: Guest", because
cfFilterOptionsCreate() only looks at the job-name and
job-originating-user-name options, while CUPS passes the title and user
as filter arguments (argv[3] and argv[2]). Use data->job_title and
data->job_user when those options are absent.

Add test-pdftopdf-job-sheets.sh, which counts the output pages for
several job-sheets values and checks the banner text.

Fixes OpenPrinting#262
@tillkamppeter
tillkamppeter merged commit ea62f9c into OpenPrinting:master Oct 23, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pdftopdf generates two unwanted banner pages when job-sheets=none,none

2 participants