[ic] PDF generation in Interchange

Ethan Rowe ethan at endpoint.com
Tue Jul 10 08:15:49 EDT 2007

On the freenode#interchange IRC channel yesterday, there was some 
discussion on the topic of PDF generation, with Stefan Hornburg 
suggesting that it would be good to have as a default feature in the 
standard demo catalog for things like invoices.  Since this particular 
problem has been approached numerous times in various ways, I offered to 
gather information from my coworkers at End Point to get a picture of 
what solutions we've found and the pros/cons of each.

In recent years, we've generated PDFs in the following ways:
* Simple HTML generation within Interchange, then passed through HTMLDoc 
(http://htmldoc.org) for conversion to PDF.
* Use Postscript::BasicTypeSetter to generate Postscript, then pass that 
through Ghostscript to generate PDF as needed.
* Use PDF::API2 within custom Perl modules/routines

The reliance on HTMLDoc for HTML-to-PDF conversion has the benefit of 
simplicity, but it's not particularly rich and effectively only offers 
the level of sophistication of a version-3 browser.  The 
Postscript-based approach provides complete control over fonts, 
positioning, etc., but was done some years before PDF::API2 was 
available; it was a successful approach but doesn't seem likely to be 
the most logical approach now.  PDF::API2 is pretty comprehensive and 
completely met our needs for the uses to which it was put; however, it's 
relatively low level compared to the level most of us are accustomed to 
working at when dealing with presentation/content, so it would hard to 
offer a generic usertag that exposed the full richness of the PDF::API2 

So, our collective suggestion on this topic: use PDF::API2, but perhaps 
plan on making custom usertags per use case or something like that.  It 
may be possible to make a usertag that can handle a number of simple 
tasks for PDF generation, but we'll always need to drop directly to Perl 
in order to get particularly fancy.

- Ethan

Ethan Rowe
End Point Corporation
ethan at endpoint.com

More information about the interchange-users mailing list