OpenPrinting / cups

OpenPrinting CUPS Sources
https://openprinting.github.io/cups
Apache License 2.0
1.1k stars 195 forks source link

Print options from UI software cannot be correctly passed to CUPS backend #1093

Closed tthnu closed 1 week ago

tthnu commented 4 weeks ago

Describe the bug I implemented a simplified backend based on cups-pdf, which only logs all argv[] parameters to a log file. Using this backend, I created a virtual printer with the lpadmin -p -P command. After triggering a print operation with this virtual printer, I observed whether the argv parameters received in the CUPS backend matched the options selected in the UI. I consistently tested with A4, black and white printing, DuplexTumble, and 1200 dpi. I noticed that among different WPS family software, the PDF reader consistently fails to retrieve argv[5] parameters that match the options selected in the UI, while the other doc/ppt/excel software can correctly obtain the matching parameters in the CUPS backend.

Did I make any mistakes while implementing the PPD file?

CUPS backend source code in briefly:


int main(int argc, char* argv[])
{
....
    for (int i = 0; i < argc; i++) {
       printf("argv[%d] = %s", i, argv[i]);
    }
....
}

PPD file : The entries starting with zh_CN. are some Chinese characters.

*PPD-Adobe: "4.3"
*%%%% My Virtual Printer
*%%%% PPD file for My Virtual Printer.
*%%%%%% 1. 20 keywords are required according to PPD Specification 4.3.
*%%%%%% And some rigid rules should be complied such as no more than 255
*%%%%%% characters in one line.
*%%%%%% 2. Set cupsFilter to application/vnd.cups-postscript
*%%%%%% so that it's postscript type stream when entering backend.
*%%%%%% 
*FormatVersion: "4.3"
*FileVersion: "3.21.12"
*LanguageVersion: English
*LanguageEncoding: ISOLatin1
*Product: "(My Virtual Printer)"
*Manufacturer: "My"
*ModelName: "My Virtual Printer model"
*ShortNickName: "My virtual printer"
*NickName: "My Virtual Printer model, version 1.0"
*PSVersion: "(3010.000) 0"
*PCFileName: "cups-my-template.ppd"
*ColorDevice: True
*DefaultColorSpace: RGB
*% ============================ImageableArea================================
*%ImageableArea
*ImageableArea Letter_8_1\2x11_in/Letter_8_1\2x11_in: "12 12 583 830"
*zh_CN.ImageableArea Letter_8_1\2x11_in/信纸: "12 12 583 830"
*ImageableArea Legal_8_1\2x14_in/Legal_8_1\2x14_in: "12 12 583 830"
*zh_CN.ImageableArea Legal_8_1\2x14_in/法律专用纸: "12 12 583 830"
*ImageableArea Executive_7_1\4x10_1\2_in/Executive_7_1\4x10_1\2_in: "12 12 583 830"
*zh_CN.ImageableArea Executive_7_1\4x10_1\2_in/Executive: "12 12 583 830"
*ImageableArea A4_210x297_mm/A4_210x297_mm: "12 12 583 830"
*zh_CN.ImageableArea A4_210x297_mm/A4: "12 12 583 830"
*ImageableArea A5_148x210_mm/A5_148x210_mm: "12 12 583 830"
*zh_CN.ImageableArea A5_148x210_mm/A5: "12 12 583 830"
*DefaultImageableArea: Letter_8_1\2x11_in
*% ============================PageRegion===================================
*OpenUI *PageRegion/Media Size: PickOne
*PageRegion Letter_8_1\2x11_in/Letter_8_1\2x11_in: "Letter_8_1\2x11_in"
*zh_CN.PageRegion Letter_8_1\2x11_in/信纸: "信纸"
*PageRegion Legal_8_1\2x14_in/Legal_8_1\2x14_in: "Legal_8_1\2x14_in"
*zh_CN.PageRegion Legal_8_1\2x14_in/法律专用纸: "法律专用纸"
*PageRegion Executive_7_1\4x10_1\2_in/Executive_7_1\4x10_1\2_in: "Executive_7_1\4x10_1\2_in"
*zh_CN.PageRegion Executive_7_1\4x10_1\2_in/Executive: "Executive"
*PageRegion A4_210x297_mm/A4_210x297_mm: "A4_210x297_mm"
*zh_CN.PageRegion A4_210x297_mm/A4: "A4"
*PageRegion A5_148x210_mm/A5_148x210_mm: "A5_148x210_mm"
*zh_CN.PageRegion A5_148x210_mm/A5: "A5"
*DefaultPageRegion: Letter_8_1\2x11_in
*CloseUI: *PageRegion
*% ============================PageSize=====================================
*OpenUI *PageSize/Media Size: PickOne
*PageSize Letter_8_1\2x11_in/Letter_8_1\2x11_in: "Letter_8_1\2x11_in"
*zh_CN.PageSize Letter_8_1\2x11_in/信纸: "信纸"
*PageSize Legal_8_1\2x14_in/Legal_8_1\2x14_in: "Legal_8_1\2x14_in"
*zh_CN.PageSize Legal_8_1\2x14_in/法律专用纸: "法律专用纸"
*PageSize Executive_7_1\4x10_1\2_in/Executive_7_1\4x10_1\2_in: "Executive_7_1\4x10_1\2_in"
*zh_CN.PageSize Executive_7_1\4x10_1\2_in/Executive: "Executive"
*PageSize A4_210x297_mm/A4_210x297_mm: "A4_210x297_mm"
*zh_CN.PageSize A4_210x297_mm/A4: "A4"
*PageSize A5_148x210_mm/A5_148x210_mm: "A5_148x210_mm"
*zh_CN.PageSize A5_148x210_mm/A5: "A5"
*DefaultPageSize: Letter_8_1\2x11_in
*CloseUI: *PageSize
*% ============================PaperDimension===============================
*%PaperDimension
*PaperDimension Letter_8_1\2x11_in/Letter_8_1\2x11_in: "595 842"
*zh_CN.PaperDimension Letter_8_1\2x11_in/信纸: "595 842"
*PaperDimension Legal_8_1\2x14_in/Legal_8_1\2x14_in: "595 842"
*zh_CN.PaperDimension Legal_8_1\2x14_in/法律专用纸: "595 842"
*PaperDimension Executive_7_1\4x10_1\2_in/Executive_7_1\4x10_1\2_in: "595 842"
*zh_CN.PaperDimension Executive_7_1\4x10_1\2_in/Executive: "595 842"
*PaperDimension A4_210x297_mm/A4_210x297_mm: "595 842"
*zh_CN.PaperDimension A4_210x297_mm/A4: "595 842"
*PaperDimension A5_148x210_mm/A5_148x210_mm: "595 842"
*zh_CN.PaperDimension A5_148x210_mm/A5: "595 842"
*DefaultPaperDimension: Letter_8_1\2x11_in
*% =======================End of 20 required keywords=======================

