Simple and Fast Python framework to convert HTML files or Web Site to PDF
Project description
Examples
•
Documentation
•
PyPi
•
News
•
Chat
WebSite2PDF
Simple and Fast Python framework to convert HTML files or Web Site to PDF
Installing with pip
pip3 install WebSite2PDF
or
pip3 install git+https://github.com/uNickz/WebSite2PDF
Installing with python
python3 -m pip install WebSite2PDF
or
python3 -m pip install git+https://github.com/uNickz/WebSite2PDF
Dependencies
- Selenium Chrome WebDriver (If Chrome is installed on the machine you won't need to install the chrome driver)
Example
Using a url
import WebSite2PDF
url = "https://pypi.org"
c = WebSite2PDF.Client()
with open("file_name.pdf", "wb+") as file:
file.write(c.pdf(url))
or
import WebSite2PDF
url = "https://pypi.org"
c = WebSite2PDF.Client()
c.pdf(url, filename = "file_name.pdf")
Using a file HTML
import WebSite2PDF
file_path = "C:\Users\uNickz\index.html"
c = WebSite2PDF.Client()
with open("file_name.pdf", "wb+") as file:
file.write(c.pdf(f"file:///{file_path}"))
or
import WebSite2PDF
file_path = "C:\Users\uNickz\index.html"
c = WebSite2PDF.Client()
c.pdf(f"file:///{file_path}", filename = "file_name.pdf")
Using multiple urls or files HTML
import WebSite2PDF
urls_or_path = ["https://pypi.org", "file:///C:\Users\uNickz\index.html", "https://github.com/"]
c = WebSite2PDF.Client()
c.pdf(urls_or_path, filename = ["pypi.pdf", "index.pdf", "github.pdf"])
or
import WebSite2PDF
urls_or_path = ["https://pypi.org", "file:///C:\Users\uNickz\index.html", "https://github.com/"]
file_name = ["pypi.pdf", "index.pdf", "github.pdf"]
c = WebSite2PDF.Client()
data = c.pdf(urls_or_path)
for name, data in zip(name, data):
with open(name, "wb+") as file:
file.write(data)
Using a delay (in seconds) before create PDF
import WebSite2PDF
url = "https://pypi.org"
c = WebSite2PDF.Client()
c.pdf(url, filename = "file_name.pdf", delay = 3)
Using global PDF Options
import WebSite2PDF
url = "https://pypi.org"
c = WebSite2PDF.Client(
pdfOptions = {
"landscape" = True,
"displayHeaderFooter": True,
"printBackground": True,
"preferCSSPageSize": True,
}
)
c.pdf(url, filename = "file_name.pdf")
Using specific PDF Options for a PDF
import WebSite2PDF
url = "https://pypi.org"
c = WebSite2PDF.Client(
pdfOptions = {
"landscape" = True,
"displayHeaderFooter": True,
"printBackground": True,
"preferCSSPageSize": True,
}
)
c.pdf(url, filename = "file_name.pdf", pdfOptions = {
"landscape" = False,
"displayHeaderFooter": True,
})
Using global Selenium ChromeDriver Options
import WebSite2PDF
url = "https://pypi.org"
c = WebSite2PDF.Client(
pdfOptions = {
"landscape" = True,
"displayHeaderFooter": True,
"printBackground": True,
"preferCSSPageSize": True,
}, seleniumOptions = [
"--no-sandbox",
"--headless",
]
)
c.pdf(url, filename = "file_name.pdf")
Using specific Selenium ChromeDriver Options for a PDF
import WebSite2PDF
url = "https://pypi.org"
c = WebSite2PDF.Client(
pdfOptions = {
"landscape" = True,
"displayHeaderFooter": True,
"printBackground": True,
"preferCSSPageSize": True,
}, seleniumOptions = [
"--no-sandbox",
"--headless",
]
)
c.pdf(url, filename = "file_name.pdf", pdfOptions = {
"landscape" = False,
"displayHeaderFooter": True,
}, seleniumOptions = [
"--no-sandbox",
"--disable-gpu",
])
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
WebSite2PDF-0.1.1.tar.gz
(18.8 kB
view details)
Built Distribution
File details
Details for the file WebSite2PDF-0.1.1.tar.gz
.
File metadata
- Download URL: WebSite2PDF-0.1.1.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43ab867dbc12b4bcff86be755e960e3217e44e1a6afe9d9539446489a498536a |
|
MD5 | 9a579c2f770bed82adb6395f45287387 |
|
BLAKE2b-256 | 614a0a0f04bc26f3444a6757ad768c54f724c719b40a726486a12afe3312ae57 |
File details
Details for the file WebSite2PDF-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: WebSite2PDF-0.1.1-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f402790eaff074a105bdb336a61671564074adea3538c496439043238a6be864 |
|
MD5 | b8ad4a9fce347986b3d424bf7516924e |
|
BLAKE2b-256 | dd0df3f53f8365d1e20d339f1bf1e1e19c5bca9d6e3b3d746c74b12564b06008 |