LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Printing problems (https://www.linuxquestions.org/questions/linux-newbie-8/printing-problems-4175635096/)

ferrari 08-27-2018 05:47 AM

A little experiment - running the filters by hand as described here...

http://www.penguintutor.com/linux/printing-cups

See if you can take a the CUPS testprint page, create a PDF, and run the pdftops filter successfully by hand....
Code:

export PPD=/etc/cups/ppd/HP_Color_LaserJet_CM2320nf_MFP.ppd
/usr/lib/cups/filter/bannertopdf 1 tim '' 1 '' </usr/share/cups/data/testprint >bannertopdf.pdf
/usr/lib/cups/filter/pdftops 1 tim '' 1 '' <bannertopdf.pdf >pdftops.ps

The last command will produce a lot of output, but hopefully will complete successfully as it did for me (with pdftops.ps file created). There is a warning in the page I linked to about how this can hang with a R.Pi. I wonder if this is what you're encountering? Anyway, try it and see if it completes without errors. Post the output that it generates as that might yield useful debugging information.

giancarlo64 08-27-2018 07:54 AM

Hi Ferrari,
I have executed the commands and this are the results:

Code:

pi@raspberrypi:~ $ /usr/lib/cups/filter/bannertopdf 1 tim '' 1 '' </usr/share/cups/data/testprint >bannertopdf.pdf
DEBUG: Could not open PPD file '/etc/cups/ppd/HP_Color_LaserJet_CM2320nf_MFP.ppd'
PDF template file doesn't have form. It's okay.

Code:

pi@raspberrypi:~ $ /usr/lib/cups/filter/pdftops 1 tim '' 1 '' <bannertopdf.pdf >pdftops.ps
DEBUG: pdftops - copying to temp print file "/tmp/050dc5b8aa334"
DEBUG: Printer make and model:
DEBUG: Running command line for pstops: pstops 1 tim  1
DEBUG: Using image rendering resolution 300 dpi
DEBUG: Running command line for gs: gs -q -dNOPAUSE -dBATCH -dSAFER -dNOMEDIAATTRS -sDEVICE=ps2write -sOUTPUTFILE=%stdout -dLanguageLevel=3 -r300 -dCompressFonts=false -dNoT3CCITT -dNOINTERPOLATE -c 'save pop' -f /tmp/050dc5b8aa334
DEBUG: Started filter gs (PID 20701)
DEBUG: Started post-processing (PID 20702)
DEBUG: Started filter pstops (PID 20703)
DEBUG: slow_collate=0, slow_duplex=0, slow_order=0
DEBUG: Before copy_comments - %!PS-Adobe-3.0
DEBUG: %!PS-Adobe-3.0
DEBUG: %%BoundingBox: 0 0 612 792
DEBUG: %%HiResBoundingBox: 0 0 612.00 792.00
DEBUG: %%Creator: GPL Ghostscript 920 (ps2write)
DEBUG: %%LanguageLevel: 2
DEBUG: %%CreationDate: D:20180827124304Z00'00'
DEBUG: %%Pages: 1
DEBUG: %%EndComments
DEBUG: Before copy_prolog - %%BeginProlog
DEBUG: Adding Setup section for option PostScript code
DEBUG: Before copy_setup - %%BeginSetup
DEBUG: Before page loop - %%Page: 1 1
DEBUG: Copying page 1...
PAGE: 1 1
DEBUG: pagew = 576.0, pagel = 720.0
DEBUG: bboxx = 0, bboxy = 0, bboxw = 612, bboxl = 792
DEBUG: PageLeft = 18.0, PageRight = 594.0
DEBUG: PageTop = 756.0, PageBottom = 36.0
DEBUG: PageWidth = 612.0, PageLength = 792.0
DEBUG: PID 20701 (gs) exited with no errors.
DEBUG: Wrote 1 pages...
DEBUG: PID 20702 (Post-processing) exited with no errors.
DEBUG: PID 20703 (pstops) exited with no errors.


Seeing the error (DEBUG: Could not open PPD file '/etc/cups/ppd/HP_Color_LaserJet_CM2320nf_MFP.ppd') as user pi I have tried also to execute it from root


Code:

root@raspberrypi:/home/pi# /usr/lib/cups/filter/bannertopdf 1 tim '' 1 '' </usr/share/cups/data/testprint >bannertopdf.pdf
PDF template file doesn't have form. It's okay.

Code:

root@raspberrypi:/home/pi# /usr/lib/cups/filter/pdftops 1 tim '' 1 '' <bannertopdf.pdf >pdftops.ps
DEBUG: pdftops - copying to temp print file "/tmp/052725b914c43"
DEBUG: Printer make and model: HP Hewlett-Packard HP Color LaserJet CM2320wi MFP
DEBUG: Running command line for pstops: pstops 1 tim  1
DEBUG: Using image rendering resolution 600 dpi
DEBUG: Running command line for gs: gs -q -dNOPAUSE -dBATCH -dSAFER -dNOMEDIAATTRS -sDEVICE=ps2write -sOUTPUTFILE=%stdout -dLanguageLevel=3 -r600 -dCompressFonts=false -dNoT3CCITT -dNOINTERPOLATE -c 'save pop' -f /tmp/052725b914c43
DEBUG: Started filter gs (PID 21107)
DEBUG: Started filter pstops (PID 21108)
DEBUG: Page = 595x842; 12,12 to 583,830
DEBUG: slow_collate=0, slow_duplex=0, slow_order=0
DEBUG: Before copy_comments - %!PS-Adobe-3.0
DEBUG: %!PS-Adobe-3.0
DEBUG: %%BoundingBox: 0 0 595 842
DEBUG: %%HiResBoundingBox: 0 0 595.00 842.00
DEBUG: %%Creator: GPL Ghostscript 920 (ps2write)
DEBUG: %%LanguageLevel: 2
DEBUG: %%CreationDate: D:20180827124906Z00'00'
DEBUG: %%Pages: 1
DEBUG: %%EndComments
DEBUG: Before copy_prolog - %%BeginProlog
DEBUG: Before copy_setup - %%Page: 1 1
DEBUG: Before page loop - %%Page: 1 1
DEBUG: Copying page 1...
DEBUG: pagew = 571.1, pagel = 817.6
DEBUG: bboxx = 0, bboxy = 0, bboxw = 595, bboxl = 842
DEBUG: PageLeft = 12.0, PageRight = 583.1
DEBUG: PageTop = 829.7, PageBottom = 12.1
DEBUG: PageWidth = 595.0, PageLength = 842.0
DEBUG: Wrote 1 pages...
DEBUG: PID 21108 (pstops) exited with no errors.
DEBUG: PID 21107 (gs) exited with no errors.

Also tested other command as indicated by http://www.penguintutor.com/linux/printing-cups

Code:

pi@raspberrypi:~ $ gs -sDEVICE=cups -dNOPAUSE -dBATCH -sOutputFile=out Visite.pdf
GPL Ghostscript 9.20 (2016-09-26)
Copyright (C) 2016 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
INFO: Start rendering...
INFO: Processing page 1...
Processing pages 1 through 1.
Page 1
INFO: Processing page 2...
INFO: Rendering completed

Code:

pi@raspberrypi:~ $ /usr/lib/cups/filter/pdftoraster 1 tim '' 1 '' <bannertopdf.pdf >pdftoraster.ras
DEBUG: PPD file is not specified.
DEBUG: mediaBox = [ 0.000000 0.000000 612.000000 792.000000 ]; rotate = 0

Gian Carlo

ferrari 08-27-2018 02:39 PM

Ok, that pdftops filter test seems to have executed without issue. BTW, you should be able to view the created pdftops.ps file with gs like this
Code:

gs pdftops.ps
I can only wonder if some specific PDF documents are causing the issue here. You might need to experiment a bit.

BTW, there was no need to test gs specifically - it is called by pdftops for rendering anyway. The pdftoraster filter is also not involved in the filter chain for your printer, so irrelevant here.

giancarlo64 08-27-2018 05:52 PM

Hi Ferrari,
cups-filter version is 1.11.6

Code:

apt-cache policy libcupsfilters1

libcupsfilters1:
  Installed: 1.11.6-3+rpi1
  Candidate: 1.11.6-3+rpi1
  Version table:
 *** 1.11.6-3+rpi1 500
        500 http://archive.raspberrypi.org/debian stretch/main armhf Packages
        100 /var/lib/dpkg/status
    1.11.6-3 500
        500 http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages


Gian Carlo

ferrari 08-27-2018 06:13 PM

Quote:

Hi Ferrari,
cups-filter version is 1.11.6
Ok, not so important to know now, as we've demonstrated that the pdftops filter is working. However, as mentioned before some experimentation with different PDF files may be needed. When it failed, were you trying to print a multi-page PDF for example?

The pdftops filter uses Ghostscript by default, but it is possible to switch from Ghostscript to Poppler if required.
This might be worth a shot here. You can run the following commands in a terminal window for switching between Ghostscript and Poppler:

lpadmin -p <printer> -o pdftops-renderer-default=gs
lpadmin -p <printer> -o pdftops-renderer-default=pdftops

Reference:
CUPS bug report

So, for your printer you could try
Code:

lpadmin -p HP_Color_LaserJet_CM2320nf_MFP -o pdftops-renderer-default=pdftops
This will add the following option in the printer configuration (/etc/cups/printers.conf)
Code:

Option pdftops-renderer pdftops
Then try printing a PDF again.

giancarlo64 08-28-2018 02:49 AM

3 Attachment(s)
Hi Ferrari,
I have added
Code:

Option pdftops-renderer pdftops
trough the command
Code:

lpadmin -p HP_Color_LaserJet_CM2320nf_MFP -o pdftops-renderer-default=pdftops
now it seems little bit better

This are the results in the order that I have tested:

TEST 1

Sent an email with txt in the body and attached PDF

txt converted by my script to PS printed correctly (JOB 1263)
PDF not printed (JOB 1264): Printed a page with the following informations:

ERROR: syntaxerror
OFFENDING COMMAND: J b= @7Z $ /
STACK sfnts, --mark--,--string--,--string--,--string--,--string--,--string--,--string--,--string--,
--string--,--string--,--string--,--string--,--string--,--string--,--string--,--string--,
--string--,--string--,--string--,--string--,--string--,--string--,--string--,--string--,
--string--,--string--,--string--,--string--,--string--,--string--,--string--,--string--,
--string--,--string--,--string--,--string--,--string--,--string--,--string--,--string--,
--string--,--string--,--string--,--string--,--string--,--string--,

pdfinfo of the PDF

Code:

Author:        Gian
Creator:        Writer
Producer:      LibreOffice 5.1
CreationDate:  Mon Aug 27 06:39:20 2018 UTC
Tagged:        no
UserProperties: no
Suspects:      no
Form:          none
JavaScript:    no
Pages:          1
Encrypted:      no
Page size:      595 x 842 pts (A4)
Page rot:      0
File size:      48329 bytes
Optimized:      no
PDF version:    1.4

I have attached an the CUPS error logfile: error-log CM2320nf_MFP20180828.txt


TEST 2

Sent an email with txt in the body and attached PDF Since the beginning of this post is the first time that I can print this PDF

pdfinfo of the file

Code:

Subject:        File: EK001E00 Job: QPRTJOB System: CHEMKS01
Author:        QTMPLPD
Creator:        IBM i program EMPRDPGM/EKB001
Producer:      2A55SM1 SpoolMail by Gumbo Software Inc V2R9M0   
CreationDate:  Mon Aug 20 13:54:57 2018 UTC
Tagged:        no
UserProperties: no
Suspects:      no
Form:          none
JavaScript:    no
Pages:          1
Encrypted:      no
Page size:      595 x 841 pts
Page rot:      0
File size:      22497 bytes
Optimized:      no
PDF version:    1.4

TXT is JOB 1265
PDF is JOB 1266

both printed correctly


TEST 3

Retry to print TEST 2. with the same results: both files printed correctly

TXT is JOB 1267
PDF is JOB 1268



TEST 4


txt converted by my script to PS and printed correctly (JOB 1269)
PDF printed correctly but CUPS show as status canceled (JOB 1270). Since the beginning of this post is the first time that I can print this PDF
pdfinfo:

Code:

Title:          untitled
Subject:        unspecified
Author:        anonymous
Producer:      ReportLab http://www.reportlab.com
CreationDate:  Tue Aug 21 07:22:08 2018 UTC
Tagged:        no
UserProperties: no
Suspects:      no
Form:          none
JavaScript:    no
Pages:          1
Encrypted:      no
Page size:      595.276 x 841.89 pts (A4)
Page rot:      0
File size:      48096 bytes
Optimized:      no
PDF version:    1.3


I have attached an the CUPS error logfile: error-log CM2320nf_MFP20180828-2.txt



I have also attached a screen-shot of the CUPS JOBS status. I noticed that when the TXT file indicates unknown pages after the PDF is shown as canceled.
I don't know if there is a relation....

It seems we are on the right way .... with still some problems

Regards

Gian Carlo

ferrari 08-28-2018 04:22 AM

That does read like progress, and ultimately a CUPS bug report would probably bee needed to progress this further. However, since you are taking emails with PDFs attached and printing them via your custom script, I'm going to suggest trying another approach. Take the PDF document and convert it to PS with the pdf2ps (ghostscript) utility or 'pdftops' (poppler-tools). Note the latter is not the same executable as the filter you ran previously, although it uses the same supporting libraries.

If you can convert the 'problematic' PDF files to PS files, and then submit the print job, we'll avoid using the CUPS 'pdftops' filter, and maybe print more successfully.

The ghostsctipt utility get's executed like this ('man pdf2ps' for more info):
pdf2ps [ options ] input.pdf output.ps

The pdftops utility ('man pdftops' for more info) like this:
pdftops [options] input.pdf [output.ps]

The following blog will be of interest to you about using/comparing these two tools...
https://www.stefaanlippens.net/pdf2ps_vs_pdftops/

See how that goes.

giancarlo64 09-02-2018 10:20 AM

Hi again Ferrari,
I have introduced in my script the conversion of all PDF to PS before printing but nothing changed.
On the LAN I have also a LINUX x86 PC for the VPN connection. I have installed CUPS on that machine and the HP driver (shared on the network) and I have tried to print from the Raspberry using x86 PC printer driver.
I can now print with no problems all the documents (PDF, JPG, TXT, PS, HTML ...)
keeping the pdftops converter in my script I can also print "fillable PDF" that I couldn't print before (the fillable fields was printed as empty not only ARM based PC also on x86 PC)
For now, because I have to be operational, I keep for the moment the driver on the x86 PC but it would be interesting to try to find the problems on the raspberry.
Do you think is a raspberry CUPS compiling problem ?

Gian Carlo

ferrari 09-02-2018 03:00 PM

Well done getting this far. I think to progress this any further would take a bug report.

Shadow_7 09-05-2018 06:12 PM

Quote:

Originally Posted by giancarlo64 (Post 5894696)
pi user belongs to the following groups

pi adm dialout cdrom sudo audio video plugdev games users input netdev lpadmin gpio i2c spi

I see lpadmin which is needed to configure the localhost:631 part of cups as admin. But I don't see "lp" which is what allows printing. At least for debian (raspbian). Exim4 is what debian installs by default for cups to talk print jobs with cups over the LAN. Not an admin, but I doubt mutt is configured by default for this task. And more of a mail receiver than server. Bear in mind that once you change your groups, you need to logout and back in for it to take affect.

ferrari 09-05-2018 09:15 PM

There should be no need to be a member of the 'lp' group for printing. Any user who is logged in should be able to print to an attached printer via CUPS. In addition, when used as a CUPS server, the following cupsd.conf configuration permits access to any host connected to the LAN...
Code:

< Location / >
# Restrict access to the server...
Order allow,deny
Allow @local
< /Location >

It can all be adjusted to suit the requirements of the administrator of course.

Reference:
https://www.cups.org/doc/policies.html

In any case, this has nothing to do with the issues faced in this thread.

ferrari 09-19-2018 03:44 AM

Reported.


All times are GMT -5. The time now is 05:48 AM.