Re: Viewing a PDF file from a Perl program
by tachyon (Chancellor) on Mar 24, 2003 at 03:12 UTC
|
Acrobat reader comes with an Active X object that lives in PDF.OCX. You can get all the details on the interface here.
There are PDF to everything converters. Google for them. Foolabs has some good PDF related GPL tools
I you have an app that need to view PDF and you want a windowing environment it begs the question what's wrong with a Browser/CGI app - just pop the PDF in a new window. Potentially a lot easier than anything else as all the work has been done for you. Followed by a jpg conversion with creating Active X containers and automating it following up the rear.
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
| [reply] |
Re: Viewing a PDF file from a Perl program
by zengargoyle (Deacon) on Mar 24, 2003 at 03:39 UTC
|
you don't give an OS, under Linux, both of these work.
system "acroread poe.pdf &";
# or (needs error checking)
if (fork) { print "bye$/" }
else {
system acroread => "poe.pdf"
}
| [reply] [d/l] |
|
|
++zengargoyle
IMHO the best (i.e.: more portable) way to do it is fork, since it works on every UNIX-like OS and it is emulated on Win32, and it won't "freeze" your application. Calling system "acroread poe.pdf &"; won't work on non-UNIX systems
Ciao! --bronto
The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
--John M. Dlugosz
| [reply] [d/l] [select] |
|
|
| [reply] |
|
|
|
|
|
|
system start => acrord32 => $pdf_file;
# or
system start => $pdf_file;
neither of which has any hope of running anywhere but Windows.
for cross-platform-ability have a config setting for the reader executable.
# in child after fork (close STD* for good measure)
close STDIN;
close STDOUT;
close STDERR;
system $cfg{PDFViewer}, $pdf_file;
i'm sure there are modules on CPAN that abstract Running a program for multiple OSs.
| [reply] [d/l] [select] |
|
|
| [reply] |
|
|
nope, Proc::Daemon::Init doesn't return to the parent after it is called, so you would still have to fork around it. it does have some nice code for fork-ing and close-ing all open handles so it's good to look at.
| [reply] |
|
|
| [reply] |
Re: Viewing a PDF file from a Perl program
by Thelonius (Priest) on Mar 24, 2003 at 17:05 UTC
|
If you are on Windows and they are using the regulare Acrobat Reader, this will work: system qq(start acrord32 "$pdffile");
. But if they might have full Acrobat instead of the reader, in which case I'm not sure that will work. Or, theoretically, they might have some other reader.
As long as the filename doesn't have spaces, this will open the file in their configured PDF reader: system qq(start $pdffile);
. Unfortunately there doesn't seem to be a way to do that if the file (or path name) contains spaces (quoting does not help). You could translate it to a DOS short (8.3) name, though. | [reply] [d/l] [select] |
Re: Viewing a PDF file from a Perl program
by aquarium (Curate) on Mar 25, 2003 at 00:44 UTC
|
use fork to run "name_of_pdf.pdf" in background, and default viewer is activated. not sure if this is very portable, but is more so that running "acroread.exe" which is not same on other platforms. if they don't have a pdf viewer it pops up the "open with which program" dialog.
chris | [reply] |