Click to See Complete Forum and Search --> : How to convert PDF file to text file in perl???


daisysamuel
03-06-2009, 05:41 AM
Hi somebody help me how to convert PDF file to text file. It ll be gr8 help for me. I tried using CAM::PDF, PDF::Parse but output is not as expected, Please help me out. Thanks in advance.

DaisySamuel.

Phill Pafford
03-11-2009, 03:39 PM
Seen this code but have not tested


#!/usr/bin/perl

use strict;
use warnings;

use CAM::PDF;
use CAM::PDF::PageText;

my $filename = shift || die "Supply pdf on command line\n";

my $pdf = CAM::PDF->new($filename);

print text_from_page(1);

sub text_from_page {
my $pg_num = shift;

return
CAM::PDF::PageText->render($pdf->getPageContentTree($pg_num));
}