An open source product for Plone to download or email a page seen by the user as a PDF file.

## Introduction

collective.sendaspdf is an open source product for Plone that allows downloading the page seen by the user as a PDF file. It also provide a form to send the page by e-mail (a screenshot of the current page in a PDF format being joined to the e-mail).

It relies on two products to generate the PDF files:

The site manager can easily chose which solution he prefers for the generation.

## Installing

To install the package, you can simply add ‘collective.sendaspdf’ to the eggs list in your buildout. Then install it using Zope’s quick installer or Plone’s add-on products manager.

pisa
pyPdf
html5lib
reportlab

collective.sendaspdf has been tested with development versions of pisa and html5lib. With the latest releases (when writing this README - html5lib 0.9 and pisa 3.0.33) some pages could not be rendered.

To install wkhtmltopdf, go to the projects page and download an executable version for your OS. Install it so the command ‘wkhtmltopdf’ is in the PATH. You can also update your buildout to automatically download wkhtmltopdf and have it used by your instance using the following recipes:

[buildout]
parts =
...
wkhtmltopdf
wkhtmltopdf_executable

[instance]
...
environment-vars =
...
WKHTMLTOPDF_PATH ${wkhtmltopdf:location}/wkhtmltopdf [wkhtmltopdf] recipe = hexagonit.recipe.download url = http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2 [wkhtmltopdf_executable] recipe = collective.recipe.cmd on_install = true on_update = true cmds = cd${buildout:directory}/parts/wkhtmltopdf
mv wkhtmltopdf-amd64 wkhtmltopdf
chmod +x wkhtmltopdf

You might have some changes to do depending on the architecture you are using (this example is for the amd64 architecture)

## Configuring

Go to the Plone control panel. You will find a ‘Send as PDF’ link that sends you to the products configuration page.

• the tool used to render the PDF files.

• the directory where the PDF files are stored.

• the sentence used as salt when hashing the user’s emails (this hash is used to know which files a user can access)

• the name used in the mail for the PDF file.

• a default title/body for the mails.

For wkhtmltopdf user, two extra options are available:

• always use the print CSS to render the PDF.

• use the print CSS for a given set of objects.

xhtml2pdf always use the print CSS.

## Testing

If you want to run the sendaspdf test suite, you need to add ‘pdfminer’ in the list of eggs in the buildout.

## Changelog

### 2.4 (2011-11-22)

• Added a setting in send as PDF tool so we can exclude some browser when forcing file name. This will mainly usefull for Chrome, as this one considers PDF generated with the tool as potentially harmful files. The same problem will certainly appear with Chromium. [vincent]

• Added some functional tests. [vincent]

• Don’t repeat POST parameters anymore. [vincent]

### 2.3.1 (2011-06-27)

• Bugfix with Unicode (again) and Ajax. [vincent]

### 2.3 (2011-05-25)

• Bugfix when not using secure mail host. [Yuri]

• Bugfix with wk transforms for encoding. [Khairil Yusof]

### 2.2 (2011-04-05)

• Fixed encoding to avoid being limitated to ASCII. [mauriziolupo]

• Added a generic setup handler for sendaspdftool and import/export preferences. [mauriziolupo]

### 2.1.1 (2010-12-23)

• added a target (sic :/) attributes on the link to preview the PDF so it opens in a new window. That’s prety ugly, but the fact is that if a user clicks on the link with IE and Acrobat reader installed, it will open the PDF in the same window. Hitting the ‘back’ button will display the page without the Ajax form. [vincent]

• in the Ajax popup, we do not try to initialize tinymce is an error happenned. [vincent]

• another IE bugfix due to an extra comma + CSS opacity fix [vincent]

### 2.1 (2010-12-15)

• also added meta tag robots:noindex on the forms. [vincent]

• Bugfix when sumbitting the Ajax form with TinyMCE. [vincent]

### 2.0.1 (2010-11-11)

• Bugfix in jquery.sendaspdf.js - removed one comma that was causing an error in IE. [vincent]

### 2.0 (2010-10-22)

• compatibility fixes with Plone4. [vincent]

• Removed the ‘-C’ parameter. [yuri + vincent]

### 1.1 (2010-09-16)

• when the PDF generation failed in the page to send by mail, we display an error page instead of failing. [vincent]

• bugfix in send page - it was impossible to load the Wysiwyg for anonymous users. Stole some code from POI to solve it. [vincent]

### 1.0.3 (2010-08-02)

• Fix broken release with missing files. (Now released with setuptools-git installed.) [mark]

### 1.0.2 (2010-08-02)

• updated egg information in setup.py (author and description). [mark]

### 1.0.1 (2010-08-02)

• registered the translations so they are applied. [mark]

### 1.0 (2010-07-21)

• added Dutch and French translations [vincent+mark]

• Added sendaspdf tool to manage preferences. [vincent]

## Project details

Uploaded source