Page 1 of 1

phpwcms2pdf - Print PHPWCMS 1.3 Page as PDF

Posted: Mon 23. Apr 2007, 14:01
by marcus@localhorst
Info: Oliver Georgie will include this PDF printing feature in the next release!
Hi,
Need a simple Solution to print your phpwcms content to PDF?
there was some ideas about that here in the forum
( http://www.phpwcms.de/forum/viewtopic.php?t=13594#79835 )
I take these basic and enhance it to my needs.

So here is the result (read about features, limitations and usage below) :
download phpwcms2pdf
There are all files you need included (incl. html2fpdf package).
If you find bugs take some bugpowder (like in "Na-ked Lunch" ;-))

Docu of fpdf and html2fpdf: (what is possible and what not)
http://www.fpdf.de/dokumentation/
http://www.fpdf.org/
http://html2fpdf.sourceforge.net/

This is only tested with phpwcms 1.3. ! I'm not shure if this works below, because I used phpwcms function which seems to be new (returnGlobalGET_QueryString()). AND the template folder name has changed from phpwcms_template to template - please keep in mind where to place the frontend_render/pdf.php file ;-)

Image
Temporary live Demo:
http://tinyurl.com/3897d4

INSTALLATION

Code: Select all

   -----------------------------------------------------------------------------
	 phpwcms2pdf - Print PHPWCMS 1.3 Page as PDF
	 marcus@localhorst
	 23-Apr-2007
	 -----------------------------------------------------------------------------
	 
	 CREDITS:
	 # This use the html2fpdf Library
	   http://html2fpdf.sourceforge.net/
	   http://html2fpdf.sourceforge.net/classdoc.php
	   fpdf Doc (html2fpdf is build on a changed fpdf class!)
	   http://www.fpdf.org/en/doc/
	 
	 # Based on this thread: http://www.phpwcms.de/forum/viewtopic.php?t=13594#79835
     which is based on the "nice formatted printing page" hack
     http://www.phpwcms.de/forum/viewtopic.php?t=3759
	   I just add the template feature and some finetunings for my needs.
   
   # most heavy rotating records in these days
     OF MONTREAL - Hissing Fauna, Are You The Destroyer?
     ARCADE FIRE - EP + Neon Bible
     NEUTRAL MILK HOTEL - all
     
	 
	 FEATURES
	 # Replacementtag no core code hacks
	 # prints only your {CONTENT} (depends on your phpwcms setup)
	 # add Metadata (from phpwcms article) to PDF 
	   (Subject, Keywords, Author, Description)
	 # setup a template with your custom header/footer in templates/inc_default/pdf.tmpl
	 # takes the global $phpwcms['inline_download'] switch from config.inc.php
	   to display the pdf in new browserwindow ( $phpwcms['inline_download'] = 1; )
		 or force download ( $phpwcms['inline_download'] = 1 )
	 
	 LIMITATION
	 # PDF Layout is very basic
	 # CSS Support is very basic
	 # nested div,elements makes problems (you can disable some tags - I did this
	   with <div>
		 $pdf->DisableTags("div");
	 
  	 The Limitations came mainly from html2fpdf
  	 read more here about XHTML/CSS Support
  	 http://html2fpdf.sourceforge.net/features.php
  	 
	 # sometimes I get blank PDF, I think this comes throught broken pictures
	 
	 TODO
	 # inline download doesn't work in IE
	   don't know why...
	 
	 #############################################################################
	 # USAGE AND INSTALLATION
	 #############################################################################
	 
	 # unpack/copy the zip archiv content to your phpwcms root folder
	   (no files will be overwritten!)
   
   # go to template/inc_script/frontend_render/pdf.php and change the values
     $pdfFilePrefix and $disableTags if needed.
     $disableTags is maybe useful to play with, because nested html maybe makes problems
     http://html2fpdf.sourceforge.net/classdoc.php
     
   # go to template/inc_default/pdf.tmpl to setup your basic html output 
     which will be converted to PDF
     
	 # put a Link like this into your PHPWCMS template, where the "Print to PDF"
     link should shown
     [PDF]Print Page as PDF[/PDF]
     
	 # add <!-- startpdf --> and <!-- stoppdf --> before and after your
     {CONTENT} which should transform to pdf.
		 Typically like this:
			<!-- startpdf -->
			 {CONTENT}
			<!-- stoppdf -->
			
	 # that's all - you should read the html2fpdf Docu to change 
     the script for your needs
     
     THAT'S ALL 
PS: why does the forum kicks me out? f**k --- grrr. no time for that... :-(
ok, I found out - because of my reference to "na-ked lunch" - the forum doesn't like the term "na-ked" haha - very prude...

Posted: Mon 23. Apr 2007, 15:03
by silencox
Great marcus

I'm go to test this

Best regards

Posted: Mon 23. Apr 2007, 19:57
by update
marcus,
I just visited the test page - this is really great!
Does it work with png (eventually transparent ones) too?
Thank you !
Greetings
claus

Posted: Tue 24. Apr 2007, 07:00
by marcus@localhorst
claus wrote:marcus,
I just visited the test page - this is really great!
Does it work with png (eventually transparent ones) too?
Thank you !
Greetings
claus
thanks and yes it should work with transparent png (but I think only 8-bit transparency, not real 24-bit alpha channels)
try and post it :-) (installation is just drag and drop :-) and some template changes)

OG will include the pdf printing in the next release he said...

best marcus

Posted: Tue 24. Apr 2007, 14:27
by Heiko H.
Hi Marcus,

I am really happy that you have taken your time to develop this thing further. I was too busy, sorry.
I am also a little proud if our work should be implemented in phpwcms 8) .


Super! THX Markus...

Posted: Tue 24. Apr 2007, 14:34
by marcus@localhorst
Heiko H. wrote:Hi Marcus,

I am really happy that you have taken your time to develop this thing further. I was too busy, sorry.
I am also a little proud if our work should be implemented in phpwcms 8) .


Super! THX Markus...
:-) hehe - thanks to you and the printing page guy - my work was just glue some code bits, structure/format it a bit, read the docu and add some fancy stuff ;-)

best m.