Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Extract text from PDF (normal text)

by xbmy (Friar)
on Jun 09, 2010 at 21:33 UTC ( #843932=note: print w/replies, xml ) Need Help??


in reply to Extract text from PDF (normal text)

Try this, it works well for me, enjoy!

use warnings; use CAM::PDF; use CAM::PDF::PageText; my $infile = "?.pdf"; #the pdf file you want to extract my $outfile = "out.txt"; open (OUTFILE, ">>out.txt") or die("cannot open file : $!"); my $pdf = CAM::PDF->new($infile) || die "$CAM::PDF::errstr\n"; my $num = $pdf->numPages(); foreach my $p (1..$num) # p present for the page number { my $str = $pdf->getPageText($p); CAM::PDF->asciify(\$str); print OUTFILE "$str\n"; # write to file } close (OUTFILE);

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2020-12-04 05:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (58 votes). Check out past polls.

    Notices?