Attention
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.
Please get in touch if you would like to take over maintainership.
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 ressources appear in the pdf.
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 de 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 django-xhtml2pdf 0.0.4
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-xhtml2pdf-0.0.4.tar.gz | 4.7 kB | Without provenance | Details for django-xhtml2pdf-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_xhtml2pdf-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for django_xhtml2pdf-0.0.4-py3-none-any.whl |
Total release size: 11.0 kB
Release files / django-xhtml2pdf-0.0.4.tar.gz
| Download URL | django-xhtml2pdf-0.0.4.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e91f4ea6033fb0eb9ae3869fe764df3c756c22897b526587aef008fb04d69871
|
|
BLAKE2b-256 checksum How to use checksums |
11966828e583a56884bc5661a46afcbf9f67b5badb9b4fd55277d843c7d358d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_xhtml2pdf-0.0.4-py3-none-any.whl
| Download URL | django_xhtml2pdf-0.0.4-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
84595fd7f242efffc1682eaf6646f237cb4823cda14e81b9cd642f6c790edd4e
|
|
BLAKE2b-256 checksum How to use checksums |
08ff92fc2d8e6e8bbd93237cc57c3a25ddea8ff016de31f5e488f1b2dfd29f46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-xhtml2pdf 0.0.4
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.