Forum Moderators: coopster & phranque

Message Too Old, No Replies

errors using PDF::Parse

Can't call method "TargetFile" on an undefined value

         

crevier

9:05 pm on Sep 26, 2005 (gmt 0)

10+ Year Member



I'm writing a CGI script that will provide a list of links to available PDF documents in a directory, and I want to use some of the information embedded in the PDF document (title, author, subject, etc) in the listing.

I'm using PDF::Parse [search.cpan.org] for the first time and it's just not working. I just downloaded it and installed it today (Linux 2.6, Apache 1.3, Perl 5.8.0). I've simplified my CGI script to just the specific code that fails, and I'm now running it as a shell script for troubleshooting:


#!/usr/bin/perl
use PDF::Parse;

$file = '/tmp/test.pdf';
$size = (-s $file);
print "The size of $file is $size bytes.\n";
$pdf->TargetFile($file);

exit(0);

The error message is "Can't call method "TargetFile" on an undefined value". I know that the $file value is defined properly because the size prints properly. I've even tried hard-coding the file path, same error though. If I turn on warnings (via "-w"), I get the following errors:


PDF::Core::PDFGetPrimitive() called too early to check prototype at /usr/lib/perl5/site_perl/5.8.0/PDF/Core.pm line 288.
PDF::Core::PDFGetPrimitive() called too early to check prototype at /usr/lib/perl5/site_perl/5.8.0/PDF/Core.pm line 294.
Name "main::pdfinfo" used only once: possible typo at ./test.pl line 9.

So apparently there's some problem with the module. The documentation at CPAN provides a web link at geocities for reference, but that page no longer exists (surprise). A Google search didn't yield much. Has anyone used this module? Or is there a more reliable module to use for parsing PDF files?

moltar

9:58 pm on Sep 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There seems to be some kind of mistake. $pdf is not defined anywhere previosly, thus it's not a package handle. I checked the documentation, and I know that's what they say, but it's wrong.

Usually you need to call method new(), but they don't even have it.

KevinADC

10:03 pm on Sep 26, 2005 (gmt 0)

10+ Year Member



is the PDF::Core module also installed? You can search CPAN ( [search.cpan.org...] ) for PDF modules but I have no recommendations, I've never used any of them myself.

moltar

10:25 pm on Sep 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Upon closer inspection I realised that the module is broken. Don't use it. It's full of errors and it's not supported anymore. Last version was in 2000.

crevier

12:46 am on Sep 27, 2005 (gmt 0)

10+ Year Member



The PDF::Core module is indeed installed (did that today too when I installed the PDF::Parse module).

It sure does seem broken. I noticed the old date too when I saw the link to the geocities page which doesn't exist.

So, does anyone have any tips for what I'm trying to do?

KevinADC

4:03 am on Sep 27, 2005 (gmt 0)

10+ Year Member



Read the PDF::Core module documentation, more than likely it will do whatever it is you want. Also search CPAN and read the documentation of the various PDF related modules and see if any seem appropriate for your purposes.

moltar

10:38 am on Sep 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PDF::Core works in conjunction with PDF::Parse. It's by the same authors. Neither of the modules is fully functionaly by itself.

So, does anyone have any tips for what I'm trying to do?

And what exactly are you trying to do?

crevier

1:15 pm on Sep 27, 2005 (gmt 0)

10+ Year Member



And what exactly are you trying to do?

This is from my original post:

I'm writing a CGI script that will provide a list of links to available PDF documents in a directory, and I want to use some of the information embedded in the PDF document (title, author, subject, etc) in the listing.

moltar

3:01 pm on Sep 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I looked around and unfortunately I couldn't find any way to do that. There are tons of modules that can write PDF, but none that can read them. Very strange!

What you can do is try to fix the current module and make it work. Write to the creators and ask their help. If you fix the module, make sure you submit your changes back to CPAN.

crevier

3:40 pm on Sep 27, 2005 (gmt 0)

10+ Year Member



Thanks much folks. I appreciate your time and efforts.

KevinADC

8:12 pm on Sep 27, 2005 (gmt 0)

10+ Year Member




PDF::Core works in conjunction with PDF::Parse. It's by the same authors. Neither of the modules is fully functionaly by itself.

ahh, I didn't take the time to look. I assumed PDF::Parse was more like a user friendly interface to PDF::Core. Thanks for the correction.

Maybe try another module by the same author and see if it does work, requires the other two modules though so probably not, but nothing to lose by trying.

[search.cpan.org...]