cross
Foswiki General Assembly will be held on 28th November 2019, 1200 UTC on Freenode IRC channel #foswiki-association. See AgendaTenthGeneralAssembly
TIP GenPDFWeasyPlugin is not installed on Foswiki.org.

GenPDFWeasyPlugin

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.

Usage

Get a PDF by adding contenttype=application/pdf to the view url like this:
%SCRIPTURL{"view"}/%WEB%/%TOPIC%?contenttype=application/pdf&cover=print

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

%SCRIPTURL{"view"}/%WEB%/%TOPIC%?contenttype=application/pdf&cover=print&outfile=myreport.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';

Fonts

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. "Extensions Operation and Maintenance" Tab -> "Install, Update or Remove extensions" Tab. Click the "Search for Extensions" button. Enter part of the extension name or description and press search. Select the desired extension(s) and click install. If an extension is already installed, it will not show up in the search results.

You can also install from the shell by running the extension installer as the web server user: (Be sure to run as the webserver user, not as root!)
cd /path/to/foswiki
perl tools/extension_installer <NameOfExtension> 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 https://foswiki.org/Support/ManuallyInstallingExtensions for more help.

Dependencies

None

Change History

12 Nov 2019 don't append the html page to the end of the pdf output
11 Jul 2016 added option pdfdisposition to inline or redirect content; remove leftovers from copy-pasting GenPDFPrincePlugin
16 Sep 2015 initial release
Topic attachments
I Attachment Action Size Date Who Comment
GenPDFWeasyPlugin.md5md5 GenPDFWeasyPlugin.md5 manage 174 bytes 12 Nov 2019 - 11:19 MichaelDaum  
GenPDFWeasyPlugin.sha1sha1 GenPDFWeasyPlugin.sha1 manage 198 bytes 12 Nov 2019 - 11:19 MichaelDaum  
GenPDFWeasyPlugin.tgztgz GenPDFWeasyPlugin.tgz manage 6 K 12 Nov 2019 - 11:19 MichaelDaum  
GenPDFWeasyPlugin.zipzip GenPDFWeasyPlugin.zip manage 8 K 12 Nov 2019 - 11:19 MichaelDaum  
GenPDFWeasyPlugin_installerEXT GenPDFWeasyPlugin_installer manage 4 K 12 Nov 2019 - 11:19 MichaelDaum  
Topic revision: r4 - 12 Nov 2019, MichaelDaum - This page was cached on 13 Nov 2019 - 18:27.

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