Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Copies ignored when printing from Chromium with duplex (splix PPD lacks *Collate; CUPS chain passes NumCopies correctly)

已关闭 适合新手
#33 9 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cpp
领域
devtools

调研方向

从 src/rastertoqpdl.cpp 和 include/request.h 开始,追踪 CUPS 的份数值如何传递到 Request,然后阅读输出 PJL 作业头的 src/printer.cpp。当请求的份数大于一时,将其添加到作业头中,并确认两份作业包含 @PJL SET COPIES=2,而一份作业保持不变。

由索引模型根据 Issue 内容生成。

描述

Summary

rastertoqpdl silently drops the number of copies requested by the application: every job prints exactly one copy, no matter what "copies" value is passed through CUPS. This is most visible when printing from a browser (Chromium/Edge: duplex + N copies → only one sheet comes out), but it affects every client that requests copies through the CUPS job options, including plain lp -n 2.

Root cause
  • src/rastertoqpdl.cpp reads the copies count from the CUPS filter argv[4] and stores it in the Request object (Request::_copiesNr, set in loadRequest()).
  • But _copiesNr / copiesNr() is never read anywhere afterwards.
  • The copy count that actually ends up in the QPDL page header (src/qpdl.cpp: header[0x2..0x3] = page->copiesNr()) is taken from the CUPS raster page header (src/document.cpp: page->setCopiesNr(header.NumCopies)), which raster producers leave at 1.

Net effect: the requested copies count is discarded.

How to reproduce
lp -n 2 -d <splix-driven-queue>   # a one-page job prints exactly one copy

Observed on a Samsung ML-2160 (USB), splix 2.0.2, CUPS 2.4.16, Ubuntu 26.10.

Suggested fix

Let the printer engine duplicate the job: emit @PJL SET COPIES=N in the PJL job header when N > 1. Engine-side duplication keeps per-copy duplex collation correct, whereas duplicating page data inside the QPDL stream would break collation for duplex jobs.

The following patch against 2.0.2 was built and verified on an ML-2160: after applying it, a 2-copy job stream contains @PJL SET COPIES=2, while 1-copy jobs are untouched.

--- splix-pristine/include/request.h
+++ splix-patched/include/request.h
@@ -110,6 +110,10 @@
           */ 
         Duplex                  duplex() const {return _duplex;}
         /**
+          * @return the number of copies requested for this job.
+          */
+        unsigned long           copiesNr() const {return _copiesNr;}
+        /**
           * @return TRUE if it's a reversed duplex. Otherwise it returns FALSE.
           */
         bool                    reverseDuplex() const {return _reverseDuplex;}
--- splix-pristine/src/printer.cpp
+++ splix-patched/src/printer.cpp
@@ -272,6 +272,11 @@
             break;
     }
  
+    // Honor the number of copies requested by the application (CUPS argv[4]):
+    // the engine duplicates the job, which keeps duplex collation correct.
+    if (request.copiesNr() > 1)
+        printf("@PJL SET COPIES=%lu\n", request.copiesNr());
+
     // Set some job options
     if (request.ppd()->get("MediaType").isNull())
         printf("@PJL SET PAPERTYPE=OFF\n");

Happy to prepare a proper PR if that helps.

主要语言
C++
星标
54
派生
20
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

OpenPrinting/splix 的其他 Issue

查看 OpenPrinting/splix 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。