![]() |
Output to PDF
Hey guys,
Just wondering if anyone here has any experience with generation PDF reports with PHP? Is this the best one to use? http://www.fpdf.org/ I'm having a hard time understanding how it works. For example, I have a website that generates a graph in flash. Then beneath the graph, I have rows upon rows of data to support the data in the graph. Then there's also the layout of the webpage itself. So my assumption is that the PDF would look pretty much identical to the layout of the site, what you see on the webpage... But I haven't got a clue how to go about this? I currently have the data exported to CSV which is easy because I don't have to worry too much about formatting. But the PDF part is kinda confusing for me... Help??? |
So what exactly is your question?
|
Quote:
How to basically get my webpage along with the dynamically generated contents to be able to be exported to PDF.... |
I have never worked with fpdf before, but this tutorial might be of use http://www.id.uzh.ch/cl/zinfo/fpdf/tutorial/tuto1.htm
|
Quote:
I guess I just don't conceptually understand how I can allow my users to export my PDF page in all it's glory via PDF. As an example, imagine this website: www.talkphp.com And imagine on the top corner it says: Export to PDF. Then when you click on it and save it to your desktop and then open it, you basically get a screenshot of the main page.... |
FPDF is the one to use. I used it for printing barcodes on a label printer many moons ago.
I'd suggest starting small, positioning text and lines etc. However I think that using any pdf API to draw anything more than simple pages will be like digging a hole with a spoon so to speak. I'll have a look tomorrow see if I can dig out that code. |
Quote:
Thank you I would really appreciate it...perhaps I can get idea's on how to do it after seeing some real live code.... |
|
Quote:
Thanks I will take a look..... |
If you want to generate PDF's in PHP, I would recommed to use Haru, instead of FPDF, its well documented on php.net and is better supported, plus its not only available as a PHP binding.
PHP Binding: http://pecl.php.net/haru PHP Binding Documentation: http://www.php.net/haru LibHaru: http://www.libharu.org/ |
Quote:
Wow this looks great....looking at it now... Do you know offhand if it supports flash images? I generate reports via flash graphs.... |
No I don't think Haru supports flash to be honest, but you can always add a feature request to their bug tracker and see if anyone can pick it up :)
|
Quote:
If Haru can do what I need it to do, then I'd rather look into replacing my flash graphs than to ask for a feature fix in Haru...although I guess it wouldn't hurt for Haru to continue multiple types of media objects.... |
Quote:
But I have never worked with flash in php, so you are on your own there =) |
Here's some of my code, maybe it helps:
PHP Code:
|
I was going to ask the same question so thanks for the topic!
|
Have not tried this but something similar words for .doc try
header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="downloaded.pdf"'); readfile('original.pdf'); Not to sure on the last line. http://corymathews.com/?p=287 shows how to save for .doc but changing the header files to the ones about should save a page as a .pdf. Then you don't need any third party crap. |
Quote:
|
Ye that would generate one on the fly. It makes the normal .php page render as a .pdf page. So there is no need for third party apps to convert the page into pdf this header file will do that for him.
The .pdf file in the above example is not already created. |
I think you misunderstand, he doesn't want to send the file to the browser, he wants to generate an actual pdf. Your example code sends the current page to the browser and forces it to not show it inline even if a plugin can display it inline.
And he does need "third party crap" to make a pdf, unless he wants to write a kick ass cryptic script to convert and write the binary data correct. |
| All times are GMT. The time now is 01:10 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0