This package provides utilities to convert images and PDF files using ImageMagick. It also provides a generic /download.pdf browser view that allow your users to download Plone pages as PDF files with custom PDF cover, disclaimer and back cover (requires wkhtmltopdf and pdftk system-packages installed on your server).
Provide custom browser:page called @@pdf.cover:
<browser:page
for="my.package.interfaces.ICustomContent"
name="pdf.cover"
class=".app.pdfview.Cover"
template="zpt/pdf.cover.pt"
permission="zope2.View"
/>
First page after PDF Cover containing author details and copyrights. Provide custom browser:page called @@pdf.cover:
<browser:page
for="my.package.interfaces.ICustomContent"
name="pdf.disclaimer"
class=".app.pdfview.Disclaimer"
template="zpt/pdf.disclaimer.pt"
permission="zope2.View"
/>
Provide custom browser:page called @@pdf.body:
<browser:page
for="my.package.interfaces.ICustomContent"
name="pdf.body"
class=".app.pdfview.Body"
template="zpt/pdf.body.pt"
permission="zope2.View"
/>
Provide custom browser:page called @@pdf.cover.back:
<browser:page
for="my.package.interfaces.ICustomContent"
name="pdf.cover.back"
class=".app.pdfview.BackCover"
template="zpt/pdf.cover.back.pt"
permission="zope2.View"
/>
To enable Table of contents provide an empty browser:page called @@pdf.toc:
<browser:page
for="my.package.interfaces.ICustomContent"
name="pdf.toc"
template="zpt/pdf.toc.pt"
permission="zope2.View"
/>
For PDF cover you’ll have to provide a named adapter like:
<adapter
name="pdf.cover"
for=" my.package.interfaces.ICustomContent"
provides="eea.converter.interfaces.IPDFOptionsMaker"
factory=".adapters.CoverOptionsMaker" />
Same for PDF disclaimer:
<adapter
name="pdf.disclaimer"
for=" my.package.interfaces.ICustomContent"
provides="eea.converter.interfaces.IPDFOptionsMaker"
factory=".adapters.DisclaimerOptionsMaker" />
Or for PDF back cover:
<adapter
name="pdf.cover.back"
for=" my.package.interfaces.ICustomContent"
provides="eea.converter.interfaces.IPDFOptionsMaker"
factory=".adapters.BackCoverOptionsMaker" />
For PDF body you’ll have to provide a named adapter like:
<adapter
name="pdf.body"
for=" my.package.interfaces.ICustomContent"
provides="eea.converter.interfaces.IPDFOptionsMaker"
factory=".adapters.BodyOptionsMaker" />
For global PDF options provide an unamed adapter like:
<adapter
for=" my.package.interfaces.ICustomContent"
provides="eea.converter.interfaces.IPDFOptionsMaker"
factory=".adapters.OptionsMaker" />
Also add custom print.css for your needs. See more at eea.pdf
In order to restrict access to /download.pdf you’ll have to provide a multi-adapter named pdf.support with a method called can_download like:
<browser:page
name="pdf.support"
for="zope.interface.Interface"
class=".support.Support"
permission="zope.Public"
allowed_interface="eea.converter.interfaces.ISupport"
/>
Same for asynchronous download, define a method called async. See default implementation within eea.converter.browser.app.support or add an environment var called EEACONVERTER_ASYNC within your buildout.cfg:
[instance]
...
environment-vars =
EEACONVERTER_ASYNC True
This package uses Plone Content-rules to notify users by email when an asynchronous job is done. Thus 3 custom content-rules will be added within Plone > Site Setup > Content-rules
Warning
As these content-rules are triggered by an asynchronous job, while you customize the email template for these content-rules, please DO NOT USE OTHER string substitutions that the ones that start with $download_ as you’ll break the download chain. Also if you disable these content-rules the users will never know when the file is ready and what is the link where they can download the output document.
Notify the person who requested a PDF/ePub export that the document successfully exported and provide a link to the downloadable file.
Notify the person who requested a PDF/ePub export that the export failed.
Notify admin that there were issues while exporting PDF/ePub
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/ePub
Email address of the user that triggered the download as PDF/ePub action
Error traceback when download as PDF/ePub 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/ePub
The absolute URL where the generated output PDF/ePub can be downloaded
Download type: PDF/ePub
Note
These are not hard dependencies. You can use all features of eea.converter or just the ones that you need.
pdfinfo to parse pdf metadata (part of the xpdf package):
yum install xpdf (fedora)
apt-get install xpdf (debian)
pdftk to generate a cover image from a pdf file:
yum install pdftk (fedora)
apt-get install pdftk (debian)
ImageMagick (6.3.7+):
yum install ImageMagick
apt-get install imagemagick
See the doc directory in this package.
The Initial Owner of the Original Code is European Environment Agency (EEA). All Rights Reserved.
The EEA Exhibit (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