LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Printing PDF's using ghostscript (https://www.linuxquestions.org/questions/linux-newbie-8/printing-pdfs-using-ghostscript-765051/)

gurps_cov 10-28-2009 10:02 AM

Printing PDF's using ghostscript
 
I have a web application running on linux. One of the things the application does is creates a PDF document and stores it on disk. It then executes a shell script to print the PDF directly to the printer. The command used is:

gs -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=ljet4 -sOutputFile=|lp myPdfDocument.pdf

The printer is set to US Letter size by default therefore I have passed in the paper size. The PDF itself was created using a Java library known as FOP and the dimensions of the PDF match that of letter size.

My problem is that if you print a pdf document from your web browser using File > print e.t.c. it prints fine. If you print the same PDF using ghostscript, the fonts come out bigger and the text gets chopped off at the margins.

Version of ghostscript = 7.07

Also, is it absolutely neccesary to use ghostscript to print the PDF? can't you just use 'lp'?

Any ideas?

HaroldWho 10-28-2009 01:43 PM

Quote:

If you print the same PDF using ghostscript, the fonts come out bigger and the text gets chopped off at the margins.
Try adding the option "-dPDFFitPage" to the "gs" command.

softbear 10-28-2009 02:47 PM

Syntax?
 
FWIW, lpr some.pdf prints correctly on this system (gs v. 8.63, and I don't have a version 7 handy right now.) The PDF was created here with that printer as the default from Konqueror.

Unless there are some single quotes missing here, you appear to be effectively doing an 'lp myPdfDocument.pdf' with the gs output going to the lp <stdin> which isn't being captured. The gs manpage says that to create an output pipe using the device setting as a filter, one would say -sOutputFile=%pipe%lpr which on my printer creates a slightly different output than the example above.

If your printer is named ljet4, then I'm not sure why you're using an -sOutputFile at all, just use -sDEVICE=lpname and skip all the pipe nonsense. If you're NOT printing to an ljet4, you need to insert the correct target device.


All times are GMT -5. The time now is 02:56 PM.