• Stars
    star
    363
  • Rank 117,374 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 11 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PDF views, the easy way

Django PDF rendering

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 #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 [email protected].

More Repositories

1

pywt

We're moving. Please visit https://github.com/PyWavelets
C
167
star
2

django-easy-pjax

Easy PJAX for Django
JavaScript
145
star
3

heroku-django-cookbook

Collection of snippets that solve certain problems while deploying Django apps to Heroku
128
star
4

StackScripts

A bunch of StackScripts that I use to easily deploy full web+db+django stack at Linode.com
Shell
82
star
5

django-session-activity

List recent account activity and sign-out from all sessions opened on other computers
Python
63
star
6

django-modern-template

Modern Django project template
JavaScript
44
star
7

django-herokuify

Automatic Django configuration and utilities for Heroku
Python
38
star
8

django-request-id

X-Request-Id logging
Python
33
star
9

dj-cmd

Tired of typing `python manage.py runserver`?
Python
26
star
10

django-infinite-pagination

Efficiently paginate large object collections
Python
26
star
11

django-twilio-sms

Twilio integration for SMS-based Django apps
Python
14
star
12

web-screenshots

Sample Flask web app for taking web page screenshots using Selenium PhantomJS driver. Runs on Heroku.
Python
12
star
13

django-common-configs

Convention over configuration. Common settings for Django projects.
Python
10
star
14

jquery-expandme

Small jQuery plugin for expanding images and other content in articles.
JavaScript
5
star
15

sentry-on-dotcloud

Sentry realtime event logging deployment on DotCloud
Python
3
star
16

heroku-centrifuge

Python Centrifuge deployment on Heroku
2
star
17

ai-class-chrome-extension

Chrome Browser Extension for AI Class Forum
JavaScript
2
star
18

djutil

Common django utilities
Python
2
star
19

celery-worker-deadlock-debug

Debugging celery worker hangs and crashes - https://github.com/celery/celery/issues/3898
Python
1
star