*% =========================================================================
*% =======================Start of my-defined keywords==================
*LanguageLevel: "3"
*cupsVersion: 2.3
*cupsModelNumber: 0
*cupsManualCopies: True
*cupsFilter: "application/vnd.cups-postscript 100 -"
*cupsFilter: "application/* 0 -"
*cupsLanguages: "en zh zh_CN"
*% =======================End of my-defined keywords====================

*% =========================================================================
*% =======================Start of important keywords=======================
*% ============================ColorModel===================================
*OpenUI *ColorModel/Output Mode: PickOne
*ColorModel Color/Color: Color
*zh_CN.ColorModel Color/彩色打印: "彩色打印"
*ColorModel Gray/Gray: Gray
*zh_CN.ColorModel Gray/灰色打印: "灰色打印"
*ColorModel Black/Black: Black
*zh_CN.ColorModel Black/黑白打印: "黑白打印"
*DefaultColorModel: Color
*CloseUI: *ColorModel
*% ============================MediaType====================================
*OpenUI *MediaType/Media Type: PickOne
*MediaType user-defined_paper_type2/user-defined_paper_type2: "user-defined_paper_type2"
*zh_CN.MediaType user-defined_paper_type2/其他光面喷墨打印纸: "其他光面喷墨打印纸"
*MediaType user-defined_paper_type1/user-defined_paper_type1: "user-defined_paper_type1"
*zh_CN.MediaType user-defined_paper_type1/普通纸,轻磅纸/再生纸: "普通纸,轻磅纸/再生纸"
*DefaultMediaType: user-defined_paper_type9
*CloseUI: *MediaType
*% ============================Print Quality================================
*OpenUI *Resolution/Print Quality: PickOne
*Resolution 600dpi/600dpi: "[600 600]"
*Resolution 300dpi/300dpi: "[300 300]"
*Resolution 1200dpi/1200dpi: "[1200 1200]"
*DefaultResolution: 600dpi
*CloseUI: *Resolution
*% ============================Duplex=======================================
*OpenUI *Duplex/2-Sided Printing: PickOne
*DefaultDuplex: None
*Duplex None/None: "None"
*Duplex DuplexNoTumble/DuplexNoTumble: "LongEdgeBinding"
*Duplex DuplexTumble/DuplexTumble: "ShortEdgeBinding"
*DefaultDuplex: None
*CloseUI: *Duplex
*% ============================Media Source=================================
*OpenUI *InputSlot/Media Source: PickOne
*InputSlot from_source_bin/from_source_bin: "from_source_bin"
*zh_CN.InputSlot from_source_bin/自动选择: "自动选择"
*InputSlot user-defined_bin1/user-defined_bin1: "user-defined_bin1"
*zh_CN.InputSlot user-defined_bin1/主纸盒: "主纸盒"
*DefaultInputSlot: from_source_bin
*CloseUI: *InputSlot

