how to generate PDF and save a copy on client?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vivekchopra
Forum Newbie
Posts: 4
Joined: Thu Aug 04, 2005 8:41 pm

how to generate PDF and save a copy on client?

Post by vivekchopra »

I have a hardcopy PDF form and now I want to create an applicant which reads data from database and fills the PDF form. Users should be able to save this filled form.

I have tried one method. I created a PDF form (with defined text fields) and I generate a FDF file using information from the database. When a user clicks on download, the FDF populates the PDF form and displays to the user.
Problem: User sees a completed form but can't download the COMPLETED form. In this case, I am able to print the completed form or download the original form (without any data filled in) but not able to download the completed form.

If I use CPDF library then I need to specify each fields' dimensions and position which is a pain because the number of fields is very high and I need to do a few forms.

Whats the best way to approach this problem? I want to create a PDF from Database and allow user to save it as well.

Any help is appreciated.

Vivek
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

very nice pdf tool:
http://www.ros.co.nz/pdf/
vivekchopra
Forum Newbie
Posts: 4
Joined: Thu Aug 04, 2005 8:41 pm

CPDF from R&OS

Post by vivekchopra »

Hey Feyd,

Thanks for your reply. I have tried using this library as well. As I mentioned in previous post,
"If I use CPDF library then I need to specify each fields' dimensions and position which is a pain because the number of fields is very high and I need to do a few forms."

The problem with using this library is that I need to give the coordinates and dimensions of each text field/image/background image in the PDF form that it becomes very messy code for each form as I need to match it against the hardcopy of PDF form.

And considering that I have to do different kinds of forms, the task gets very mechanical.

Is it possible to open an existing PDF file using this library? And then add my contents on the required fields? That would be the ideal solution for me. Let me know if it supports this functionality.

Vivek
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

fpdf can open an existing pdf, however if you use the ezPDF extension it's quite simple to create quite complex pdf's...
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

If you know LaTeX, I like to have my PHP scripts output a LaTeX source file that I then run through pdflatex using exec. You'll probably have to build a lot of you own "helper" code to properly escape the different special characters, but otherwise it makes layout a snap. (If you already know LaTeX..... if you don't, its probably not the easiest approach)
vivekchopra
Forum Newbie
Posts: 4
Joined: Thu Aug 04, 2005 8:41 pm

will this help?

Post by vivekchopra »

Hi, I just came across this post

viewtopic.php?t=30157

And I also need to fill an existing PDF. Do you think the above post should help me with it?

Vivek
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it could... it doesn't really hurt to try it..
vivekchopra
Forum Newbie
Posts: 4
Joined: Thu Aug 04, 2005 8:41 pm

thanks ..

Post by vivekchopra »

Thanks ..

I will try it and post the results here ..

Thanks.
Vivek
egreene
Forum Newbie
Posts: 2
Joined: Mon Sep 12, 2005 11:16 pm

Java-based solution

Post by egreene »

Anyone had any success integrating Java with PHP? The best "free" solution I've found for flattening form data on a PDF is IText (http://www.lowagie.com/iText/) but it is java based. If you can integrate Java with PHP it is the best tool to use. Otherwise you will have to use a server-based workaround (keep data in database and retrieve on every "request") like I do with formGenie. See website below.
Post Reply