PDF creation in Perl

We in our project use HTMLDOC for PDF generation in Cent OS 5. We pass html files with some template info and run the HTMLDOC command line from perl program. This after multiple run gives me the correct PDF book with proper table of content, Index etc. The basic issue now I face with this engine is that it doesn’t support the new pdf features like PDF/A, CSS etc. and I don’t think HTMLDOC is very much in developmental mode. I want to introduce new engine to my application and tried some of the available options:

Prince:

This looks excellent and supports almost all modern PDF features. The input files can be xml, html etc and can be run as a batch process. But it has a licence fee.

PDF Reactor:

Looks fine also have the Perl wrapper for manipulating PDF but can’t run as a batch process for making single PDF from many HTML files. This can be done through Perl program by making a loop to documents which in result can produce combine PDF. Like prince it also has a licence fee.

WKHTMLTOPDF:

First thing I like about this engine is that this is a open source engine, beside being free it still supports CSS. It can be run as a batch process through Perl like HTMLDOC, prince. At first look it looks promising to me so I have decided to invest some time on it. The engine is QT and webkit based and in development phase.

I was wondering if I am missing something. Is there other engines someone has tried which go well with Perl?

Best regards,

  • http://www.perl.it/workshop/ Michele Beltrame

    Hello!

    I’ve been using wkhtmltopdf for a while, and what I can say is that it is far superior to htmldoc (which I had been using previosly). It’s especially handy that the page you see in Chromium or other webkit browser is actually what you get in the PDF.

    I also wrote a simple Catalyst view for it: Catalyst::View::Wkthmltopdf.

    Cheers,
    Michele.

    • http://ppant.blogspot.com ppant

      Thanks Mitchele. I will definitely try Catalyst wrappers in my another projects. BTW which version of WKHTMLTOPDF you are using?

      One of the issue which I face earlier was with the size of the pdf created with WKHTMLTOPDF was much higher compared to others but this was solved after installing TTF fonts in Linux box. As I have multiple files and I want to make a book out of it with proper cover, TOC, index. I think –book and –toc option solves all these issue but for index page I haven’t found anything yet. Just checking with you if you have some clue to generate index page.

  • ico

    Hi,

    Currently I’m using Apache FOP. It’s the best I found on the net, can do everything I wanted to. I started with XSLT but then I discovered FO format and use that now. I create uniform FO files (XML file actually) and call fop to create really nice PDFs.

    This way I learned to live with a piece of Java in my Perl application :)

    • http://ppant.blogspot.com ppant

      you must be using inline::Java just checking if this can run as a batch command? I mean passing multiple files at one go

      • ico

        Well not really. I know nothing about Java so I just prepare correct command line and call external process with IPC::Open3. It takes prepared FO and dumps PDF which is then downloaded to browser. Quite simple (stupid? easy to develop :) ) setup. I have the luxury of being the only developer & server administrator.

  • Drago

    I have had success using html2ps then ps2pdf to produce nice-looking/working pdf files.

    I haven’t had to use any of the newer features though.

    • http://ppant.blogspot.com ppant

      Will look into these options. Thanks for comment.