warning This is an discontinued version of ToPDFPlugin. Extensions in the Extensions/Archived web are obsolete and no longer maintained.

support How to configure your Foswiki to install from this repository

In lib/LocalSite.cfg, add this web's URL to {ExtensionsRepositories}:

Read more about configuring Extension repositories

ToPDF Plugin

This plugin is currently not maintained by me. Please consider taking the better alternatives like GenPDFWebkitPlugin

This plugin converts Foswiki topics into PDF`s. Comparing to GenPDF or others, its main goal yet is to support CSS as far as possible and therefore the PDF should just look like the original topic. In addition it supports to render the topic in a diffrrent template before generating the PDF to customize the topic, remove anything not needed or just adjust the "printing" view for papers.

The plugin fetches all data ( pictures, css ..) on file-system base and save a lot of webserver-load now.

This Plugin was based on GenPDF

This plugin is currently not able to display patter-skin topics correctly. See ToDo/Bug section below


  • as backend it uses html2pdf, a php5 script to convert html files into PDFs. It supports CSS 2.0 and even float content.

Plugin Installation Instructions

Note: You do not need to install anything on the browser to use this Plugin. The following instructions are for the administrator who installs the Plugin on the server where Foswiki is running.

Dependecies( Tested with linux, should work under windows too)


  • PHP5 as client modes, so for the use in the command line
  • Ghostscript-GPL ( worked with 8.61, please add other versions here, if you tested it )

  • gnu-gs-fonts-std: Ghostscript Standard Fonts
  • gnu-gs-fonts-other: Ghostscript Extra Fonts
  • Microsoft fonts: you might want install the Microsoft fonts, you can follow this readme http://corefonts.sourceforge.net/


  • tba

Installation instructions

Debian Dependencies Installation
apt-get install gs-gpl gs-fonts php5-cli cabextracter

Now the Truetypes fonts mostly needed
wget http://ftp.de.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_2.7_all.deb

dpkg -i ttf-mscorefonts-installer*.deb
Now set the values throught configure:
{Plugins}{ToPDFPlugin}{FontsPath} = /usr/share/fonts/type1/gsfonts/
{Plugins}{ToPDFPlugin}{TffFontsPath} = /usr/share/fonts/truetype/msttcorefonts

No you should have all dependencies generally needed

General Plugin installation
  • Use the Extension-Center to install the plugin
  • Attention: Right now the pub/System/ToPDFPlugin/html2pdf/topdf.php needs to be customized for each install. you must enter the absolute path to the lib/ directory there.
  • Use the Foswiki configure script to define
Option Default Description
DefaultEncoding iso-8859-1 normaly your Foswiki encoding
BaseUrl foswiki.org what is the URL of the page. Important! Its needed to define what can be fetched locally and what is remote
GhostscriptPath /usr/bin/gs path to Ghostscript
FontsPath /usr/share/fonts/default/ghostscript/ path to your fonts reporsitory
PrintTemplate pattern template to use for rendering the topic with, before creating the PDF
RenderImages 1 render and show images
RenderForms 0 render forms
RenderLinks 1 render links and make them clickable
PageWidth 755 width of the page, important if linebreaks should be exact
MediaType "A4" Media format
DateFormat "d.m.y" date format to use when filling in header/footer
CreateTOC 0 Create TOC ( not the toc of Foswiki )

  • Customize ToPDFPluginHeader and ToPDFPluginFooter for using your footers and headers
  • Add the PDF button to your viewtopicactions.skin.tmpl ( or somewhere else ) by using the macro : %TOPDFBUTTON% which would be shown as %TOPDFBUTTON%

Option Default Description
web current web web, where the topic is located, which should get converted
topic current topic topic to be converted
label PDF how should the button be named
  • Test if the installation was successful:
    • open view/System/ToPDFPlugin and click this %TOPDFBUTTON% and hopefully you get a PDF of the ToPDFPlugin topic.

you can also use the macro TOPDFBUTTONLINK which just returns the link-destination.

ToDo / Bugs

  • images included in CSS files with relative paths are not shown
  • problems with "focus" on links, painting the whole page in one color ( like pattern skin )

Plugin Info

Plugin Author: Foswiki:Main.MayerEugen
Copyright: © 2009, Collaborganize www.collaborganize.com
License: GPL (GNU General Public License)
Plugin Version: 31 Jan 2009 (V1.6)
Change History:
31 Jan 2009: Added TOPDFBUTTONLINK which just returns the link. Mostly needed when skinning
28 Jan 2009: Fixed some path errors, updated deps docs and added a Debian howto
24 Jan 2009: MANIFEST fixed. Right now the pub/System/ToPDFPlugin/html2pdf/topdf.php needs to be customized for each install.
07 Jan 2009: * Fixed the Manifest which has skipping the pub/System/ToPDFPlugin folder
* Added Macro for the button
04 Dez 2008: Fixed all bugs with Foswiki, also using restHandler now, instead of /bin/topdf.
All data is fetched locally now. Working footer and header
01 Dez 2008: Ported to Foswiki and made for auto-build. Simplified configuration a lot and added
new configuration abilities like template, renderForms, renderImages.
Everything availble thorugh configure script now. Header and Footer are Foswiki-Topics now. Fixed some bugs with images and encoding.
01 Jun 2008: Initial version
Foswiki Dependency:  
CPAN Dependencies: HTTP::Cookies::Find,Encode,Encode::Encoding,File::Basename,URI::Escape,HTML::TreeBuilder
Other Dependencies: htmltopdf(included in the package)
Perl Version: 5.005
Add-on Home: http://foswiki.org/Extensions/ToPDFPlugin
Feedback: http://foswiki.org/Extensions/ToPDFPluginDev
Appraisal: http://foswiki.org/Extensions/ToPDFPluginAppraisal

Related Topic:

-- Foswiki:Main/MayerEugen - 28 Jan 2009
Topic revision: r15 - 19 Mar 2010, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy