[](https://readthedocs.org/projects/drf-pdf/?badge=latest)
[](https://travis-ci.org/drgarcia1986/drf-pdf)
[](https://coveralls.io/r/drgarcia1986/drf-pdf)
[](https://landscape.io/github/drgarcia1986/drf-pdf/master)
A simple PDF utils for Django Rest Framework
## Install
```
pip install drf-pdf
```
## Example
```python
# coding: utf - 8
from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
from drf_pdf.renderer import PDFRenderer
from my_pdf_package import PDFGenerator
class PDFHandler(APIView):
renderer_classes = (PDFRenderer, )
def get(self, request):
pdf = PDFGenerator('foo')
headers = {
'Content-Disposition': 'filename="foo.pdf"',
'Content-Length': len(pdf),
}
return Response(
pdf,
headers=headers,
status=status.HTTP_200_OK
)
```
### With two or more renderer_classes
```python
# coding: utf - 8
from rest_framework import status
from rest_framework.response import Response
from rest_framework.renderers import JSONRenderer
from rest_framework.views import APIView
from drf_pdf.response import PDFResponse
from drf_pdf.renderer import PDFRenderer
from my_pdf_package import get_pdf
class PDFHandler(APIView):
renderer_classes = (PDFRenderer, JSONRenderer)
def get(self, request, pdf_id):
pdf = get_pdf(pdf_id)
if not pdf:
return Response(
{'error': 'Not found'},
status=status.HTTP_404_NOT_FOUND
)
return PDFResponse(
pdf=pdf,
file_name=pdf_id,
status=status.HTTP_200_OK
)
```
Metadata
Release files for drf-pdf 0.2.0
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 |
|---|---|---|---|---|
| drf-pdf-0.2.0.tar.gz | 4.5 kB | Without provenance | Details for drf-pdf-0.2.0.tar.gz |
Release files / drf-pdf-0.2.0.tar.gz
| Download URL | drf-pdf-0.2.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4e870bff87d19f43fa0bb85f8112ab0588db0c7bb00656f1ec52120d19ac4b2a
|
|
BLAKE2b-256 checksum How to use checksums |
007565c7f9120e197e142ae0f65aa6d5fecb649a349a1ea36e2ba20db6cb90bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for drf-pdf 0.2.0
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.