phpwcms2pdf - Print PHPWCMS 1.3 Page as PDF

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

phpwcms2pdf - Print PHPWCMS 1.3 Page as PDF

Post 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...
Last edited by marcus@localhorst on Tue 24. Apr 2007, 06:58, edited 1 time in total.
silencox
Posts: 11
Joined: Wed 11. Oct 2006, 10:38

Post by silencox »

Great marcus

I'm go to test this

Best regards
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Post 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
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

Post 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
User avatar
Heiko H.
Posts: 868
Joined: Thu 27. Oct 2005, 11:41
Location: Dresden
Contact:

Post 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...
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

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