Skip to main content

Convert HTML to pdf with django using nightmarejs

Project description

|nightmare\_pdf v2.0.3 on PyPi| |MIT license| |Stable|

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 <https://github.com/segmentio/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 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.

.. |nightmare\_pdf v2.0.3 on PyPi| image:: https://img.shields.io/badge/pypi-0.0.1-green.svg
:target: https://pypi.python.org/pypi/nightmare_pdf
.. |MIT license| image:: https://img.shields.io/badge/licence-MIT-blue.svg
.. |Stable| image:: https://img.shields.io/badge/status-stable-green.svg

Project details


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

nightmare_pdf-0.0.1-py2.py3-none-any.whl (8.9 kB view hashes)

Uploaded Python 2 Python 3

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