Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[regression] pdftopdf handles "roll" page sizes incorrectly. #583

Open
Sandelinos opened this issue May 10, 2024 · 4 comments
Open

[regression] pdftopdf handles "roll" page sizes incorrectly. #583

Sandelinos opened this issue May 10, 2024 · 4 comments

Comments

@Sandelinos
Copy link

I have 2 machines. One of which is running Debian 11 and cups-filters-core-drivers 1.28.7-1+deb11u2, the other is running Debian 12 and cups-filters-core-drivers 1.28.17-3. Connected to both I have "CUSTOM Engineering VKP80III" receipt printers configured as follows:

  1. Install the vendor's driver
  2. lpadmin -p CUSTOM_Engineering_VKP80III -E -v 'usb://...' -m CUSTOM/VKP80III.ppd.gz
  3. lpadmin -d CUSTOM_Engineering_VKP80III
  4. lpadmin -p CUSTOM_Engineering_VKP80III -o PageSize=X50MMYRoll
  5. lpadmin -p CUSTOM_Engineering_VKP80III -o PaperRotation=1Rot180

On the Debian 11 machine everything works as expected and the printed receipt is cut to the length of the content, but on the Debian 12 machine around 40 cm of receipt is printed even when the content is less than 10 cm.

To debug this I have created a debug queue on the Debian 11 machine like this:
lpadmin -p debug -v file:/tmp/out.dat -E -m CUSTOM/VKP80III.ppd.gz
Then copied out.dat to the Debian 12 machine and printed it using lp -o raw out.dat and got a correct print so I know the printer driver is working OK.

Then I ran the pdftopdf filter manually on the 2 devices with the same input pdf and got these results:

Debian 11:

user@debian11:~$ sudo env PPD='/etc/cups/ppd/CUSTOM_Engineering_VKP80III.ppd' /lib/cups/filter/pdftopdf 1 user title 1 'finishings=3 number-up=1' ticket.pdf > /tmp/pdftopdf.pdf && pdfinfo /tmp/pdftopdf.pdf
DEBUG: pdftopdf: No FINAL_CONTENT_TYPE environment variable, could not determine whether to log pages or not, so turned off page logging.
DEBUG: pdftopdf: Last filter determined by the PPD: None; FINAL_CONTENT_TYPE: (null) => pdftopdf will not log pages in page_log.
DEBUG: PDF interactive form and annotation flattening done via QPDF
Title:          Ticket
Creator:        Chromium
Producer:       Skia/PDF m124
CreationDate:   Fri May 10 15:44:57 2024 EEST
ModDate:        Fri May 10 15:44:57 2024 EEST
Tagged:         yes
UserProperties: no
Suspects:       no
Form:           none
JavaScript:     no
Pages:          1
Encrypted:      no
Page size:      114 x 212.88 pts
Page rot:       0
File size:      19804 bytes
Optimized:      no
PDF version:    1.4

Debian 12:

user@debian12:~$ sudo env PPD='/etc/cups/ppd/CUSTOM_Engineering_VKP80III.ppd' /lib/cups/filter/pdftopdf 1 user title 1 'finishings=3 number-up=1 print-color-mode=monochrome' /tmp/ticket.pdf > /tmp/pdftopdf.pdf && pdfinfo /tmp/pdftopdf.pdf
DEBUG: pdftopdf: No FINAL_CONTENT_TYPE environment variable, could not determine whether to log pages or not, so turned off page logging.
DEBUG: pdftopdf: Last filter determined by the PPD: None; FINAL_CONTENT_TYPE: (null) => pdftopdf will not log pages in page_log.
DEBUG: PDF interactive form and annotation flattening done via QPDF
DEBUG: pdftopdf: "print-scaling" IPP attribute: auto
DEBUG: pdftopdf: Print scaling mode: Do not scale, center, crop if needed
After Cropping: 114.000000 212.879990 136.000000 1690.000000
Title:           Ticket
Creator:         Chromium
Producer:        Skia/PDF m124
CreationDate:    Fri May 10 15:44:57 2024 EEST
ModDate:         Fri May 10 15:44:57 2024 EEST
Custom Metadata: no
Metadata Stream: no
Tagged:          yes
UserProperties:  no
Suspects:        no
Form:            none
JavaScript:      no
Pages:           1
Encrypted:       no
Page size:       136 x 1690 pts
Page rot:        0
File size:       21043 bytes
Optimized:       no
PDF version:     1.4

