Skip to main content

Create nice-looking PDF reports from HTML content.

Project description

Travis CI build status https://coveralls.io/repos/github/Edinburgh-Genome-Foundry/pdf_reports/badge.svg?branch=master

PDF Reports is a Python library to create nice-looking PDF reports from HTML or Pug templates. It is used at the Edinburgh Genome Foundry to unify the look of web-generated reports across different libraries and services.

For instance your template template.pug may look like this (see a full example):

#sidebar I am the text in the sidebar.

h1 {{ title }}

.ui.piled.segment
  p Oh hi there ! I am some text in a cool box.

Your Python code will be as follows:

from pdf_reports import pug_to_html, write_report
html = pug_to_html("template.pug", title="My report")
write_report(html, "example.pdf")

And your final result may look like this (PDF file):

https://github.com/Edinburgh-Genome-Foundry/pdf_reports/raw/master/screenshot.png

There is no documentation at the moment but since it is only two functions you can just have a look at their in-code documentation.

How it works

The library consists of just a few lines of Python, using pypugjs to parse Pug templates, optionally including stylesheets from the Semantic UI CSS framework, and finally calling weasyprint for PDF generation.

Importantly, because of the use of Semantic UI and the Lato font, pdf_reports currently requires an internet connection. It is also not the fastest report generator you will come accross, partly because it uses internet files.

Installation

You can install the library via PIP

sudo pip install pdf_reports

Alternatively, you can unzip the sources in a folder and type

sudo python setup.py install

Note: on some Debian systems you may need to first install libffi-dev (apt install libffi-dev).

License = MIT

This open-source software project was originally written at the Edinburgh Genome Foundry by Zulko and released on Github under the MIT licence (¢ Edinburg Genome Foundry). Everyone is welcome to contribute !

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdf_reports-0.1.7.tar.gz (16.9 kB view details)

Uploaded Source

File details

Details for the file pdf_reports-0.1.7.tar.gz.

File metadata

  • Download URL: pdf_reports-0.1.7.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pdf_reports-0.1.7.tar.gz
Algorithm Hash digest
SHA256 02ce25fab3e8f8294a7fa652c444e6e37741dc91f0dbe91f929b1b14c9eea516
MD5 5075511615ef710b56882dee00fcd89d
BLAKE2b-256 a989096f94d8832db955587f17ab1e6ad2c91871212f7b634b96e44a7ada6e9d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page