Link to home
Start Free TrialLog in
Avatar of TLN_CANADA
TLN_CANADAFlag for Afghanistan

asked on

Export Records as pdf from website

Hi all,

I have a journal page on a site and I want to be able to offer users the ability to export all of their journal entries as a pdf document. I have all of the fields setup that retrieve the users information (using PHP/MYSQL) and just want to a user to be able to click on a button on the page and their records are saved in a pdf document for them locally.

Thanks for any advice on how to do this,

D
Avatar of mcnute
mcnute
Flag of Germany image

You'll need something like fpdf to generate a pdf with your mysql query results.

Step 1 save query results in array
Step 2 generate pdf with looped results of query
Step 3 output to browser with header() php method.

Everything is explained very well on the fpdf website.
http://www.fpdf.org/
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TLN_CANADA

ASKER

Thank you Ray, this looks relatively simple alright. I went with your FPDF example, included this file in a page I already have and it gives the error:

FPDF error: Unable to create output file: /home/clear555/public_html/RAY_junk/temp_pdf_blue.pdf

Do you need to change this temp file output in your code?

Thanks,

D
My guess is that you need to create a directory named RAY_junk on your server. or generalize the solution to fit your particular needs and your required file paths. On my server, this is a public-facing script, so I keep all of the products in that directory and I remove the contents of the RAY_junk directory from time to time.  Garbage collection usually occurs on Sunday night.
Working now, sorry I misread the code and though it was creating a temp directory rather than accessing it. Thanks again for your help Ray!
Thanks for the points... Maybe I should update the example to look for the directory and use PHP mkdir() if it's not there!  Best regards, ~Ray