Skip to main content

A simple django app that let you render(create) pdf files from given views.

Project description

==================
DJANGO PHANTOM JS
==================

A simpla django package for rendering a django template to a PDF.

Quick start
-----------

1. Install node and phantomjs:

### On Mac OSX:

brew install node npm
npm install -g phantomjs

### On Ubuntu:

apt-get install node npm
sudo npm install -g phantomjs

2. Install django-phantom-pdf:

pip install django-phantom-pdf

3. That's it, now you can start using in your django views like so:

from phantom_pdf import render_to_pdf
from django.http import HttpResponse

def home(request):
# If 'print=pdf' in GET params, then render the PDF!
if request.GET.get("print", None) == "pdf":
basename = 'output' # `.pdf` will be appended to this string.
return render_to_pdf(request, basename)
else:
return HttpResponse("Hello World!")

Advanced Use
------------

For more advanced use and control, you can set the following variables in your setting.
They are already set to sane defaults, so it's not necessary unless you are looking for
more fine grained control.

PHANTOMJS_COOKIE_DIR = Directory where the temp cookies will be saved.
PHANTOMJS_PDF_DIR = Directory where you want to the PDF to be saved temporarily.
PHANTOMJS_BIN = Path to PhantomsJS binary.
PHANTOMJS_GENERATE_PDF = Path to generate_pdf.js file.
keep_pdf_files = Option to not delete the PDF file after rendering it.

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

django-phantom-pdf-0.1.tar.gz (6.0 kB view details)

Uploaded Source

File details

Details for the file django-phantom-pdf-0.1.tar.gz.

File metadata

File hashes

Hashes for django-phantom-pdf-0.1.tar.gz
Algorithm Hash digest
SHA256 2703a4190df8f6f4fdb5cdb90ea49753980a08a6e14385ffdd89b22ad19ef698
MD5 1f68d0ef93c62a0ace87bfc8755efed9
BLAKE2b-256 117ed3d3db79801d1bf28d724a71f6a88a797f5fea638ab0fcd6334eab614f77

See more details on using hashes here.

Provenance

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