TIP GenPDFWeasyPlugin is not installed on Foswiki.org.


Generate PDF using WeasyPrint

This plugin generates PDF using the third-party tool WeasyPrint. You will have to download this tool and install it on the Foswiki Server before being able to use it for Foswiki.


Get a PDF by adding contenttype=application/pdf to the view url like this:

Optionally an url parameter outfile can be used to specifiy the target filename of the pdf being generated. If not specified explicitly it defaults to genpdf_%!TOPIC%.pdf


Installation Instructions

Installation instructions for weasyprint can be found on their site.

For a Debian/Ubuntu based installation use this:

apt-get install python-dev python-pip python-lxml \
                libcairo2 libpango1.0-0 libgdk-pixbuf2.0-0 \
                libffi-dev shared-mime-info
pip install WeasyPrint

Test with

weasyprint --help

Make sure that you record the full path to the binary and configure this plugin accordingly.

which weasyprint

Most probably, when installing weasyprint manually, this will be /usr/local/bin/weasyprint as is the default in this plugin's configuration.

If you are using other plugins that implement a completePageHandler (see InstalledPlugins) then you most probably need to tune the $Foswiki::cfg{PluginsOrder} to list the GenPDFWeasyPlugin behind those, for example like this:

$Foswiki::cfg{PluginsOrder} = 'SpreadSheetPlugin,PageOptimizerPlugin,NatSkinPlugin,GenPDFWeasyPlugin,SlideShowPlugin';


Note that weasyprint does not (yet) understand @font-face. To make use of custom fonts you will need to install them on the server itself. Recommended font packages on a debian/ubuntu system:

apt-get install fonts-font-awesome fonts-lato fonts-roboto ttf-mscorefonts-installer

You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.

Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install".

If you have any problems, or if the extension isn't available in configure, then you can still install manually from the command-line. See http://foswiki.org/Support/ManuallyInstallingExtensions for more help.



Change History

11 Jul 2016 added option pdfdisposition to inline or redirect content; remove leftovers from copy-pasting GenPDFPrincePlugin
16 Sep 2015 initial release

%META:FIELD{name="Author" title="Author" value="Michael Daum"}
Topic revision: r2 - 11 Jul 2016, MichaelDaum - This page was cached on 14 Feb 2017 - 03:05.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License