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

I have made a perl script to read the text into a PDF, it doesn't run.
$pdf = CAM::PDF->new($file_name); $pageone_tree = $pdf->getPageContentTree(4); print CAM::PDF::PageText->render($pageone_tree);
What's wrong ? Could you help me ? If you need the PDF to test it I can send it to you. Tks.

Replies are listed 'Best First'.
Re: Reading a PDF content
by marto (Cardinal) on May 03, 2012 at 13:01 UTC

    Welcome! If it "doesn't run" does it throw an error? Try:

    #!/usr/bin/perl use strict; use warnings; use CAM::PDF; my $file_name="test.pdf"; my $pdf = CAM::PDF->new($file_name); my $pageone_tree = $pdf->getPageContentTree(1); # replaced 4 with 1 fo +r testing $pageone_tree->render("CAM::PDF::Renderer::Dump");

    Note the last line, it's directly taken from the CAM::PDF::Renderer::Dump documentation. This prints the coordinates of each node of a page layout, your post suggests you want to read the content, investigate the other methods this module offers such as getPageContent. See also PerlMonks for the Absolute Beginner.

    Update: removed typo from last sentence.

    A reply falls below the community's threshold of quality. You may see it by logging in.