Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Retrieve the PDF file description

by marto (Chancellor)
on Apr 29, 2006 at 11:13 UTC ( #546483=note: print w/ replies, xml ) Need Help??


in reply to Retrieve the PDF file description

Hi Punitha,

I tested this code firstly with a PDF file I knew had the information you are looking for, and your script ran properly, printing the expected results. Then I created a document using Open Office Writer, exported it to PDF (In the 'PDF Options' tab I unchecked the 'Tagged PDF' and 'Export Notes' options) and experienced the errors you mention.

Use of uninitialized value in concatenation (.) or string at pdf.pl li +ne 9. Use of uninitialized value in concatenation (.) or string at pdf.pl li +ne 9. 1.4

Then I opened the PDF and displayed the 'Document Properties', only the PDF version and Producer tags have values, hence the 1.4 printing out. I think then that you can assume your problem occurs when these values are not populated either in the source document before conversion, or later in Acrobat writer.
If you want to catch these errors take a look at this basic example:
#!/usr/bin/perl use strict; use warnings; use PDF; my $pdf = PDF->new("003.pdf"); my $version = $pdf->Version; my $title = $pdf->GetInfo("Title"); my $author = $pdf->GetInfo("Author"); if ($version){ print "\nVersion: $version"; }else{ print "\nVersion: Undefined"; } if ($title){ print "\nTitle: $title"; }else{ print "\nTitle: Undefined"; } if ($author){ print "\nAuthor: $author\n"; }else{ print "\nAuthor: Undefined\n"; }


Hope this helps.

Martin


Comment on Re: Retrieve the PDF file description
Select or Download Code
Re^2: Retrieve the PDF file description
by Punitha (Priest) on Apr 29, 2006 at 12:11 UTC

    Thank you for your comment.

    But in my PDF file all the Description fields (Title, Author,Description etc.) has value. But the PDF Producer is Acrobat Distiller 7.0 not the Acrobat writer.

    I am not sure whether thats the problem. And also i want to retrieve the page size value, for this i added these lines and tried

    my ($startx,$starty, $endx,$endy) = $pdf->PageSize (1) ; print "$startx\t$starty\t$endx\t$endy\n";

    These lines also not working for the same PDF files.But for some PDF file it prints the value as

    0 0 612 792

    But the page size value in the description is

    8.50 x 11.00 in

    I want the same value as output (in inches). Can anyone comment me in this and whether i am going in right direction or show some other way

    Thank you once again and in advance

    Punitha

      Punitha,

      Firstly, I am not fully understanding what you are trying to say. Have you looked at your end result PDF in acrobat reader and checked the properties to see if these fields are populated?

      Secondly, the coded you added to find out the sizes is working for you. You need to divide the sizes by 72 (72 points = 1 inch) to convert the value to inches.
      So 612 / 72 = 8.5 and 792 / 72 = 11.

      Hope this helps.

      Martin
Reaped: Re^2: Retrieve the PDF file description
by NodeReaper (Curate) on Jan 17, 2011 at 04:00 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (17)
As of 2014-07-14 17:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (269 votes), past polls