PDA

View Full Version : HTML to PDF - for the techies out there


PackerFanatic
09-16-2009, 10:18 PM
I am attempting to print off this sexy looking page, but because it has background colors, it won't print without going into the print settings of your browser and checking an option to "print background colors" (pretty stupid if you ask me) So the next option we thought of was to convert it to a PDF and print it that way. Sounds fairly straight-forward - but I can't seem to find a decent HTML to PDF tool. The page is built in PHP, and it is fairly dynamic (here is an example)

Truck Schedule (http://ptd.wausauchem.com/includes/truckschedule/schedule-print.php?state=Admin&city=Test%20Case%2001)

Using the two query params, it goes out to a DB and gets the data needed. It had been rendering the calendars with javascript, but I thought printing it all via PHP (which would then print all the HTML to the screen) would be easier for the PDF. But most of the tools I have tried using don't like the dynamicness of the page. Am I making this more difficult than I need to? Has anyone tried to do something like this? Any feedback would be greatly appreciated - thanks :)

GoldenEagle
09-16-2009, 10:30 PM
PrimoPDF is the thing that I use for this kind of stuff. But I just tried to do it and was able to generate the PDF fine, but the background colors on the calendar are not showing up.

JonInMiddleGA
09-16-2009, 10:30 PM
Maybe I'm just a little confused but ... I think I've got the .pdf you're trying to get.

When I went to "Save page as .pdf" in my Firefox, it ran through the plug-in from PDF Download — Free Tools to Create, Control and Convert Web-Based PDF Files (http://www.pdfdownload.org/)

Unlike when I tried to simply print the page to .pdf myself normally (which dropped the background colors out of the calendar cells), their conversion which popped up as a d'loadable after less than minute seems to include the background colors just fine. PM me an email address & I'll send you the .pdf I've got so you can see if it's what you're trying to accomplish.

Fidatelo
09-16-2009, 10:31 PM
You should be able to get a printer driver that will just print to pdf. I'll look around.

Fidatelo
09-16-2009, 10:32 PM
Dola

I think this is the one I've used in the past, but there are millions, just google "pdf printer driver free".

pdf 995: create PDF documents easily for free (http://www.pdf995.com/)

JonInMiddleGA
09-16-2009, 10:38 PM
FWIW, .pdf 995 is the pdf printer driver I've used for several years. This happens to be one of the fairly rare times where it isn't reproducing exactly what shows up on screen in the .pdf (it's dropping the background shading in the date cells).

edit to add: But otherwise it's been a lifesaving find for me, it's extremely unusual where it doesn't do exactly what I want/need it to do, probably less than once a year that happens.

PackerFanatic
09-17-2009, 08:08 AM
I was hoping to find a programmatic solution, because we don't want to have to make the users change settings or install drivers (just from an ease-of-use perspective)

JIMGA - I tried that pdfdownload site (used the bookmarklet) and it didn't take the query string parameters into account.

Ronnie Dobbs2
09-17-2009, 08:12 AM
PackerFanatic,

I tried to do something similar (dynamically created .pdfs from php) uisng FPDF (FPDF (http://www.fpdf.org/)) but found it clunky and inflexible and decided to use CSS instead to format the way I wanted to. YMMV.

Coffee Warlord
09-17-2009, 08:16 AM
FPDF is alright, though as said, it can be a bit inflexible. Clunky...eh, I picked it up quite easily, but formatting is indeed a bit of a pain on it.

PackerFanatic
09-17-2009, 08:21 AM
I had seen FPDF, but didn't see anything that allowed me just to print out a whole HTML page that was already built and formatted. So you just created the page using that class?

Coffee Warlord
09-17-2009, 08:35 AM
Oh oh, that, you need some extra stuff to do. If you're using PHP, I know there's a couple modules that need to be built in. Again, if you're using PHP, google pdf generation php (or something like that), you'll find the one I saw that could do that.