On the Debian 11 machine Page size is 114 x 212.88 pts, while on the Debian 12 machine Page size is 136 x 1690 pts. I also tried specifying print-scaling=none in pdftopdf's options but it made no difference.

I've attached the ppd file that comes with the driver below. (renamed to .txt because github wouldn't let me attach a .ppd)
VKP80III.txt

@ditikos
Copy link

ditikos commented May 14, 2024

I am having the same issues in cups-filters past 1.28.x (ubuntu) , after the other issue I raised I started experimenting yesterday on a Star TSP 700II and a Parnertech RP700 printer set.

I am having trouble because the paper is not calculated as roll (dynamically) but as the whole piece while in pdf it generates the actual representation as it was with previous 1.27.x cups filters

From the three printers I've tested (I also tested with an POS80 printer) the POS80 printer can render the actual paper because it uses different ways to calculate the pagesize and the pagereigion. The other two thermal printers use the standard ppdc output variable named "VariablePaperSize".

I am happy to help you triage the issue with other printers, in fact if you can write the steps above or attach any file I can reverify if there is the case to other printers as well.

@Sandelinos
Copy link
Author

I tested versions from 1.28.7 to 1.28.17 and found that the issue was introduced in 1.28.12.

Here is a test.pdf I used as input and output pdfs from pdftopdf versions 1.28.11.pdf and 1.28.12.pdf.
This is the ppd file used: CUSTOM_Engineering_VKP80III.txt (renamed to .txt because github won't let me attach a .ppd)

$ git checkout 1.28.11 && ./autogen.sh && LIBQPDF_CFLAGS=-std=c++17 ./configure --disable-avahi && make -j4
[output trimmed]
$ PPD=~/cups-filters/CUSTOM_Engineering_VKP80III.ppd ./pdftopdf 1 user title 1 'finishings=3 number-up=1' ~/cups-filters/test.pdf > ~/cups-filters/1.28.11.pdf
DEBUG: pdftopdf: No FINAL_CONTENT_TYPE environment variable, could not determine whether to log pages or not, so turned off page logging.
DEBUG: pdftopdf: Last filter determined by the PPD: None; FINAL_CONTENT_TYPE: (null) => pdftopdf will not log pages in page_log.
DEBUG: PDF interactive form and annotation flattening done via QPDF
$ git checkout 1.28.12 && ./autogen.sh && LIBQPDF_CFLAGS=-std=c++17 ./configure --disable-avahi && make -j4
[output trimmed]
$ PPD=~/cups-filters/CUSTOM_Engineering_VKP80III.ppd ./pdftopdf 1 user title 1 'finishings=3 number-up=1' ~/cups-filters/test.pdf > ~/cups-filters/1.28.12.pdf
DEBUG: pdftopdf: No FINAL_CONTENT_TYPE environment variable, could not determine whether to log pages or not, so turned off page logging.
DEBUG: pdftopdf: Last filter determined by the PPD: None; FINAL_CONTENT_TYPE: (null) => pdftopdf will not log pages in page_log.
DEBUG: PDF interactive form and annotation flattening done via QPDF
DEBUG: pdftopdf: "print-scaling" IPP attribute: auto
DEBUG: pdftopdf: Print scaling mode: Do not scale, center, crop if needed

@ditikos
Copy link

ditikos commented May 14, 2024

I posted in the apple/cups issues (so if you don't find my post here apologies), so I am using 1.28.15-0ubuntu2 version which falls into the area of your problem. I will test the above steps too, tomorrow as well and see if they match. But it is definitely a problem, which I don't know if anyone using thermal printers has seen it.

@ditikos
Copy link

ditikos commented May 16, 2024

So I tested that with my own pdf (can't add this here because it's sensitive code and needs regulator approvals), but I can confirm the same issue:

On ubuntu 20.04 the cups/cupsfilters version are:

sudo dpkg -l |grep cups-filter
ii  cups-filters                                  1.27.4-1ubuntu0.2                        amd64        OpenPrinting CUPS Filters - Main Package
ii  cups-filters-core-drivers                     1.27.4-1ubuntu0.2                        amd64        OpenPrinting CUPS Filters - Driverless printing

Performing the test:

sudo env PPD='/etc/cups/ppd/RP-700-U-1.ppd' /lib/cups/filter/pdftopdf 1 user title 1 'finishings=3 number-up=1' ./ticket.pdf > ./pdftopdf.pdf && pdfinfo ./pdftopdf.pdf
DEBUG: pdftopdf: No FINAL_CONTENT_TYPE environment variable, could not determine whether to log pages or not, so turned off page logging.
DEBUG: pdftopdf: Last filter determined by the PPD: None; FINAL_CONTENT_TYPE: (null) => pdftopdf will not log pages in page_log.
DEBUG: PDF interactive form and annotation flattening done via QPDF
Producer:       GPL Ghostscript 9.50
CreationDate:   Fri Apr 26 12:09:11 2024 EEST
ModDate:        Fri Apr 26 12:09:11 2024 EEST
Tagged:         no
UserProperties: no
Suspects:       no
Form:           none
JavaScript:     no
Pages:          1
Encrypted:      no
Page size:      205 x 343.15 pts
Page rot:       0
File size:      13824 bytes
Optimized:      no
PDF version:    1.4

On Ubuntu 22.04.4:

root@ath-pt-opos-10:~# sudo dpkg -l |grep cups-filter
ii  cups-filters                           1.28.15-0ubuntu1.2                      amd64        OpenPrinting CUPS Filters - Main Package
ii  cups-filters-core-drivers              1.28.15-0ubuntu1.2                      amd64        OpenPrinting CUPS Filters - Driverless printing

Same pdf:

sudo env PPD='/etc/cups/ppd/PTech-RP700.ppd' /lib/cups/filter/pdftopdf 1 user title 1 'finishings=3 number-up=1 print-color-mode=monochrome' /tmp/ticket.pdf > /tmp/pdftopdf.pdf && pdfinfo /tmp/pdftopdf.pdf
DEBUG: pdftopdf: No FINAL_CONTENT_TYPE environment variable, could not determine whether to log pages or not, so turned off page logging.
DEBUG: pdftopdf: Last filter determined by the PPD: None; FINAL_CONTENT_TYPE: (null) => pdftopdf will not log pages in page_log.
DEBUG: PDF interactive form and annotation flattening done via QPDF
DEBUG: pdftopdf: "print-scaling" IPP attribute: auto
DEBUG: pdftopdf: Print scaling mode: Do not scale, center, crop if needed
After Cropping: 205.000000 343.149994 204.000000 646.000000
Producer:        GPL Ghostscript 9.50
CreationDate:    Fri Apr 26 10:09:11 2024 BST
ModDate:         Fri Apr 26 10:09:11 2024 BST
Custom Metadata: no
Metadata Stream: yes
Tagged:          no
UserProperties:  no
Suspects:        no
Form:            none
JavaScript:      no
Pages:           1
Encrypted:       no
Page size:       204 x 646 pts
Page rot:        0
File size:       14097 bytes
Optimized:       no
PDF version:     1.4

So I can also confirm this issue with a different ppd but thermal printer whatsoever.

Regards, Panos

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

No branches or pull requests

2 participants