Page 1 of 1
Converting PHP or HTML Page to PDF using libpdf_php library
Posted: Tue Jan 25, 2011 2:09 am
by baptiste2k8
Hello all,
I am working on a project where I am using libpdf_php library to create pdf but I need to convert the entire page as it is displayed on the screen with whatever the format it has on the screen. can anyone tell me how to go about it? If there is a sample code for that I wll appreciate it.
Regards,
Baptiste
Re: Converting PHP or HTML Page to PDF using libpdf_php libr
Posted: Tue Jan 25, 2011 11:16 am
by pickle
Pretty much can't be done solely server-side. What you're seeing on the screen is mostly done by the browser itself converting the markup, css, and javascript into what you see. There's no way for the server to see exactly what you're seeing.
That said - if you're using html5 compatible browsers, I've heard there's a way to put an entire website in a <canvas> tag (via Javascript), then have that canvas tag rendered out to image data. Sending that image data back to the server may enable you to convert it to PDF.
The simplest thing though would be to have the user install a PDF printer & just print the screen.
Re: Converting PHP or HTML Page to PDF using libpdf_php libr
Posted: Tue Jan 25, 2011 11:29 am
by baptiste2k8
Thanks for the answer. but I do believe it can be done. I have seen some webpages in html or php with print button and when you click it it prints the entire page. this is exactly what I am looking for but not print screen.
Re: Converting PHP or HTML Page to PDF using libpdf_php libr
Posted: Tue Jan 25, 2011 11:34 am
by pickle
Yes, that's easy to do - to get it to a PDF though you either need to generate it on the server or on the client side. I've explained the only 2 ways I know of how to do that.
Re: Converting PHP or HTML Page to PDF using libpdf_php libr
Posted: Tue Jan 25, 2011 11:49 am
by Jonah Bron
There are ways to generate an image of a web page on the server. There are sites that will take thumbnails of websites for you, so it must be possible. There's probably a modified version of Firefox or something that can do that.
Update: a quick Google brought this up:
http://www.betalon.com/blog/server/crea ... server.htm