Skip to main content

Django PDF views, the easy way

Project description

Django PDF rendering, the easy way.

Build Status Latest Version Wheel License

Developed at en.ig.ma software shop.

Development Version

Note: A new PDF rendering backend using WeasyPrint for more accurate rendering is in development under the develop branch. See https://github.com/nigma/django-easy-pdf/pull/34 for changes, testing and discussion.

If you rely on the xhtml2pdf rendering backend and templates pin the package version to django-easy-pdf>=0.1.1<0.2.0.

Overview

This app makes rendering PDF files in Django really easy. It can be used to create invoices, bills and other documents from simple HTML markup and CSS styles. You can even embed images and use custom fonts.

The library provides both Class-Based View that is almost a drop-in replacement for Django’s TemplateView as well as helper functions to render PDFs in the backend outside the request scope (i.e. using Celery workers).

Quickstart

  1. Include django-easy-pdf, xhtml2pdf in your requirements.txt file. If you are on Python 3 you need to install the latest version of Reportlab and the beta version of xhtml2pdf:

    $ pip install xhtml2pdf>=0.2b1
  2. Add easy_pdf to INSTALLED_APPS.

  3. Create HTML template for PDF document and add a view that will render it:

    {% extends "easy_pdf/base.html" %}
    
    {% block content %}
        <div id="content">
            <h1>Hi there!</h1>
        </div>
    {% endblock %}
    from easy_pdf.views import PDFTemplateView
    
    class HelloPDFView(PDFTemplateView):
        template_name = 'hello.html'
  4. You can also use a mixin to output PDF from Django generic views:

    class PDFUserDetailView(PDFTemplateResponseMixin, DetailView):
        model = get_user_model()
        template_name = 'user_detail.html'

Documentation

The full documentation is at django-easy-pdf.readthedocs.io.

A live demo is at easy-pdf.herokuapp.com. You can run it locally after installing dependencies by running python demo.py script from the cloned repository or through Docker with make demo.

Dependencies

django-easy-pdf depends on:

  • django>=1.10

  • xhtml2pdf>=0.2b1

  • reportlab

License

django-easy-pdf is released under the MIT license.

Other Resources

Commercial Support

This app and many other help us build better software and focus on delivering quality projects faster. We would love to help you with your next project so get in touch by dropping an email at en@ig.ma.

History

0.1.1 (2017-04-19)

  • Update for Django 1.11 and Python 3

0.1.0 (2014-01-24)

  • First release

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

django3-easy-pdf-0.1.2.dev1.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django3_easy_pdf-0.1.2.dev1-py2.py3-none-any.whl (9.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django3-easy-pdf-0.1.2.dev1.tar.gz.

File metadata

  • Download URL: django3-easy-pdf-0.1.2.dev1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.3rc1

File hashes

Hashes for django3-easy-pdf-0.1.2.dev1.tar.gz
Algorithm Hash digest
SHA256 ca5806dd758098175a0b9050b371de14108b9cabe13a11bf1b550fbc41059af4
MD5 96fa446e62e632066edb3a7315a4f432
BLAKE2b-256 1e8e44cf600754e1e05d9795a7e790d67b146610a8e3c8e17d85e116ec07caef

See more details on using hashes here.

File details

Details for the file django3_easy_pdf-0.1.2.dev1-py2.py3-none-any.whl.

File metadata

  • Download URL: django3_easy_pdf-0.1.2.dev1-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.3rc1

File hashes

Hashes for django3_easy_pdf-0.1.2.dev1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7d68ad86df25de024aa653e34f86553bc0b14323b40cb0de434e6e1743cb7b1d
MD5 cc7acc7cb625d8e7147a434e7bace77d
BLAKE2b-256 8e1293715b26d686e8f1c14c08dbfb58569c1f900e340c873ed4b676479eebf4

See more details on using hashes here.

Supported by

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