Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

use PDF; woes

by zeltus (Sexton)
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:

Hi

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.

Thanks

Bill

Comment on use PDF; woes
Download Code
Re: use PDF; woes
by monkey_boy (Curate) on Nov 29, 2013 at 18:19 UTC

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





    This is not a Signature...
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 (Bishop) 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 http://search.cpan.org/~cdolan/CAM-PDF-1.60/bin/getpdftext.pl if your desire to go further -- for example, to text extraction... but as the author, Chris Dolan http://search.cpan.org/~cdolan/ has noted (in paraphrase) extracting information from some .pdf formats is a real pain.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2014-09-17 22:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (100 votes), past polls