Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Module to print pdf from command line? 1

Status
Not open for further replies.

Jimbo2112

IS-IT--Management
Mar 18, 2002
109
GB
Hi All,

Is there a module I can invoke to print pdf's from? I would also like to be able to print just the first page of the pdf as well.

I have tried going down the batch processing route in Acrobat itself, but I have not found a way of making that work unattended.

Cheers!

Jimbo
 
Jimbo -- have you had a look at ?

Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Jimbo,
I don't know of any perl mods that will print pdf's. You would need to read the PDF and then output in the printer's language (i.e. PostScript, PCL/HP-GL, etc).

On a unix box it should be fairly straight forward. Just install acrobat reader. It can output from the command line to a postscript compatible printer. Eg:
Code:
acroread -toPostScript -start 1 -end 1 < input.pdf | lp -d your-postscript-printer
You can also install the postscript utilities from GhostView and use them to manipulate your pdf/postscript files.

If your on winders you might be able to get the utils from GhostScript to work, but I don't do winders so I can't help on that front.

Good luck.
 
Thanks both,

The answer is below ...... too simple really!


#!perl -w

$reader = '&quot;C:\\Program Files\\Adobe\\Acrobat 4.0\\Acrobat\\Acrobat.exe&quot;';

@options = ('/p', '/h');
$file = &quot;C:\\Temp\\a.pdf&quot;;
@args = ($reader, @options, $file);
system(@args);
 
Jimb02112,

Thanks, this code works well. But it leaves acrobat running and the user must close it manually.

Is there a way to close acrobat after the print? Besides getting a listing of all processes, grep-ing for acrobat, and killing it?

May be a elemenatary question but where are the /p and /h flags explained? I assume /p -> print and /h -> hide, but are there others?

Thanks again...
 
Hi Canine,

As Adobe has gone to later versions they have put in less command line options for printing pdf's. The best way to get more control over your pdf's is to search online for third party software that has the functionality through a separate interface than Acrobat. There are plenty around that do a variety of functions.

Regards

Jimbo
 
Open Office offers export functionality to pdf. And Open office is available under both linux/unix and windows.

Don't know yet if OO offers a command line function for it... (will look into it)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top