Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Documentation of PDF::GetImages is lack of some info concerning the 'optionals'

by programmer.perl (Beadle)
on Feb 09, 2013 at 11:48 UTC ( #1017951=perlquestion: print w/ replies, xml ) Need Help??
programmer.perl has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I'm working with the PDF::GetImages. This module extracts the image(s) that are in PDF Afiles and puts them to current dir. But, I need that the module extracts the images to the path where I want.

I couldn't find the place where I should put the variable $processing_path.
In docs of module (http://search.cpan.org/~leocharre/PDF-GetImages-1.18/lib/PDF/GetImages.pod#pdfimages%28%29 ) written such: "Optional argument, is path to a dir to which to send images extracted.", but I couldn't find where to put this optional argument... there is no such example...
Also the search in perlmonks didn't give results...
I can't find the place where I should put the variable $processing_path.

My code:

#!/usr/bin/perl -w use 5.010; use strict; use warnings; use Cwd qw(); use PDF::GetImages 'pdfimages'; my $path = Cwd::cwd(); my $processing_path = $path.'/newfolder/'; my $images = pdfimages($path.'/file.pdf') or die($PDF::GetImages::errs +tr); scalar @$images or die("no images in $path"); for (@$images){print "$_\n";}

It will be a good if you point where of line 9 to put the $processing_path variable.

And, what is the function of this line scalar @$images or die("no images in $path");?

Thanks,

Enough codes make shapes. (Hamidjon)

Comment on Documentation of PDF::GetImages is lack of some info concerning the 'optionals'
Select or Download Code
Re: Documentation of PDF::GetImages is lack of some info concerning the 'optionals'
by jms53 (Monk) on Feb 09, 2013 at 11:56 UTC
    "Argument is abs path to pdf file on disk. Optional argument, is path to a dir to which to send images extracted. Returns array ref with abs paths to images extracted."

    did you try pdfimages($abs, $opt), where $abs is the variable with the absolute filepath to your pdf file, and $opt the optional destination folder?
    J -

      My last change of code:

      #!/usr/bin/perl -w use 5.010; use strict; use warnings; use Cwd qw(); use PDF::GetImages 'pdfimages'; my $path = Cwd::cwd(); my $abs = $path.'/file.pdf'; # filepath to pdf file my $opt = $path.'/processing/'; # new dir for output my $images = pdfimages($abs, $opt) or die($PDF::GetImages::errstr); scalar @$images or die("no images in $path"); for (@$images){print "$_\n";}

      Output in commandline is:
      "cant resolve /home/auu/Documents/Imag/processing/, should be able to, please notify PDF::GetImages AUTHOR at extractor.pl line 11"

      Enough codes make shapes. (Hamidjon)
        Did you try setting $abs and $opt as absolute paths?

        Also, as for your other question, unless I am mistaken, it creates an array of the images created in $opt ($path). therefore, if empty returns false and dies with the error message "no images in $path".
        J -

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1017951]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2014-08-28 08:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (259 votes), past polls