Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Win32::OLE and Adobe Acrobat

by BMaximus (Chaplain)
on Jan 10, 2006 at 22:10 UTC ( #522333=perlquestion: print w/ replies, xml ) Need Help??
BMaximus has asked for the wisdom of the Perl Monks concerning the following question:

I've searched Google and PM over and over again using just about every search term I could think of. What I have to do is create a batch process that prints out certificates and each certificate has a name and unique id on it. I've tried finding documentation on using the Acrobat OLE but I can't seem to find anything at all on how to use it. Not even on Adobe's site. Does anyone know where I might be able to find documentation of how to use the OLE. What I need to write has to be on a Windows system.


Replies are listed 'Best First'.
Re: Win32::OLE and Adobe Acrobat
by idsfa (Vicar) on Jan 10, 2006 at 23:00 UTC

    Perhaps you should look at PDF::Template instead. It is designed to do this sort of thing.

    use PDF::Template my $pdf = PDF::Template->new( filename => 'some_template.xml', ); $pdf->write_file('some_file.pdf');

    With a template like:

    <pdftemplate pagesize="Letter" h='8'> <loop name="FOO"> <pagedef> <font face="Times-Roman"> <row> <textbox w="80%"><var name="name"/></textbox> <textbox w="20%"><var name="number"/></textbox> </row> </font> </pagedef> </loop> </pdftemplate>

    The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. — Cyrus H. Gordon
Re: Win32::OLE and Adobe Acrobat
by jimbojones (Friar) on Jan 10, 2006 at 22:55 UTC
Re: Win32::OLE and Adobe Acrobat
by traveler (Parson) on Jan 10, 2006 at 23:20 UTC
    I have used PDF::API2 for such tasks. With SuperSearch you can find links to tutorials, examples and so forth.
      I've used this module and it looks like this is the best way to do what I need to do. The problem is getting the PDF to print on its own without the user having to open the file and print it. I've looked in to Win32::Printer but unfortunately it looks like the ppm from ActiveState is corrupted. It wont install. I tried downloading it from CPAN and installing it using nmake but since I don't have a compiler it blows up. looks like its dead so I can't get it from there either.

        Do you need to create pdf files or just print them (it sounds like you have the first covered and are just wondering about the second)? If you just need to print it then the the first reply had the answer:
        AcroRd32.exe /t path "printername" "drivername" "portname" Initiates Adobe Reader and prints a file, whose path must be fully spe +cified, while suppressing the Print dialog box.

        I know it's not OLE, but it ought to work :-)

        Also, there's another version of the Win32::Printer ppm in the Kobes repository.

Re: Win32::OLE and Adobe Acrobat
by marto (Bishop) on Jan 11, 2006 at 01:06 UTC
    Hi BMaximus,

    Have you looked at the module PDF::Reuse? It's designed to mass produce unique PDF files based on the a template file and content you provide (in your case names and the unique ID you mentioned). You could have a template per design of certificate you indend to create then populate them with data as you require.

    Hope this helps.

Re: Win32::OLE and Adobe Acrobat
by blm (Hermit) on Jan 11, 2006 at 11:52 UTC

    Actually you dont even need OLE to do this. There is a Win32 API call "ShellExecute" exported by shell32.dll. Basically you pick a file and what you want to do with it (open print etc) and it goes and looks up how to do it from the registry, starts the appropriate application and tells the application to perform the action. These actions are what you see as the first options in the right click context menu for the file that you want to perform the action on.

    Knowing this I did a search for on Google and found this script by Brad Fitzpatrick (the livejournal guy). I then modified it and tested it on my computer and it works.

    #!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);

    You might have to install Win32::API but I had no trouble doing this with the ppm in the latest 5.8 perl from Activestate. Let me know if you have problems.

Re: Win32::OLE and Adobe Acrobat
by InfiniteSilence (Curate) on Jan 10, 2006 at 22:16 UTC
    Searched Google, eh? You must not have looked too hard. This is one of the first hits.

    Celebrate Intellectual Diversity

      Not so. I did find that and it didn't have the answer I needed. That document was more like a FAQ than a list of methods. It was useless.



        Looks like this is part of Adobe's Developer accounts Adobe SDK which includes the methods that are visible via OLE. It is not free.

        Hope this helps

        Jason L. Froebe

        Team Sybase member

        No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2016-08-29 18:28 GMT
Find Nodes?
    Voting Booth?
    The best thing I ever won in a lottery was:

    Results (408 votes). Check out past polls.