Skip to main content

Pdfy

DOI

Pdfy is a Python library for converting HTML (and anything Chrome can render) into PDF. It uses Chrome printing functionality, so the PDFs will be rendered exactly as printed in the browser.

Installation

To install the library, you need to run.

pip install pdfy

Additionally, you will need to install Chrome Driver.

Usage

Using the library is as easy as:

from pdfy import Pdfy
p = Pdfy()
p.html_to_pdf("html_file.htm", pdf_path="pdf_file.pdf")

More control over the PDF layout

If you need to have more control over the layout, you can pass additional parameters to html_to_pdf

options = {"paperWidth": 8.3, "paperHeight":11.7}
p.html_to_pdf("html_file.htm", pdf_path="pdf_file.pdf" options=options)

The full list of parameters is available on Chrome's Developer site.

Not saving the PDF

In the absence of the pdf_path argument, the html_to_pdf function will return the PDF as a base64 encoded string.

pdf = p.html_to_pdf("html_file.htm")

Multiple instances

The library will run Chrome in the background in the remote debug mode. This means that if your project requires multiple initialized Pdfy objects, you might need to change the port used for debugging. This can be done by passing the port number to Pdfy() as follows:

p = Pdfy(debug_port=9222) #9222 is the default port

Credits

This library is released under the Apache 2.0 License.

(C) Copyright 2018-2024 Mika Hämäläinen

Cite

@software{mika_hamalainen_2020_4108770,
  author       = {Mika Hämäläinen and
                  Hiromu Hota and
                  Mike and
                  Mirza Delic},
  title        = {mikahama/pdfy 1.0.50},
  month        = oct,
  year         = 2020,
  publisher    = {Zenodo},
  version      = {1.0.50},
  doi          = {10.5281/zenodo.4108770},
  url          = {https://doi.org/10.5281/zenodo.4108770}
}

Metadata

Release files for pdfy 1.2.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 pdfy 1.2.1
File Size Uploaded Provenance Actions
pdfy-1.2.1.tar.gz 6.5 kB Without provenance Details for pdfy-1.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pdfy 1.2.1
File Interpreter ABI Platform Actions
pdfy-1.2.1-py3-none-any.whl Python 3 none any Details for pdfy-1.2.1-py3-none-any.whl

Total release size: 13.7 kB

Release files / pdfy-1.2.1.tar.gz

Download URL pdfy-1.2.1.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9e8d44d341d8ae404f0c91b7b68d73c5ca6f2473df634ab2c5a988c15467936a
BLAKE2b-256 checksum
How to use checksums
0fd5c55f8a9f093d167e3ddeb94aa97861b64fdd2b515467563333bc3684b78d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.3

Release files / pdfy-1.2.1-py3-none-any.whl

Download URL pdfy-1.2.1-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e43d97d2ed77ffe499f7f6b4b98afe87e7df7f2a8229f3ab924283ea781a2437
BLAKE2b-256 checksum
How to use checksums
d5d81ff22b7639b88bb001e0d7509fb8506e0c44113d934d920c9f3accef9946
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.3

Security for pdfy 1.2.1

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