[ic] PDF generated invoices etc.
peter at pajamian.dhs.org
Thu Jun 11 20:10:42 UTC 2009
On 06/11/2009 12:58 PM, David Christensen wrote:
>> I am wondering which applications would work best for generating
>> complex pdf invoices, preferably on the fly.
> As an addendum, another approach we've taken has been to pre-generate
> a PDF with an editable form embedded, and then process through a
> toolchain which feeds in the data to the appropriate fields and
> flatten the resulting form into regular text fields in the PDF
> document. (I believe we used PDF::FDF::Simple and pdftk to do the
> respective parts.)
> If the changing fields in the document are fixed, this can be a good
> compromise, as the source PDF can be created by any document system
> that can generate it; additionally the layout/formatting information
> for each of the text fields can be set, making it easy to separate
> layout from content. However, this approach will fall down when the
> number/types of fields on the page are variable (such as an invoice
> with a varying number of sub-items), so this may or may not be viable
> for your needs. You will also need a program that can create the
> editable form in the PDF itself. I just ended up using Acrobat, not
> sure what's out there in the OSS arena.
I took a similar approach for a client once but instead of starting with
a PDF we started with a .ps file. Since those are directly editable
text I was able to replace sections of the postscript with replaceable
markers and hold the .ps template in memory. Then writing a pdf is as
easy as replacing the appropriate text, writing the file to disk, and
then processing the output file with ghostscript's ps2pdf utility. This
solution turned out to be very fast as only one conversion had to be
done (and ps2pdf is a very fast conversion), so it was ideal for us.
Downsides are all of the above plus issues with character sets being
mapped in different ways for potentially different files to the point
where I had to create a map and search and replace characters on the
input side. This also will clash with UTF8 a bit and cause issues (none
that can't be resolved). Different ps generators tend to generate ps
output that looks vastly different and sometimes you cannot find the
source text in them at all without a deep understanding of ps, also they
tend to generate files of orders of magnitude different sizes. For us
the best solution was to try different generators for the ps until we
found some output that we could work with that wasn't overly bloated.
This may include trying drivers for different postscript printers and
capturing the output to a file.
More information about the interchange-users