Convert HTML to pdf with django using nightmarejs
Project description
django-nightmare-pdf
Convert HTML to pdf with django using nightmare
Requirements
Python (2.7) (Need to be tested for 3.x)
Django (1.10) (Need to be tested for previous versions)
Dependencies
This django app depends on Nightmare, you need to first install it using npm:
npm install nightmare
Installation
Install using pip :
pip install nightmare_pdf
Add nightmare_pdf to your INSTALLED_APPS setting.
INSTALLED_APPS = ( ... 'nightmare_pdf', )
Usage
Generate a pdf from an url and save it to database, or retrieve it as a ContentFile, or return it inside an HttpResponse :
from nightmare_pdf.generators import PDFGenerator pdf = PDFGenerator(url="https://github.com/charlesthk/django-nightmare-pdf", # Save it to database and retrieve a PdfDoc Object (database): pdf.save( filename='nightmare_pdf', title="nightmare_pdf on github", description="Convert HTML to pdf with django using nightmare") # Get the PDf as a Django ContentFiel : pdf_content_file = pdf.get_content_file('nightmare_pdf') # Return a Django HttpResponse with the PDF Attached : return pdf.get_http_response('nightmare_pdf')
Support
If you are having issues, please let us know or submit a pull request.
License
The project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for nightmare_pdf-0.0.5-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b62d6f187afbabdb04a5e9aaa95d0aca24dcea7af78d21b5e0811810e2307245 |
|
MD5 | 53649183163b5f601023e58701007fb1 |
|
BLAKE2b-256 | f46d1f159c2fe4ca372a89bd6a3c1b1ab40607d2deddf25cbc7466cb385fc13b |