Converting PHP or HTML Page to PDF using libpdf_php library

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
baptiste2k8
Forum Newbie
Posts: 4
Joined: Sun May 24, 2009 4:18 pm

Converting PHP or HTML Page to PDF using libpdf_php library

Post 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
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Converting PHP or HTML Page to PDF using libpdf_php libr

Post 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.
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

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Converting PHP or HTML Page to PDF using libpdf_php libr

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
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

Post 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
Post Reply