aloss has asked for the wisdom of the Perl Monks concerning the following question:
I'm a Perl newbie and have an issue with the PDF::API2. I need to create some formatted text and so I want to use this library to create a PDF document. Being a German, I need to deal with some special characters ("Umlauts"). I tried a while around but whatever I tried, all gives the same result, see below.
The essential part of the code I use:
#!/usr/local/ActivePerl-5.16/bin/perl -w use strict; use warnings; use PDF::API2; # Prepare PDF my $pdf = PDF::API2->new( -file => "Test.pdf"); my $page = $pdf->page; $page->mediabox( 'A4' ); # Set the font - but none of these do any difference: my $font = $pdf->corefont('Helvetica', -encoding => "utf-8"); #my $font = $pdf->corefont('Helvetica', -encoding => "UTF8"); #my $font = $pdf->corefont('Helvetica', -encoding => "UTF-8"); #my $font = $pdf->corefont('Helvetica', -encoding => "utf8"); #my $font = $pdf->corefont('Verdana'); #my $font = $pdf->ttfont('Arial.ttf'); # This even gives me an error d +uring compilation # Set up some text my $text = $page->text(); $text->font($font, 20); $text->translate(100, 700); $text->text("Umlaut: Ä ä Ö ö Ü ü ß"); $pdf->save; $pdf->end();
The output in the PDF looks like:
Umlaut: € Š ... š † Ÿ §The system I use is a mac OS X 10.9.5 and ActivePerl 5.16, the PDF::API2 lib is version 2.023.
Any help appreciated!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: PDF::API2 with special characters
by Anonymous Monk on Oct 06, 2014 at 12:39 UTC | |
by aloss (Initiate) on Oct 06, 2014 at 12:55 UTC | |
by Anonymous Monk on Oct 06, 2014 at 13:10 UTC | |
by aloss (Initiate) on Oct 06, 2014 at 13:58 UTC |