Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

How to export all images from pdf via perl?

by prabudass (Novice)
on Oct 29, 2008 at 09:06 UTC ( [id://720178]=perlquestion: print w/replies, xml ) Need Help??

prabudass has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I need to export all images from pdf file through perl. Could you please help me, how can i export all images from pdf file and which perl module is more effective for this automation. Kindly advice me with any samples.

OS : Windows
Acrobat : 8.0

Thanks in Advance,
Prabudass
  • Comment on How to export all images from pdf via perl?

Replies are listed 'Best First'.
Re: How to export all images from pdf via perl?
by marto (Cardinal) on Oct 29, 2008 at 10:01 UTC

    The CAM::PDF module would be ideal for this, it even comes with a couple of utility scripts to get you started:

  • extractallimages.pl: Save copies of all PDF images to a directory.
  • extractjpgs.pl: Save copies of all PDF JPG images to a directory.
  • Also, I am sure this question has been asked a few times before, did you super search?

    Hope this helps

    Martin

      Thanks for your response. Using "listimages.pl -v main.pdf" i got the following image details.
      "Image 1 page 1, (w,h)=(673,944), ref /Im1 = object 27, length 378633"
      But i don't know the command for to extract images from pdf using CAM::PDF. I used the following command.
      "extractallimages.pl -O main.pdf "D:\OUTPUT""
      Could you please advice me the correct format for to extract image from main.pdf.

        From the documentation I previously mentioned, the -O option only extracts images based on their index number within the PDF file, for example:

        ./extractallimages.pl -O 1 main.pdf /tmp

        will save only the first image to directory /tmp.

        Read the documentation again, it contains all of the information you need. Since you asked how to extract all of the images within a PDF, you don't need to specify the -O option.

        Update: Please pay attention to the part of the documentation which explains that the ImageMagick 'convert' program is a prerequisite.

        Hope this helps

        Martin

Re: How to export all images from pdf via perl?
by almut (Canon) on Oct 29, 2008 at 09:23 UTC

    Personally, I'd try pdfimages (part of the xpdf package). It's not Perl and not guaranteed to work with any type of PDF, but it could be the easy way out...

      Thanks for your response. I tried through xpdf. But some pdf not supported. Could you please tell me some other way. Any third party tool(free) available for this automation.

      Thanks,
      Prabudass

        I personally believe that your repeated requests across the whole thread is getting really annoying, and what's worse, its being so poorly worded e.g. with questions missing the question mark, denotes lack of respect on your part towards those whom you're asking to help you. Just as does the fact that people has been giving you actual suggestions along with proper references into the respective documentations, complete of hints, too; but you seem to refuse to do that minimal amount of effort that would allow you to solve your own problem, just as if you were too much in a hurry. You know, impatience is a virtue! But if it's not complemented by those other two virtues called lazyness and hubris respectively, you may end up doing more work than would have been necessary, with this "work" consisting of these harassing posts to the Monastery which incidentally will give you a bad name in this community...

        All this being said, funnily enough I just posted a few hours ago a tiny little and naive program that's supposed to extract jpeg images out of... anything, provided that within "anything" they retain their "jpeg-ness" which IME is generally the case. Unless those who created "anything" intended to prevent such possibilty, that is...

        --
        If you can't understand the incipit, then please check the IPB Campaign.
Re: How to export all images from pdf via perl?
by leocharre (Priest) on Oct 30, 2008 at 15:50 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-25 10:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found