lanshark-django-xhtml2pdf
Attention
This is a fork of the https://github.com/xhtml2pdf/django-xhtml2pdf project.
This project is wrapper code between the django project and the xhtml2pdf project, both have a few maintaining so maybe are not ideal for your project.
What it does is simply allow people to create xhtml2pdf templates using all the cool django things like STATIC_URL etc.. (like one would for a webpage template), and the utils function makes all the images and resources appear in the pdf.
This release (0.0.7) supports Django 2.0, and Python 3.6.
NOTE:
While this project is being maintained on a limited basis for legacy projects, we recommend strongly that new projects consider using WeasyPrint <https://weasyprint.org>.
Usage
Simply do the following:
from django_xhtml2pdf.utils import generate_pdf
def myview(response):
resp = HttpResponse(content_type='application/pdf')
result = generate_pdf('my_template.html', file_object=resp)
return result
Class-based views
You can use the provided PdfMixin with any view that subclasses TemplateView, example:
from django.views.generic.detail import DetailView
from django_xhtml2pdf.views import PdfMixin
from .models import Product
class ProductPdfView(PdfMixin, DetailView):
model = Product
template_name = "product_pdf.html"
It will output the rendered content of the view in pdf.
Decorator
Simply do the following:
from django_xhtml2pdf.utils import pdf_decorator
@pdf_decorator
def myview(request):
return render(request, 'mytemplate.html')
Change the pdf file name:
from django_xhtml2pdf.utils import pdf_decorator
@pdf_decorator(pdfname='new_filename.pdf')
def myview(request):
return render(request, 'mytemplate.html')
Metadata
Release files for lanshark-django-xhtml2pdf 0.0.7
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 | |
|---|---|---|---|---|
| lanshark-django-xhtml2pdf-0.0.7.tar.gz | 45.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lanshark_django_xhtml2pdf-0.0.7-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 51.1 kB
Release files / lanshark-django-xhtml2pdf-0.0.7.tar.gz
| Download URL | lanshark-django-xhtml2pdf-0.0.7.tar.gz |
|---|---|
| Size | 45.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3954fc1bb454aef1b4430d9dbbdb71476e8ea17aa7f0c41faf6cf7405ec7dd15
|
|
BLAKE2b-256 checksum How to use checksums |
96906b70c4cbd0d19aaacad91d3f6fc94bfeb33840f8617b8c1bd9169d7c14bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1
|
Release files / lanshark_django_xhtml2pdf-0.0.7-py2.py3-none-any.whl
| Download URL | lanshark_django_xhtml2pdf-0.0.7-py2.py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
1d4a3bb1a2286bb4fc5d79f3fece4d89d5e2064dff663d53982c988afe4a67cb
|
|
BLAKE2b-256 checksum How to use checksums |
644edbf069c25119c1019ebbc564ebd8afef1c0cca970722b2946987a0f76b9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1
|
Security for lanshark-django-xhtml2pdf 0.0.7
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.