in reply to PDF::API2 / unicode characters
Hello Andrea,
I am fairly a newb at using PDF::API2 -- I took a crack at trying to figure it out a few weeks ago, but decided it was more trouble than it was worth for what I needed -- but I saw your lonely post, and felt inclined to offer what help I could, being a lover of Unicode and Greek characters especially.
To your questions:
-- According to the PDF::API2::Resource::Font::CoreFont manpage, the core fonts they list (Times Roman, Verdana, etc.) *ought* to support UTF8, and the standard Greek characters.
-- According to the PDF::API2 manpage, you should be able to import standard TrueType fonts.
-- PDF::API seems to be the best interface for PDF that I've found. But I am, as I said, a newb.
I just followed what appeared to be the procedure for assigning a Unicode font with PDF/API2/Resource/UniFont.pm. But it doesn't seem to be working. I can why you are frustrated! I need to get to class, but my interest is now piqued, and I'll try to work more on this later today. For what it's worth, and for anyone else who comes along to help, here's what I'm working with:
All it puts on the page, presently, is the ASCII, non-Unicode exclamation point.#/usr/bin/perl use strict; use warnings 'all'; use PDF::API2; use PDF::API2::Resource::UniFont my $test = 'test.pdf'; # Create a blank PDF file my $pdf = PDF::API2->new(); # Add a blank page my $page = $pdf->page(); # Add a built-in font to the PDF my $font = $pdf->corefont('Times-Roman'); # Register a Unicode font my $ufont = PDF::API2::Resource::UniFont->new($pdf, {font => $font}); # Create a Unicode string (Greek) my @uhex = qw(03a7 03b1 03b9 03c1 03b5 0021); my @uchars = map (hex, @uhex); my $ustring = pack("U*", @uchars); # Add some text to the page my $text = $page->text(); $text->font($ufont, 20); $text->translate(80, 710); $text->text($ustring); # Save the PDF $pdf->saveas('test.pdf');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: PDF::API2 / unicode characters
by Eliya (Vicar) on Feb 17, 2012 at 19:05 UTC | |
by LonelyPilgrim (Beadle) on Feb 17, 2012 at 20:11 UTC |