PDF-API2/Encoding

From OpenStreetMap Wiki
Jump to: navigation, search
#!/usr/bin/perl
use strict;
use Encode;
use PDF::API2;
use constant mm => 25.4/72;

my $PDF = PDF::API2->new();
my $Page = $PDF->page;
my $TextHandler = $Page->text;

$TextHandler->font($PDF->corefont('Helvetica'), 8/mm );
$TextHandler->fillcolor("black");
$TextHandler->translate(20/mm, 40/mm);

$TextHandler->text(decode("utf8", "Tromsø with an \"ø\""));

$PDF->saveas("test.pdf");