Help - Search - Members - Calendar
Full Version: Fill PDF Server-Side
Invision Power Services > Community Forums > Community Web Design and Coding
Luke
I've been looking around for a server side application that allows me to fill a pdf's fields, and output it to the user... I've found a few, but the price range is pretty high.

My old method of filling a PDF myself was placing "#Box1#", etc... in each field and replacing it with preg_replace, one at a time... That worked for smaller documents, around 20 fields, but it took to long and required me to cache it... Now im doing a forum with 200 fields, which would take nearly forever to do... And the document itself cant be cached because of its purpose, unlike the other document... To top it off my method doesn’t work for check boxes, and I’m using check boxes.... So now I’m looking for a server side app that does this... Before I tried FDF files (form filler files), but it depends on the clients adobe reader to fill the fields, and it doesn’t work when the PDF is on the web server (has to be on clients machine)....

So far ive found:

FDFMerge - $1k, works for Linux servers. Uses FDF files, which you have to generate.
activePDF Toolkit - I think it does the same thing as FDFMerge, or like the one below, but doesn’t work for Linux servers (windows only) and costs nearly $800-$900
"PDF Form Filling and Flattening Tool" from pdf-tools.com - So far the best. You can specify the fields command line, or provide a "control file" which is a simple field=value ASCII concept. Windows version costs $360 (good price) and Linux version costs...$720 shocked.gif

If the last one was $360 for Linux too, instead of nearly double, I would have gone for it... ultimately its not my decision to make, and I need to find a solution just as good, and at a cheaper price. I’m not sure if I'll find any, but I'm running out of time....
Brendon Koz
Any possibility you can just create an HTML-based form highly stylized in CSS (to make it look like the finalized PDF) and then just grab the input from the form to create the PDF and send back to both the user and (if need be) the receiving party?
Luke
That would be the prefered way of doing it, but the problem is

(1) There are a ton of forums. It easier to add boxes into existing pdf forums. Plus some of these forums, on the admin side, are legal documents and have to be authentic. That means that when printing it, its had to be from the PDF. I can import/export the fields.
(2) HTML pages print like crap, and its more of a professional thing.
Brendon Koz
1.) Crap...

2.) When the user submits the form, couldn't it create the PDF on the fly and present them with the Adobe Acrobat file within their browser as a finished product?

I don't think I'll be much help. I've only recently started using Acrobat Pro, and...I hate it. ...nor have I used any of PHP's PDF libraries.
Luke
It could, but that would be a waste of space. The idea is to save all the values in a database to cross reference it and fill in the fields, from a single pdf file, on the fly with the server. If you store the whole pdf you would be storing 300+kb every time, which adds up. That's why you have the PDF forum submit it as post data which you can then store in the database. The biggest problem is Database -> PDF, which is needed when creating a new pdf, editing or viewing a pdf. You need it for a new one so you know which customer ID its associated to.

It's very possible with those programs listed above, just expensive. The last one I listed is great, but I think they charge almost double for the linux version is bs.
marcele
Cy check out http://fpdf.org/ Its a FREE PHP class that allows you to generate pdf's. It's very straight forward , fully OO, and easy to use original.gif
Luke
I dont think you can fill out fields with it.
marcele
You are much better off doing what malikyte said and just having an html form which they fill in and then generate the pdf on the fly. This simplifies the process of creating the forms, and gives you the ability to log the info in a db (or do anything else you want with it).
Luke
Actually I found one on freshmeat.net (sf.net site) biggrin.gif. Its called PDFTK, which does exactly what I need to do, and its under a GPL license biggrin.gif

QUOTE(marcele @ Feb 3 2006, 09:26 AM) *
You are much better off doing what malikyte said and just having an html form which they fill in and then generate the pdf on the fly. This simplifies the process of creating the forms, and gives you the ability to log the info in a db (or do anything else you want with it).


Cant do that with legal documents.
Brendon Koz
Tell that to the State University of New York! laughing.gif


Technically, I think you could do anything so long as your disclaimer is legal enough for the context. However, I'm glad you found a useable alternative.

P.S. - FPDF was basically what I was suggesting, except he'd be using a class that was already made rather than writing his own (and I would suggest using a class anyway).
Luke
I dont think FPDF does form fill anyway... Even if it did and it was all PHP, im pretty sure it would be slow anyway... With the program I got, PDFTK (and others like it), it uses a command line program you install on your server. From there you can write a class to bridge the gap, which I did biggrin.gif. It's actually a pretty simple process.... Generate a random unique key based on md5( uniqid( microtime() ) ) and use it as a file name for both the output pdf and fdf in the command line using shell_exec. Then load the output pdf in variable memory, delete your "temporary files" and display it in the browser with the proper headers. Took me about 15 minutes or less to write the library class in my CMS original.gif
mera
cy, I have tried with pdftk and it works fine in my pc but after I uploaded this files in a server, it gives error message.

Error message>
Acrobat could not open output.pdf because it is either not a supported file type or because the file has been damaged....either it is sent as an email attachment ....

what do you advise me.
Mera
Luke
Try saving your PDF documents in 6.0 format (if you have no javascript in your pdf's do 5.0. Lower the better).. You can do this by File -> Reduce File Size.

We abandoned pdf-tk because it was shifting fields upward... It may not even support acrobat 7.... Dont really know because we just upgraded to 7. You should look into pdf-tools or FDFMerge. If you have a windows server, activePDF has something too.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.