I've a nice simple piece of code that pulls some information out of a pdf file:
#!/path/bin/perl
use Data::Dumper;
use PDF::API2;
use Encode;
my $dir = '/tmp/';
my $file = $dir.'test.pdf';
my $pdf = PDF::API2->open($file);
my %info = $pdf->info;
print Dumper(%info);
foreach my $key (sort keys %info) {
print "$key ->";
print decode("utf8", $info{$key});
print "\n";
}
Everything is installed, and the code runs.
Data Dumper prints out:
$VAR1 = 'CreationDate';
$VAR2 = 'D:20060817180621+01\'00\'';
$VAR3 = 'Producer';
$VAR4 = "\x{4f00}\x{7000}\x{6500}\x{6e00}\x{4f00}\x{6600}\x{6600}\x{69
+00}\x{6300}\x{6500}\x{2e00}\x{6f00}\x{7200}\x{6700}\x{2000}\x{3200}\x
+{2e00}\x{3000}";
$VAR5 = 'Creator';
$VAR6 = "\x{5700}\x{7200}\x{6900}\x{7400}\x{6500}\x{7200}";
$VAR7 = 'Author';
$VAR8 = "\x{4200}\x{6f00}\x{6200}\x{2000}\x{5700}\x{6500}\x{6200}\x{73
+00}\x{7400}\x{6500}\x{7200}";
$VAR9 = 'Title';
$VAR10 = "\x{4300}\x{4f00}\x{4d00}\x{5000}\x{4500}\x{5400}\x{4900}\x{5
+400}\x{4900}\x{5600}\x{4500}\x{2000}\x{5300}\x{4100}\x{4600}\x{4100}\
+x{5200}\x{4900}";
but
decode barfs with "Cannot decode string with wide characters"
(The pdf file was created by exporting an OpenOffice file {.doc format on disk} to pdf.)
I have tested this under Solaris and Fedora Core 5.
Solaris is running with Perl 5.8.3 and Encode 1.99
FC5 is running Perl 5.8.8 and and Encode 2.09 (downgraded from Encode 2.18)
Has anyone got a setup that will handle the UTF-8 (as present in pdfs...
all pdfs..?)
-- Ian Stuart
A man depriving some poor village, somewhere, of a first-class idiot.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.