- 論壇徽章:
- 0
|
本帖最后由 zhlong8 于 2011-07-20 23:10 編輯
想用手機(jī)看非pdf的文檔有好辦法了,使用perl模塊CAM::PDF 把pdf文件轉(zhuǎn)化為txt格式,O(∩_∩)O哈哈~,推薦,已使用過,請看如下代碼:
#!/usr/bin/perl -w
use CAM::PDF;
use CAM::PDF::PageText;
$infile = $ARGV[0];
#print "the input PDF file is $infile\n";
$outfile = $ARGV[1] || 'test.txt;
#print "the output TXT file is $outfile\n";
open (OUTFILE, ">>$outfile") or die("cannot open file : $!");
$pdf = CAM::PDF->new($infile) || die "$CAM::PDF::errstr\n";
$num = $pdf->numPages();
foreach $p (1..$num)
{
#print "this is in page $p\n";
$str = $pdf->getPageText($p);
CAM::PDF->asciify(\$str);
print $str;
print OUTFILE "$str\n"; # write to file
}
close (OUTFILE); |
|