1751804 Members
5332 Online
108781 Solutions
New Discussion юеВ

Printing a PDF Document

 
SOLVED
Go to solution
John Waller
Esteemed Contributor

Printing a PDF Document

I'm looking for a way to use acroread to print pdf documents to a printer from the command line or via a script. I've been looking at the following thread:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1090377
which talks about using xinit but it doesn't explain how direct output to the printer, or give details about the options used within the wrapper.
I can print the pdf by using the command cat tmp.pdf | acroread -toPostScript -shrink -size a4 | lp -dprinter but this doesn't appear to shrink the document to fit onto the page. Any help anybody can give would be welcomed.
4 REPLIES 4
Andrew Merritt_2
Honored Contributor

Re: Printing a PDF Document

Hi John,
Piping the output to 'lp' should be sending it to the printer (as in that thread you quoted). Assuming that's a postscript printer, it should then print.

What are you actually getting printed?

I don't have documentation; is the order of arguments significant? If so, does 'acroread -toPostScript -size a4 -shrink' work better?

Andrew
John Waller
Esteemed Contributor

Re: Printing a PDF Document

Andrew,

I do get printed output but it is doesn't reduce to fit onto the page correctly.

One other point I forgot to mention is that I need to set the DISPLAY to a valid xterminal and cannot use the Xvfb as described in the previous thread. Ideally I don't want to do this as the site where I want to implement this printing facility currently don't have any X terminals
Tony Berry
Valued Contributor
Solution

Re: Printing a PDF Document

We use Ghostscript to print PDF files created on Windows workstations dropped on a SAMBA mount to our HP-UX systems. When we originally set this up, the X libraries were needed, but you didn't need to be running X (init 3 was fine). Since then, I think they've changed that requirement.

I'm not sure if this is what you need, but it sounded relevant. We specify several orientation, sizing, and page specifications on the command line, which is formatted from a custom application.

http://www.ghostscript.com/awki/Ghostscript
Unix is boss.
John Waller
Esteemed Contributor

Re: Printing a PDF Document

Tony,

Many thanks for the idea of using Ghostscript. After some playing with the settings I've managed to get a correct sized printout from the command line using the command

gs -sDEVICE=pswrite -sPAPERSIZE=a4 -sOutputFile=%pipe%"lp -dprinter" -q -dNOPAUSE -dBATCH ducument.pdf.

As document.pdf is 2 pages I found I had to use the -dNOPAUSE option. The only thing I have found is that I get a message saying:

GNU Ghostscript 8.55: **** Could not open the file lp -dprinter .
but I still get the output sent to the correct printer.