Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: calling AcroPDF.dll from perl

by rpnoble419 (Pilgrim)
on Jul 05, 2008 at 07:34 UTC ( #695664=note: print w/ replies, xml ) Need Help??


in reply to calling AcroPDF.dll from perl

Try this. It works with 5.8 and Win32::GUI. Keep in mind this is a sample application and you should refer to the Adobe Acrobat SDK for more information.

#!perl -w use strict; use warnings; use Win32::GUI 1.06 qw(CW_USEDEFAULT); use Win32::GUI::AxWindow; # Define the application menu my @menu_defn = ( "File" => "File", ">OpenPDf" => { -name => "OpenPDF", -onClick => \&OpenPDF}, ">Exit" => { -name => "Exit", -onClick => sub{-1}, }, ); my $menu = Win32::GUI::Menu->new(@menu_defn); #Define the application window my $mw = Win32::GUI::Window->new( -title => "Open PDF File", -size => [400,400], -left => CW_USEDEFAULT, -menu => $menu, -onResize => \&resize, -onTerminate => \&QuitFile, ); # Add a Acrobat AxtiveX control my $PDFControl = new Win32::GUI::AxWindow ( -parent => $mw, -name => "PDFControl", -control => "AcroPDF.PDF.1", -pos => [0, 0], -size => [400, 400], ); #Show application window $mw->Show(); #Enter event loop Win32::GUI::Dialog(); #Hide windows on exit $mw->Hide(); undef $mw; exit(0); #Open standard windows file open dialog box sub OpenPDF { my ( @file, $file ); my ( @parms ); push @parms, -filter => [ 'PDF - Adobe Acrobat File', '*.pdf', ], -directory => "c:\\", -title => 'Select a PDF file'; @file = Win32::GUI::GetOpenFileName ( @parms ); # print "PDF File: $file[ 0 ]\n"; # Call Acorbat LoadFile Method $PDFControl->CallMethod("LoadFile", $file[ 0 ]); return 0; } #resize to fit user input sub resize { my ($self) = @_; my ($width, $height) = ($self->GetClientRect())[2..3]; $self->PDFControl->Resize($width+1, $height+1) if exists $self->{PDF +Control}; } #Exit the application sub QuitFile { my $self = shift; #Set the Acrobat control to nothing $PDFControl->CallMethod("LoadFile", ""); #This line is needed to keep the PERL interperter from crashing $PDFControl->Release(); return -1; }


Comment on Re: calling AcroPDF.dll from perl
Download Code
Re^2: calling AcroPDF.dll from perl
by Anonymous Monk on Jul 05, 2008 at 08:36 UTC
    thank you very much "rpnoble419" , your code have worked well on my machine.
    i have searched hard on the win32 gui forums and other forums with no success
    i am sure this is the first time someone have published a complete code to display a pdf file inside a win32 gui window
    hope many people will benefit from it
    best regards
Re^2: calling AcroPDF.dll from perl
by Anonymous Monk on Sep 08, 2011 at 13:10 UTC

    Very Thanks for provide Perl source code to Display PDF Files in Win32 GUI

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2014-07-13 02:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (245 votes), past polls