==================
A simple django app that takes the pain out of rendering PDFs from django views.
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, you can now start using it in your django views like so and rendering PDFs!
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)
# If you want to change default format and orientation for this view
# return render_to_pdf(request, basename, format='A3', orientation='portrait')
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.
PHANTOMJS_FORMAT = Page size to use
PHANTOMJS_ORIENTATION = How the page will be positioned when printing.
Metadata
Release files for django-phantom-pdf 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-phantom-pdf-0.3.tar.gz | 8.2 kB | Without provenance | Details for django-phantom-pdf-0.3.tar.gz |
Release files / django-phantom-pdf-0.3.tar.gz
| Download URL | django-phantom-pdf-0.3.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
54237e55c728765623c33f9d8c394653d2bbc48d6ed4cbfa8481610a5eab21a6
|
|
BLAKE2b-256 checksum How to use checksums |
3ceb5c536d1d650032db2dffd6fa1a7c7c4b877fd2a5b02bd0fcbd77e096d1d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-phantom-pdf 0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.