Unicode in PDFs in Catalyst

If you have a Catalyst app which is generating PDFs with Catalyst::View::PDF::Reuse, and you want to use Unicode characters in the PDFs, you’ll need two things:

  • you’ll have to specify a TrueType font explicitly to get characters out of the Latin-1 range. The documentation for PDF::Reuse has instructions on how to do this.
  • Catalyst::View::PDF::Reuse uses Template::Toolkit, which will turn wide characters into rubbish unless it knows what encoding you meant. You can specify this by passing in an ENCODING parameter when you configure View::PDF::Reuse in your app module:
    'View::PDF::Reuse' => {
        INCLUDE_PATH => __PACKAGE__->path_to('root', 'site', 'pdf'),
        ENCODING => 'utf8'
    }
    

    Template::Toolkit’s manuals have other ways to set the encoding.

Follow

Get every new post delivered to your Inbox.