I had trouble getting the example codes to work, but
PDF::API2 / unicode characters has some pertinent info. Just from some hacking at a PDF::API2 example, this code writes out and is searchable using xpdf. I don't have acroread going because they don't have a 64 bit version yet for linux. If you download this code, open it in a unicode aware editor and resave it with Encoding set to Unicode UTF-8, it will come in from Perlmonks as Western ISO-8859-1. The
Geany Editor works real nice for this kind of stuff.
#!/usr/bin/perl
use warnings;
use strict;
use PDF::API2;
my $pdf=PDF::API2->new;
my $f1=$pdf->corefont('Helvetica',1);
foreach my $fn (qw(
arial arialbold arialitalic arialbolditalic
)) {
foreach my $en (qw( latin1 macroman )) {
my $font=$pdf->corefont($fn,-encode => $en);
print STDERR qq($fn - $en ---\n);
my $page = $pdf->page;
my $txt=$page->text;
$txt->translate(100,750);
$txt->font($font,50);
$txt->lead(50);
$txt->text('Hello World !');
$txt->cr;
$txt->font($font,20);
$txt->text("german spec.chars: ae='ä' AE='Ä' oe='ö' ");
$txt->cr;
$txt->text("german spec.chars: OE='Ö' ue='ü' UE='Ü' ss='ß' ");
$txt->cr;
$txt->font($f1,20);
$txt->text("This is font: $fn ($en)");
$txt->font($font,20);
foreach my $x (0..15) {
foreach my $y (0..15) {
$txt->translate(50+(33*$x),50+(33*$y));
$txt->text(chr($y*16+$x));
}
}
}
}
$pdf->saveas("$0.pdf");
$pdf->end();
exit;
__END__
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.