ok1fou has asked for the wisdom of the Perl Monks concerning the following question:

I am afraid this question should have rather been addressed to PDF experts, but some of the honorable Perl Monks might know this as well...

When creating a PDF file, I need to display certain CEE characters, such as Ccaron, rcaron etc., which are not part of the standard PDF encodings.

Now, I am looking for a hint/pointer to answer one of the following problems:

  1. PDF files can contain embedded fonts. I parsed one such document in Czech, containing three TrueType fonts. I looked into the data structure created by PDF but cannot see where the font actually is. One day, if I find the hidden font, does anyone know how to re-embed such font in a newly created document?
  2. If I happen to detect CEE capable fonts in the latest distribution of Acrobat Reader, how can I define my favorite CEE font in the created document? And where could I find the respective encoding table for translation from, let's say Windows-cp1250 to that used in PDF?
  3. ... or would it help if I passed a Unicode string to PDF::Create::string ?
  4. ... or is perhaps the easiest way to generate a PostScript (which I understand better than PDF) and push it through some sort of PS2PDF pipe or filter?
BTW, my final goal is to generate something on-line from Apache/mod_perl, so there may be an entirely different solution after all.

I would be very grateful for a hint...

Jindra Vavruska

Replies are listed 'Best First'.
Re: Central/East European characters in PDF
by traveler (Parson) on Oct 02, 2002 at 22:04 UTC
    I would be very grateful for a hint...
    That is the best I can offer. PDF::Create lets you choose a font. The docs imply that the font will be "included" if it is used. That implies to me that it will do what you want.

    I have only used PDF::API2. It has a good method for accessing fonts. The (mostly untested) code below should get you started:

    use PDF::API2; $pdf = PDF::API2->new; $font = $pdf->ttfont('/fonts/Univers-Bold.ttf'); # or psfont for PS $string = $font->text("Some string"); # Now place and write the $string $pdf->update; $pdf->saveas("foo.pdf");
    I have used this technique to set, say, a title but not to create from scratch. There are more than a few PDF tools on CPAN and you might get more code from them, particulary PDF::Create.

    HTH, --traveler