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
Converting PHP or HTML Page to PDF using libpdf_php library
Moderator: General Moderators
-
baptiste2k8
- Forum Newbie
- Posts: 4
- Joined: Sun May 24, 2009 4:18 pm
Re: Converting PHP or HTML Page to PDF using libpdf_php libr
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.
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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
baptiste2k8
- Forum Newbie
- Posts: 4
- Joined: Sun May 24, 2009 4:18 pm
Re: Converting PHP or HTML Page to PDF using libpdf_php libr
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
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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Converting PHP or HTML Page to PDF using libpdf_php libr
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
Update: a quick Google brought this up:
http://www.betalon.com/blog/server/crea ... server.htm