Skip to main content

django-selenium-pdfmaker

A Light Django Application which uses selenium to convert any html page to pdf. Using this approach you can easily make pdf of HTML pages with charts, tables and having their loaded Styles.

Install

Install easily via pip:

pip install django-selenium-pdfmaker

Then add package name django_selenium_pdfmaker to the INSTALLED_APPS of django.

Usage

To use this module:

from django_selenium_pdfmaker.modules import PDFMaker
pdfmaker = PDFMaker()
res = pdfmaker.get_pdf_from_html(url='https://google.com', filename='output', write=True)

and res includes:

{
  "status": true,
  "raw": "pdf in binary format",
  "pdf": "ConvertedPDF instance if write flag is True.",
  "message": ""
}
  • status is true when converting to pdf is successful, else will be false. For example when url path is unreachable status will be false.
  • raw is binary data of pdf before storing in file. Will hold data if status == true
  • pdf is ConvertedPDF object if status is true.
  • message will hold reason why status is false.

Settings

CHROMEDRIVER_PATH

Override this variable to address the binary file of chromedriver of your own.

SELENIUM_DELAY

To set delay on selenium requests (default 3). it will last that amount of time crawling requested page before closing the session and create pdf of it.

Installation Chrome

Be noted to use this package google-chrome in your os. To install on ubuntu use following commads:

sudo curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add 
sudo bash -c "echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' >> /etc/apt/sources.list.d/google-chrome.list" 
sudo apt -y update 
sudo apt -y install google-chrome-stable 

Exceptions

1- Message: session not created: This version of ChromeDriver only supports Chrome version 90 Current browser version is 103.0.5060.53 with binary path /usr/bin/google-chrome

If you faced a problem like this, you should address the correct chromedriver binary in your codes. To do that download the proper chromedriver version and place in your OS. Then address it with following option in your settings.py file:

CHROMEDRIVER_PATH = '/usr/bin/chromedriver'

Also you can use below script to automatically fix this problem:

pip install webdriver-manager

Then use the driver in python as follows

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())

You can find the solution link

Metadata

Release files for django-selenium-pdfmaker 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-selenium-pdfmaker 0.0.5
File Size Uploaded Provenance Actions
django-selenium-pdfmaker-0.0.5.tar.gz 19.0 kB Without provenance Details for django-selenium-pdfmaker-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-selenium-pdfmaker 0.0.5
File Interpreter ABI Platform Actions
django_selenium_pdfmaker-0.0.5-py3-none-any.whl Python 3 none any Details for django_selenium_pdfmaker-0.0.5-py3-none-any.whl

Total release size: 49.1 kB

Release files / django-selenium-pdfmaker-0.0.5.tar.gz

Download URL django-selenium-pdfmaker-0.0.5.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
76883106a20a706d0e70577b6a1c754a115835f1d3b7399fdcec6b0c7fb9a75d
BLAKE2b-256 checksum
How to use checksums
c0b82cb5b771f77f41e7c1e57a184f4aa74b778e2bc9326ecd79e700095774d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / django_selenium_pdfmaker-0.0.5-py3-none-any.whl

Download URL django_selenium_pdfmaker-0.0.5-py3-none-any.whl
Size 30.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab53d86d502ef29f4582131772bb22901ef195f4f7609597c9cbebf97ce79515
BLAKE2b-256 checksum
How to use checksums
b2741ad4a111b767fc028363fa8808b348694a44c6646741747ce8e61a4dd0fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Security for django-selenium-pdfmaker 0.0.5

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page