OpenPrinting / cups

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

Difference between pdf print from command line (lp/lpr) and from any GUI (like as Atril) #882

Closed x09 closed 6 months ago

x09 commented 8 months ago

Describe the bug I have few printers, by example is EPSON L3250 (epson-inkjet-printer-escpr rpm) and Samsung SCX 3405 (Unified Linux Driver by HP/Samsung).

I have simple pdf file without any errors

additional information
[root@alt-wks-k2 tmp]# qpdf --check /tmp/mysimplefile.pdf 
checking /tmp/mysimplefile.pdf
PDF Version: 1.6
File is not encrypted
File is not linearized
No syntax or stream encoding errors found; the file may still contain
errors that qpdf cannot detect
 
[root@alt-wks-k2 tmp]# pdfinfo /tmp/mysimplefile.pdf
Creator:          XeTeX output 2022.03.04:1127
Producer:        MiKTeX-xdvipdfmx (0.7.9)
CreationDate:    Fri Mar  4 12:29:38 2022 +05
ModDate:         Fri Mar  4 12:30:10 2022 +05
Custom Metadata: no
Metadata Stream: yes
Tagged:          no
UserProperties:  no
Suspects:        no
Form:            none
JavaScript:      no
Pages:           4
Encrypted:       no
Page size:       841.89 x 595.276 pts (A4)
Page rot:        0
File size:       371985 bytes
Optimized:       no
PDF version:     1.6

If to print pdf from any GUI (Atril) then file printed perfectly. If to print pdf from command line (lp -d EPSON_L3250 /path/tofilename.pdf) then file printed with artefacts.

I uncomment FileDevice yes option in cups configuration, replace DeviceURI to file

[root@alt-wks-k2 tmp]# grep -B 1 DeviceURI /etc/cups/printers.conf
MakeModel EPSON L3250 Series , Epson Inkjet Printer Driver (ESC/P-R) for Linux
DeviceURI file:/tmp/printer.prn
--
MakeModel Samsung SCX-3400 Series
DeviceURI file:/tmp/samsung.dump

And printed from GUI and from lp/lpr again file /tmp/printer.prn from lp and from GUI - have a differents sizes.

I turn on debug and compare cups/error_log The lp/lpr job is very different from GUI job. I see GUI job uses 'gs', but lp not

Why? How print from lp/lpr correctly? It's bug?

System Information: cups-2.4.7 Linux

zdohnal commented 8 months ago

Hi,

the difference in files which are sent to printer between lp and application is not a bug in most cases - the fact you have opened PDF in an application does not mean the application sends the same file for printing - it usually is not the same PDF and sometimes not even PDF. Applications usually generate a new file (either PDF or some other format) when sending the file to CUPS, but lp sends the exact file you pass on CLI.

Since you mention ghostscript, I would guess the application sends Postscript file to CUPS, while lp sends the original PDF, which might contain fonts unknown to the printer (my guess) - so my first advice is to update firmware on printer.

Either way, artifacts when printing via lp is not desired and can be issue in printing stack.

Please check https://github.com/OpenPrinting/cups/blob/master/REPORTING_ISSUES.md and provide CUPS debug logs when you print from lp and application, PPD file for the printer you used, d files from /var/spool/cups for jobs from lp and application, and scan of the output document with artifacts (ideally mark where artifacts are - if the issue is with local alphabet, I might not be able to tell whether the character is good or bad...).

x09 commented 8 months ago

[root@localhost cups]# cupsctl LogLevel=debug2

[root@localhost cups]# cat /etc/cups/printers.conf
# Printer configuration file for CUPS v2.4.7
# Written by cupsd
# DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING
NextPrinterId 2

PrinterId 1
UUID urn:uuid:9a60a838-7f34-327e-4e26-dfc105bb705f
Info Epson L3250
Location 
MakeModel EPSON L3250 Series , Epson Inkjet Printer Driver (ESC/P-R) for Linux
DeviceURI file:/tmp/epson
State Idle
StateTime 1706847171
ConfigTime 1706847171
Type 4108
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy retry-job


[root@localhost cups]# lpstat -e
Epson-L3250

[root@localhost cups]# LANG=en_US.UTF-8 lpstat -t
scheduler is running
system default destination: Epson-L3250
device for Epson-L3250: /tmp/epson
Epson-L3250 accepting requests since Fri 02 Feb 2024 07:12:51 AM MSK
printer Epson-L3250 is idle.  enabled since Fri 02 Feb 2024 07:12:51 AM MSK

[root@localhost cups]#  lpinfo -v
network beh
network ipps
network ipp
network lpd
network http
network https
direct hp
network socket
network smb
direct hpfax

[root@localhost cups]#  cd /var/log/cups/

[root@localhost cups]#  echo >/var/log/cups/error_log; lp -d Epson-L3250 /home/tuser/myfile_1.pdf ; sleep 1; /bin/cp -f /var/log/cups/error_log /tmp/lp-error_log.txt

[root@localhost cups]#  echo >/var/log/cups/error_log; ...open atril and print myfile_1.pdf... ;  /bin/cp -f /var/log/cups/error_log /tmp/gui-error_log.txt

lp-error_log.txt gui-error_log.txt

x09 commented 8 months ago

lp vs gui

diff_2024-02-02_11-54

zdohnal commented 6 months ago

Thank you for the data!

Can you attach the file you try to print and d file from /var/spool/cups when you print from Atril? I can't check whether the file looks ok before it goes into epson filter without it :( . But the scans are great, I have something which I can compare with.

Additionally, the log for lp is missing the job - 1s wait is too short (you can make it a loop, checking until lpstat -o does not return anything).