*% End of cups-my-template.ppd

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior The parameters seen in the backend for printers created from the same PPD file should remain consistent.

Screenshots I chose A4, black and white printing, DuplexTumble, and 1200 dpi in all test case.

printing a .pdf file===========> which is different from cases below. Maybe it messed up and missed some options such as dpi and ColorModel.

00:51:01 [DEBUG] argv[5] = media=Letter_8_1\2x11_in sides=two-sided-short-edge job-uuid=urn:uuid:468d1029-3100-3c52-6a91-be656cf4d8f8 job-originating-host-name=localhost date-time-at-creation= date-time-at-processing= time-at-creation=1730307061 time-at-processing=1730307061 document-name-supplied=0e2cd672d7a79 Duplex=DuplexTumble PageSize=Letter_8_1\2x11_in

printed a .xlsx file:

00:46:16 [DEBUG] argv[5] = media=Letter_8_1\2x11_in sides=one-sided ColorModel=Black Duplex=DuplexTumble PageRegion=A4_210x297_mm PageSize=A4_210x297_mm Resolution=1200dpi job-uuid=urn:uuid:c88c0a3a-9155-3e0a-7fc4-1fa90b2522af job-originating-host-name=localhost date-time-at-creation= date-time-at-processing= time-at-creation=1730306776 time-at-processing=1730306776 document-name-supplied=0d0df672bca1f

printed a .docx file

00:48:41 [DEBUG] argv[5] = media=Letter_8_1\2x11_in sides=one-sided ColorModel=Black Duplex=DuplexTumble PageRegion=A4_210x297_mm PageSize=A4_210x297_mm Resolution=1200dpi number-up=1 number-up-layout=lrtb orientation-requested=3 job-uuid=urn:uuid:c6a40c98-5169-3c2b-578e-96bb1a7b3722 job-originating-host-name=localhost date-time-at-creation= date-time-at-processing= time-at-creation=1730306921 time-at-processing=1730306921 document-name-supplied=0edfd672266c1

printed a .pptx file

00:49:51 [DEBUG] argv[5] = media=Letter_8_1\2x11_in sides=one-sided nolandscape ColorModel=Black Duplex=DuplexTumble PageRegion=A4_210x297_mm PageSize=A4_210x297_mm Resolution=1200dpi job-uuid=urn:uuid:524742c6-c5c1-37a4-5297-98aed1385fdb job-originating-host-name=localhost date-time-at-creation= date-time-at-processing= time-at-creation=1730306991 time-at-processing=1730306991 document-name-supplied=0be2f672b49a9

System Information:

szlt5 commented 4 weeks ago

You should report this issue to WPS.

szlt5 commented 4 weeks ago

Or try to download the newest WPS from https://www.wps.cn

michaelrsweet commented 1 week ago

Yes, this is probably the application not passing the options through...