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
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
ok, I found out - because of my reference to "na-ked lunch" - the forum doesn't like the term "na-ked" haha - very prude...