OpenPrinting / cups-filters

filters, backends, driverless utility, ... - Everything which CUPS 2.x needs to be used on non-Mac systems
Apache License 2.0
151 stars 123 forks source link

PDF printout rotated 180 degrees and mirrored #582

Open kinpass opened 2 months ago

kinpass commented 2 months ago

Describe the bug Encountered a PDF file where the preview and the actual printout don't match, print_mirror.pdf. The preview appears normal:

image

However, the actual printout:

image

The content printed out is rotated 180 degrees and mirrored. Why is this happening, and is there a solution? Expectation: Consistency between the preview and the printout.

I attempted to pinpoint the issue and ultimately discovered that the PDF was processed into output.pdf using the pdftopdf filter.

To Reproduce Steps to reproduce the behavior:

  1. apt-get install cups-pdf
  2. lpadmin -p CUPS-PDF -v cups-pdf:/ -m lsb/usr/cups-pdf/CUPS-PDF_opt.ppd
  3. lp -d CUPS-PDF print_mirror.pdf
  4. the output file path : $HOME/PDF output.pdf

PDF Files print_mirror.pdf output.pdf

System Information: Ubuntu - 23.10 mantic CUPS - 2.4.6-0ubuntu3 arm64 cups-filters - 2.0.0-0ubuntu1 arm64

NJRoadfan commented 2 months ago

This is likely a cups-pdf bug, not CUPS or cupsfilters itself. I've encountered the issue with cups-pdf before. Processing the same jobs with an ippeveprinter instance results in the correct output.

kinpass commented 2 months ago

This is likely a cups-pdf bug, not CUPS or cupsfilters itself. I've encountered the issue with cups-pdf before. Processing the same jobs with an ippeveprinter instance results in the correct output.

Before using cups-pdf, I had been printing with Canon iB4100 and Epson WF C5290, and the actual printouts came out rotated and mirrored. To facilitate reproducing the issue, I started using cups-pdf for verification and reproduction. By analyzing the relevant logs in the error_log, it was observed that when printing to PDF, a pdftopdf filter is applied.

cfFilterUniversal: Adding pdftopdf to chain ... cfFilterPDFToPDF: Processing PDF input with QPDF: Page-ranges, page-set, number-up, booklet, size adjustment, ... ... cfFilterChain: pdftopdf (PID 32527) exited with no errors.

Suspecting an issue with pdftopdf, I attempted to use the pdftopdf filter to generate pdftopdf_output.pdf: /usr/lib/cups/filter/pdftopdf 1 user title 1 '' print_mirror.pdf > pdftopdf_output.pdf

The resulting pdftopdf_output.pdf generated by pdftopdf also appeared rotated and mirrored. It seems to be a bug in /usr/lib/cups/filter/pdftopdf.

Files error_log.zip pdftopdf_output.pdf

michaelrsweet commented 2 months ago

OK, well this still isn't CUPS - moving over to cups-filters...

yogesh1801 commented 2 weeks ago

can i try this issue? is it still unresolved?

tillkamppeter commented 2 weeks ago

@yogesh1801 no problem, please go ahead. Help is always welcome.

yogesh1801 commented 2 weeks ago

i am getting following issue while reproducing this issue. can someone help? image

kinpass commented 2 weeks ago

i am getting following issue while reproducing this issue. can someone help? image

I executed the following commands to reproduce the issue:

sudo apt-get install cups-pdf
lpadmin -p CUPS-PDF -v cups-pdf:/ -m lsb/usr/cups-pdf/CUPS-PDF_opt.ppd
lp -d CUPS-PDF print_mirror.pdf

Did you get any error codes when executing the above commands?

Or try reinstalling cups-pdf:

sudo apt-get reinstall cups-pdf
lpadmin -x CUPS-PDF
lpadmin -p CUPS-PDF -E -v cups-pdf:/ -m lsb/usr/cups-pdf/CUPS-PDF_opt.ppd
lp -d CUPS-PDF print_mirror.pdf

Check if the printer is working properly via http://127.0.0.1:631/printers/ and try printing a test page.

View the PDF of the test page :

ls $HOME/PDF/Test_Page-job_*.pdf

image image

yogesh1801 commented 2 weeks ago

I didn't get any error codes

When printing the test page it gives same error as above

still the same error @tillkamppeter @kinpass

kinpass commented 2 weeks ago

I didn't get any error codes

When printing the test page it gives same error as above

still the same error @tillkamppeter @kinpass

I can't reproduce the issue you encountered. Try using a different method:

cupsfilter -m application/vnd.cups-pdf print_mirror.pdf > print_mirror_out.pdf
# OR
cupsfilter -p /etc/cups/ppd/CUPS-PDF.ppd -m application/vnd.cups-pdf print_mirror.pdf > print_mirror_out.pdf

This method can also generate a problematic PDF, but print_mirror_out.pdf needs to be opened in Chrome to see the content. When I try to open it in Adobe Acrobat, the content is blank. This might be due to a conversion issue preventing it from opening correctly. I have tried converting other PDFs, and they can be opened normally in Adobe Acrobat.

tangyanli commented 2 weeks ago

似乎是文档[print_mirror.pdf]自身的原因,换了一个文档就不会重现该问题。 建议不要用lp命令直接打印,找个应用程序(比如:WPS)打开文档后再次打印。

====

