[Tfug] Scripting PDF's

Glen Pfeiffer glen at thepfeiffers.net
Tue Jul 9 13:59:53 MST 2013


On 09 Jul 2013, Bexley Hall wrote:
> Anyone have any first-hand experience scripting PDF's?
> Search engines don't seem to offer up much by way of
> assistance (besides the obvious "scripting of forms").

By "scripting PDF's", do you mean generating a PDF 
programmatically? If so, then yes. And even though my experience 
is on a windows platform, I still have some information that 
might help.

First, I highly recommend that you do not create PDF's by writing 
the PDF format yourself. The PDF format is very large and 
cumbersome to work with.

Secondly, I would avoid absolute positioning if possible. A PDF 
is a fixed layout, and therefore changes to your content/layout 
or the desire to support different print sizes requires a lot of 
work.

I found it much easier to generate the content in different 
format and then convert it to PDF. I have experience doing that 
with HTML and RTF. Of the two, I found that HTML was the easiest. 
I'm sure there are plenty of tools that will convert other 
formats as well.

I have used proprietary tools on Windows, and have used 
OpenOffice Portable as well. OOP was not created specifically for 
this task, albeit slowly while using a lot of memory.

A quick search of the Debian repositories turns up 'wkhtmltopdf' 
which is a command line utility that will convert html to pdf 
using WebKit.

Hope that helps.

-- 
Glen





More information about the tfug mailing list