Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Print PDF using Win32::OLE and Acrobat Reader

by kalyanrajsista (Scribe)
on Feb 23, 2010 at 11:39 UTC ( #824842=perlquestion: print w/ replies, xml ) Need Help??
kalyanrajsista has asked for the wisdom of the Perl Monks concerning the following question:

Hello all

I'm using the following code to print PDF using my network printer. But the problem is that I need to Install Adobe Reader 6 to achieve my task. Is there any workaround that I can print PDF's by having acrobat reader version 6.0 or more

Or any Perl modules which prints the PDF's with any version of Acrobat installed ....

use strict; use warnings; use Win32::OLE; use Win32::OLE::Const "Acrobat"; my $acrobat = Win32::OLE->new("AcroExch.App", "Quit"); my $avdoc = Win32::OLE->new("AcroExch.AVDoc"); my $pdfs = getPDF("/from/some/folder"); foreach my $pdf( @{$pdfs} ) { $avdoc->Open( $pdf, "" ); my $pddoc = Win32::OLE->new("AcroExch.PDDoc"); $pddoc->Open($pdf); my $pp = $pddoc->GetNumPages; #index starts at 0 my $totalpages = $pp; if ( $pp ) { $pp--; } eval { print "Printing $pdf with $totalpages pages\n"; $avdoc->PrintPagesSilent(0,$pp,1,1,0); }; if ( $@ ) { print "PDF did not print due to Adobe error.\n"; } $acrobat->Exit; }

Thanks to original author for giving me a pointer to help achieve my task

Comment on Print PDF using Win32::OLE and Acrobat Reader
Download Code
Re: Print PDF using Win32::OLE and Acrobat Reader
by ww (Bishop) on Feb 23, 2010 at 13:43 UTC
    Perhaps one of these will help?

    Using Win32::OLE and Acrobat is going the loooooong way around the barn. And, given Adobe's recent track record, the price of the package, and the frequency of updates, you probably don't want to install any version of Acrobat.

Re: Print PDF using Win32::OLE and Acrobat Reader
by molecules (Monk) on Feb 23, 2010 at 14:37 UTC

      I'm trying with the following program

      #!c:/perl/bin/perl -w use strict; use Win32::API; my $filename = "foobar.pdf"; my $shellopen = new Win32::API("shell32", "ShellExecute", ['N', 'P', 'P', 'P', 'P', 'I'], 'N'); $shellopen->Call(0, "print", $filename, 0, 0, 0);

      also, let me know if there are any issues/dependencies for the above program

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://824842]
Approved by Ratazong
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2014-10-23 00:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (123 votes), past polls