Skip to main content

WebSite2PDF Logo
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

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",
])

Metadata

Release files for website2pdf 0.1.1

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

Source distribution (sdist)

Source distribution for website2pdf 0.1.1
File Size Uploaded
WebSite2PDF-0.1.1.tar.gz 18.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for website2pdf 0.1.1
File Interpreter ABI Platform
WebSite2PDF-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 37.4 kB

Release files / WebSite2PDF-0.1.1.tar.gz

Download URL WebSite2PDF-0.1.1.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
43ab867dbc12b4bcff86be755e960e3217e44e1a6afe9d9539446489a498536a
BLAKE2b-256 checksum
How to use checksums
614a0a0f04bc26f3444a6757ad768c54f724c719b40a726486a12afe3312ae57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / WebSite2PDF-0.1.1-py3-none-any.whl

Download URL WebSite2PDF-0.1.1-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f402790eaff074a105bdb336a61671564074adea3538c496439043238a6be864
BLAKE2b-256 checksum
How to use checksums
dd0df3f53f8365d1e20d339f1bf1e1e19c5bca9d6e3b3d746c74b12564b06008
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release history Release notifications | RSS feed

1.0.0

2 release files

This release

0.1.1 This release

2 release files

0.1.0

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