OpenPrinting / OpenPrinting/foo2zjs

foo2ddst emits a redundant "PAGE: n copies" marker, causing CUPS to double-count printed pages

Open Beginner friendly
#29 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
8
Forks
5
PR merge metrics
No merged PRs in 30d

Description

This is a third, distinct issue found while debugging the Ricoh SP112 /
foo2ddst setup covered in #<issue_1> and #<issue_2>.

Observation

A 1-page document (confirmed as exactly 1 page via the source
application's print preview before sending) consistently shows
"Pages: 2" in the CUPS web UI job list (/jobs) when printed through
foo2ddst. Only one physical sheet is actually printed — this is purely
an accounting/display discrepancy in CUPS's job page count, not an
actual duplicate print.

Switching the same printer queue to an alternative PPD/filter
(https://github.com/vaginessa/ricoh-sp112-ppd, pstoricohddst-gdi) with
the same document does NOT reproduce this — it correctly shows
"Pages: 1".

Root cause

foo2ddst.c's start_page() function emits its own CUPS page-accounting
marker:

++pageno;
if (IsCUPS)
    fprintf(stderr, "PAGE: %d %d\n", pageno, Copies);

However, the standard CUPS "pstops" filter — which runs earlier in the
filter chain, before foomatic-rip/foo2ddst-wrapper ever sees the data —
already emits this same "PAGE: n copies" marker once per real page, as
is standard practice across CUPS printer filters. foo2ddst emitting a
second, redundant marker per page causes CUPS to count each physical
page twice.

Fix that resolved it locally

Removed the redundant fprintf() call in start_page() (foo2ddst.c, near
line 560-562):

++pageno;
if (IsCUPS)
    fprintf(stderr, "PAGE: %d %d\n", pageno, Copies);

After rebuilding without this line, single-page jobs correctly show
"Pages: 1" in the CUPS job list, with no change in actual printed
output (still exactly one sheet).

Suggested fix upstream

Remove the redundant PAGE: emission from foo2ddst.c's start_page(),
since page accounting is already handled by the upstream "pstops"
filter. This is likely low-impact/cosmetic (doesn't affect actual
printing) but does affect job accounting accuracy shown to users and
any tooling that relies on CUPS's reported page counts (e.g. usage
tracking, quota systems).

Happy to provide the full patch diff if useful.

Contributor guide

No contributing guide indexed for this repository

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

Inspect foo2ddst.c's start_page() near lines 560-562 and compare its PAGE marker with the upstream pstops behavior described in the issue. Remove the redundant emission, rebuild foo2zjs, and print a one-page document through CUPS to verify the job reports Pages: 1 while still producing one physical sheet.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.