It seems that the problem is caused by the document [print_mirror.pdf] itself. Changing another document will not reproduce the problem. It is recommended not to use the lp command to print directly, but to find an application (such as WPS) to open the document and print it again.

tangyanli commented 2 weeks ago

If there is still an error when printing with WPS, it is recommended to try printing with evince.

tangyanli commented 2 weeks ago

There are some issues with the original file print_mirror.pdf, such as obj 66 being empty. Not sure if these empty objects cause the "pdftopdf" filter to run incorrectly.

$ mutool show print_mirror.pdf 26
26 0 obj
<<
  /Contents 98 0 R
  /MediaBox [ 0 0 595.3 841.9 ]
  /Parent 2 0 R
  /Resources <<
    /ExtGState <<
      /GS14 14 0 R
      /GS8 8 0 R
      /KSPE1 65 0 R
      /KSPE2 68 0 R
    >>
    /Font <<
      /FT28 28 0 R
      /FT9 9 0 R
    >>
    /XObject <<
      /IM15 15 0 R
      /KSPX39 66 0 R
      /KSPX40 69 0 R
      /KSPX46 95 0 R
      /KSPX47 100 0 R
      /KSPX48 104 0 R
    >>
  >>
  /Type /Page
>>
endobj

$ mutool show print_mirror.pdf 66
66 0 obj
null
endobj
kinpass commented 2 weeks ago

似乎是文档[print_mirror.pdf]自身的原因,换了一个文档就不会重现该问题。 建议不要用lp命令直接打印,找个应用程序(比如:WPS)打开文档后再次打印。

====

It seems that the problem is caused by the document [print_mirror.pdf] itself. Changing another document will not reproduce the problem. It is recommended not to use the lp command to print directly, but to find an application (such as WPS) to open the document and print it again.

由于一些限制条件,应用只能通过lp命令来发送打印任务。通过 Adobe Acrobat 打开,打印是正常的。 在以下环境测试时: Ubuntu - 22.04 jammy CUPS - 2.4.1 cups-filters - 1.28.15 通过 lp 打印是正常的,猜测是 cups-filters(2.0.0) 中的 pdftopdf 的问题。

================ Due to certain restrictions, the application can only send print jobs using the lp command. Printing works fine when the document is opened and printed through Adobe Acrobat.

The following environment has been tested and is working correctly: Ubuntu - 22.04 Jammy CUPS - 2.4.1 cups-filters - 1.28.15

Printing via lp works fine, so it is likely an issue with pdftopdf in cups-filters (2.0.0).

================

tangyanli commented 2 weeks ago

cups-filters-1.28.xx依赖libqpdf28; 而cups-filters-2.0依赖libqpdf29。也许问题出在qpdf上。 您可以尝试将原始文档通过如下命令转换(纠正)后,再通过lp打印。

mutool clean -s print_mirror.pdf print_mirror_clean.pdf
lp -d [queue_name] print_mirror_clean.pdf

---translation-- cups-filters-1.28.xx depends on libqpdf28; and cups-filters-2.0 depends on libqpdf29. Maybe the problem is with qpdf. You can try to convert (correct) your original document through the following command, and then print it through lp command.

mutool clean -s print_mirror.pdf print_mirror_clean.pdf
lp -d [queue_name] print_mirror_clean.pdf
kinpass commented 2 weeks ago

cups-filters-1.28.xx依赖libqpdf28; 而cups-filters-2.0依赖libqpdf29。也许问题出在qpdf上。 您可以尝试将原始文档通过如下命令转换(纠正)后,再通过lp打印。

mutool clean -s print_mirror.pdf print_mirror_clean.pdf
lp -d [queue_name] print_mirror_clean.pdf

---translation-- cups-filters-1.28.xx depends on libqpdf28; and cups-filters-2.0 depends on libqpdf29. Maybe the problem is with qpdf. You can try to convert (correct) your original document through the following command, and then print it through lp command.

mutool clean -s print_mirror.pdf print_mirror_clean.pdf
lp -d [queue_name] print_mirror_clean.pdf

感谢您的回复

我验证了一下您的猜测,尝试了3个版本: cups-filters 1.28.15 libqpdf28 cups-filters 1.28.17 libqpdf29 cups-filters 2.0.0 libqpdf29

其中 cups-filters 1.28.15 libqpdf28 这个版本lp后pdf是正常的。

从现象上看,应该是 libqpdf29 的问题。但具体原因还不清楚。

通过执行您提供的命令:

mutool clean -s print_mirror.pdf print_mirror_clean.pdf
lp -d [queue_name] print_mirror_clean.pdf

lp后的内容正常了,可先通过该方法来解决这类pdf的问题。

==============translation==============

Thank you for your response.

I verified your assumption by testing three versions:

cups-filters 1.28.15 with libqpdf28 cups-filters 1.28.17 with libqpdf29 cups-filters 2.0.0 with libqpdf29 Among these, the combination of cups-filters 1.28.15 with libqpdf28 produced a normal PDF after using lp.

Based on this, it seems to be an issue with libqpdf29. However, the specific cause is still unclear.

By executing the command you provided:

mutool clean -s print_mirror.pdf print_mirror_clean.pdf
lp -d [queue_name] print_mirror_clean.pdf

the output from lp is normal. This method can temporarily resolve issues with such PDFs.

=======================================