This package allows your users to download Plone content as PDF files. As admin you can define specific PDF themes per content-type.
- Adds download as PDF action at the bottom of the page
- Possibility to define custom PDF themes per content-type
- Asynchronously generate PDF files and notify users by email when PDF is ready
- Possibility to temporarily disable dynamic PDF creation by adding an item called 'action-download-pdf' within context
- Add eea.pdf to your eggs and zcml section in your buildout and re-run buildout. You can download a sample buildout from https://github.com/eea/eea.pdf/tree/master/buildouts/plone4
- Install eea.pdf within Site Setup > Add-ons
[instance]
eggs =
...
eea.pdf
zcml =
...
eea.pdf
Ensure that you have installed wkhtmltopdf on your machine. You can also install wkhtmltopdf from buildout:
[buildout]
parts +=
wkhtmltopdf
[wkhtmltopdf]
recipe = hexagonit.recipe.download
url = http://eggrepo.apps.eea.europa.eu/pypi/wkhtmltopdf/wkhtmltopdf-0.12.1.tgz
[instance]
environment-vars +=
WKHTMLTOPDF_PATH ${wkhtmltopdf:location}/wkhtmltopdf
By default all PDFs are generated asynchronous, therefore some extra config is needed within your buildout in order for this to work properly.
First of all you'll need a folder were to store generated PDF files. For this you can create it manually within buildout:directory/var/ or you can let buildout handle it:
[buildout]
parts +=
media-downloads
media-downloads-temp
media-downloads-path = ${buildout:directory}/var/downloads/pdf
media-downloads-temp = ${buildout:directory}/var/downloads/tmp
[media-downloads]
recipe = ore.recipe.fs:mkdir
path = ${buildout:media-downloads-path}
mode = 0700
createpath = true
[media-downloads-temp]
recipe = ore.recipe.fs:mkdir
path = ${buildout:media-downloads-temp}
mode = 0700
createpath = true
This will create a folder named downloads within buildout:directory/var/
Next, in order for this folder to be visible from your website and your users to be able to download generated PDFs you'll need to tell to your zope instances about it:
[buildout]
media-downloads-name = downloads
media-downloads-path = ${buildout:directory}/var/downloads/pdf
media-downloads-temp = ${buildout:directory}/var/downloads/tmp
[instance]
environment-vars +=
EEADOWNLOADS_NAME ${buildout:media-downloads-name}
EEADOWNLOADS_PATH ${buildout:media-downloads-path}
EEACONVERTER_TEMP ${buildout:media-downloads-temp}
Also, don't forget to setup plone.app.async
[buildout]
[instance]
eggs +=
plone.app.async
zcml +=
plone.app.async-single_db_worker
- Go to Site Setup > PDF Settings
- Customize an existing PDF theme or add a new one
- Go to Home page and click on download as pdf icon at the bottom of the page or directly access http://localhost:8080/Plone/front-page/download.pdf
For more information about wkhtmltopdf options like Table of contents XSL file, header and footer parameters, etc. see wkhtmltopdf documentation.
A page template to be used for PDF Cover. Leave empty to disable it. Default: pdf.cover
A page template containing copyright and author information. This page will be placed between cover and PDF body. Leave empty to skip it. Default: pdf.disclaimer
A page template to be used for PDF body. An empty value will skip PDF body. Default: pdf.body
A page template to be used for back cover. Leave empty to disable back cover. Default: pdf.cover.back
A page template to be used as PDF body header. This will not appear on cover, disclaimer or back cover. Leave empty for no header. Default: pdf.header
A page template to be used as PDF body footer. This will not appear on cover, disclaimer or back.cover. Leave empty for no footer. Default: pdf.footer
An XSL page template to be used for PDF Table of contents. See wkhtmltopdf documentation for more information about XSL format. Leave empty to disable Table of contents. Default: pdf.toc
Enable or disable Table of Contents internal links and also PDF bookmarks (outline) Default: False
Enable or disable javascript. Default: True
Wait some seconds for javascript to finish Default: 0
Abort PDF conversion after this number of seconds Default: 3600
Generate PDF asynchronously and send an email to the user when it's done Default: True
Start counting pages within PDF Body from this number. Usefull when cover and/or disclaimer are enabled. Default: 0
This option defines the maximum depth a folderish item can go while recursively includes it's children within PDF. Default: 1 (include only direct children, non-folderish ones)
This options limit the number of direct children a folderish item can include within PDF. Default: 100
The total items to be included within PDF export for a folderish item, including depth and breadth. Default: 1000
Apply this theme to selected portal types. Default:
Custom permissions added by this package
Assign this permission to roles that you want to be able to download content as PDF Default: Owner, Manager, Editor
Assign this permission to roles that you want to be able to contextually customize the output PDF look and feel Default: Manager, Site Administrator
This package uses Plone Content-rules to notify users by email when an asynchronous PDF job is done. Thus 3 custom content-rules will be added within Plone > Site Setup > Content-rules
Notify the person who requested a PDF export that the PDF successfully exported and provide a link to the downloadable PDF
Notify the person who requested a PDF export that the PDF export failed.
Notify admin that there were issues while exporting PDF
In order to be able to easily customize emails sent by this package the following custom email template string substitutions can be made
The absolute URL of the Plone object which is downloaded as PDF
Email address of the user that triggered the download as PDF action
Error traceback when download as PDF job fails
Site Admin email address customizable via Plone > Site Setup > Mail
Site Admin name customizable via Plone > Site Setup > Mail
Title of the Plone object which is downloaded as PDF
The absolute URL where the generated output PDF can be downloaded
Download type. Default to PDF for this package. It is package specific and it can be PDF, EPUB, etc.
You have the possibility to temporarily disable dynamic PDF export contextually by adding a static PDF file (or a Python Script, Page Template, etc) within context called action-download-pdf. This way /download.pdf will return this file instead of generating one based on context data.
Note
This works only with folderish items.
PDFs are generated asynchronously using a parallel zc.async queue.quota. The number of workers that will generate PDFs in parallel is automatically calculated based on the number of zeo-clients registered with plone.app.async-*_db_worker.
As every db_worker can handle simultaneously maximum 3 jobs (hard-coded in zc.async Agent), if you have 2 workers then the maximum number of PDFs that will be generated at the same time will be 6 (2 workers * 3). Same if you have 5, you'll get 15 PDFs generated at the same time.
If for any reason you don't want them to be generated simultaneously you can set environment variable EEAPDF_ASYNC_THREADS to 1 within buildout:
[buildout]
...
[instance]
...
environment-vars +=
EEAPDF_ASYNC_THREADS 1
Also, if you experience issues by having too many simultaneously PDF jobs, you can limit them in the same way as above.
- Latest source code (Plone 4 compatible): https://github.com/collective/eea.pdf
The Initial Owner of the Original Code is European Environment Agency (EEA). All Rights Reserved.
The EEA PDF (the Original Code) is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
More details under docs/License.txt
EEA - European Environment Agency (EU)