Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

use PDF; woes

by zeltus (Beadle)
on Nov 29, 2013 at 17:10 UTC ( #1064991=perlquestion: print w/replies, xml ) Need Help??
zeltus has asked for the wisdom of the Perl Monks concerning the following question:


I am using Strawberry perl on a Win7 box.

Altho' I have the PDF module installed without error (and PDF::Parse), I can't get the following to run

#!/perl/bin/perl -w use strict; use PDF; my $file = shift; my $pdf=PDF->new($file); my $bool = $pdf->IscryptPDF; my $result = "NO :-(\n"; if ($bool) { $result = "yes!\n"; } print $result;

The docm. for these modules is not overly clear about what is required... at least, it isn't clear to me. So I don't know if I am doing something wrong. "Probably" is usually the right answer!

All I am trying to do is write a small test proggy that'll check if a given PDF is password protected or not.

Any suggestions/help/advice gratefully received.



Replies are listed 'Best First'.
Re: use PDF; woes
by Khen1950fx (Canon) on Nov 29, 2013 at 23:17 UTC
    I ran it like this:
    #!/usr/bin/perl -l use strict; use warnings; use PDF; my $file = '/root/abitl.pdf'; my $pdf = PDF->new; $pdf->TargetFile($file); $pdf->LoadPageInfo; if ( $pdf->IscryptPDF ) { print "File is password-protected"; } else { print "File is not password-protected"; }
    Note: You did use the IscryptPDF method correctly. The documentation for PDF incorrectly lists it as IscryptedPDF.
Re: use PDF; woes
by ww (Archbishop) on Nov 30, 2013 at 00:19 UTC
    Kehn1950fx appears to have hit this one on the head... for some Portable Document Files.......

    However, as has been said about .pdf conversion/testing/whatever -- in many threads here in the Monastery and elsewhere -- the standard for such docs has changed many times; many creators ignore or bork their implementation of the standards; and what you get may not match the output using a different source.

    You may wish to check CAM::PDF and especially if your desire to go further -- for example, to text extraction... but as the author, Chris Dolan has noted (in paraphrase) extracting information from some .pdf formats is a real pain.

Re: use PDF; woes
by monkey_boy (Priest) on Nov 29, 2013 at 18:19 UTC

    PDF seems old, unmaintained and broken, try PDF::API2

    This is not a Signature...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1064991]
Approved by monkey_boy
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2018-04-26 06:18 GMT
Find Nodes?
    Voting Booth?