[Tfug] Scripting PDF's

Bexley Hall bexley401 at yahoo.com
Tue Jul 9 14:14:31 MST 2013


Hi Glen,

On 7/9/2013 1:59 PM, Glen Pfeiffer wrote:
> 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.

Argh!  Sorry, I didn't even think of that way of interpreting
my question.  <frown>

What I want to do is create a PDF that is a "live" document;
one that a *user* (reader) can interact with.

E.g., the typical case is creating a "form" that the user fills
in (when "viewing" the PDF) and having some "code" execute that
takes the user-provided values and "displays" other, related
data.

For instance, filling in an order form and having the PDF compute
the totals for each line item (QTY * piece price = item total).

In my case, I want to create interactive *graphics*.  E.g.,
the user "does something" and the imagery displayed changes
based on some coded algorithm ("script").

> 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.

<grin>  Agreed.  I use DTP tools for much of that.  The scripts,
of necessity, I would have to write by hand (i.e., same as writing
any other "program")

> 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 use FrameMaker for most of my DTP needs.  It lets me concentrate
on what I want to write/say and not worry about the trivialites
of making things fit, look pretty, etc.  (though the equation
editor is too clever for its own good  :< )

> 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.

Actually, creating an HTML version of the "page" *might* work -- if
the tool knows how to embed any javascript *in* the web page into
the resulting PDF!  (though my general level of cynicism suggests
this will NOT be the case -- esp with FOSS tools!)

Thanks, I'll take a look at it and see if it expressly makes
any of these claims!

Keep cool -- only 364 more days of Summer!

--don





More information about the tfug mailing list