Convert template html to pdf
Project description
HTML TO PDF
Convert template html to pdf
Detailed documentation is in the "docs" directory.
Quick start
-
Install the module:
pip install htmlToPdf
-
EXAMPLE
Import module
from htmltopdfy.job import htmlToPdf
Let suppose we have a model like this:
class User(): name = models.CharField(max_length=200) age = models.CharField(max_length=20) cni = models.FileField(null=True,blank=True)
Let's create user
user = User(name="dddd",age=23, document) user.save()
We supposed we have a template named cni.html already designed on which we want to display name and age
cni_file = htmlToPdf ( media_root_url=settings.MEDIA_ROOT, file_name="cni", template_src = "cni.html", context_dict = {"name":"dddd","age":"20ans"} ) user.cni.save("cni.pdf",cni_file)
After you can print variable cni in console to see result or send url file on your response view:
print(user.cni)
or
return Response({"cni":user.cni.url})
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 Distribution
htmltopdfy-1.0.0.tar.gz
(2.9 kB
view hashes)
Built Distribution
Close
Hashes for htmltopdfy-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b515d6493bc1e548a1876f9812a669e3a1a6236b6d00a8e369d68433bbab2bc6 |
|
MD5 | 5bb5fc3158f98103201021992688a581 |
|
BLAKE2b-256 | e5530a11f771fb53e99a6fe453874460a2a6bb1ea1b11a4af27006279a9e7630 |