Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-28-2009, 10:02 AM   #1
LQ Newbie
Registered: Oct 2009
Posts: 1

Rep: Reputation: 0
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?
Old 10-28-2009, 01:43 PM   #2
Registered: Nov 2006
Location: southeastern PA
Distribution: Slackware
Posts: 130

Rep: Reputation: 23
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.
Old 10-28-2009, 02:47 PM   #3
LQ Newbie
Registered: Sep 2005
Location: Long Island, NY
Distribution: Slackware
Posts: 20

Rep: Reputation: 0
Post 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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
printing japanese pdf via ghostscript checkmate3001 Linux - Software 2 05-31-2009 11:10 PM
slackware printing cups/ghostscript npavlidis Slackware 7 02-25-2008 07:06 PM
Trouble printing pdf's SlowMindThinkin Linux - Software 1 01-10-2005 03:36 AM
Printing PDF's from PHP DeathsFriend Programming 2 03-23-2004 04:05 AM
Ghostscript printing moot Linux - Software 1 01-31-2003 05:05 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:20 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration