Repository navigation
pdftopdf: read job-sheets as "start,end" and use the CUPS job title - #297
Merged
tillkamppeter merged 1 commit intoOct 23, 2026
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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