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 \
   python3-pip \
   libpangoft2-1.0-0 \
   libpango1.0-0 \
   python3-gi 
pip3 install WeasyPrint

Test with

weasyprint --version

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

19 Jan 2024 use the PRINT_TEMPLATE as a view template if present
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
I Attachment Action Size Date Who Comment
GenPDFWeasyPlugin.md5md5 GenPDFWeasyPlugin.md5 manage 174 bytes 21 Jan 2024 - 11:59 MichaelDaum  
GenPDFWeasyPlugin.sha1sha1 GenPDFWeasyPlugin.sha1 manage 198 bytes 21 Jan 2024 - 11:59 MichaelDaum  
GenPDFWeasyPlugin.tgztgz GenPDFWeasyPlugin.tgz manage 6 K 21 Jan 2024 - 11:59 MichaelDaum  
GenPDFWeasyPlugin.zipzip GenPDFWeasyPlugin.zip manage 9 K 21 Jan 2024 - 11:59 MichaelDaum  
GenPDFWeasyPlugin_installerEXT GenPDFWeasyPlugin_installer manage 4 K 21 Jan 2024 - 11:59 MichaelDaum  
Topic revision: r6 - 21 Jan 2024, MichaelDaum
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