Coder Social home page Coder Social logo

kingel / collective.sendaspdf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zestsoftware/collective.sendaspdf

0.0 2.0 0.0 541 KB

A Plone product that allows downloading the current page as a PDF and also sending it by e-mail

Shell 0.41% JavaScript 5.10% Python 94.49%

collective.sendaspdf's Introduction

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.

To install xhtml2pdf, add the following to your buildout eggs directory:

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.

This page proposes a few settings:

  • 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.
  • a list of browser for which the attachment name should not be given. Somehow, Chrome considers the PDF generated by the tool as potentially harmful for the computer if the attachment name is specified. Adding Chrome here avoids getting a warning.

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.

Compatibility

This product has been tested with Plone 3 and Plone 4. After version 2.5 (well, starting at 2.6), we'll only ensure compatibility with Plone 4 (at least in the tests).

For developers

You can find some extra doc in collective/sendaspdf/tests.adapter.txt. It explains how to define custom options in the request or with an adapter.

Testing

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

On Plone3, this is my configuration for running the tests (packages do not seem to be mandatory as the eggs are taken from the zeoclient section):

[test]
recipe = collective.recipe.z2testrunner
zope2part = zeoclient
packages =

And on Plone 4:

[test]
recipe = zc.recipe.testrunner
eggs =
    ${zeoclient:eggs}
defaults = ['--auto-color', '--auto-progress']
environment = environment

[environment]
WKHTMLTOPDF_PATH=${wkhtmltopdf:location}/wkhtmltopdf

collective.sendaspdf's People

Contributors

davidemoro avatar giacomos avatar vincent-psarga avatar kingel avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.