Name | pdfy JSON |
Version |
1.2.1
JSON |
| download |
home_page | https://github.com/mikahama/pdfy |
Summary | A library for converting HTML files into PDF. The tool uses Chrome to render the HTML and print it into a pdf file. |
upload_time | 2024-08-10 15:27:45 |
maintainer | None |
docs_url | None |
author | Mika Hämäläinen |
requires_python | None |
license | None |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Pdfy #
[](https://doi.org/10.5281/zenodo.4108770)
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](http://chromedriver.chromium.org/getting-started).
## 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](https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF).
### 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](https://opensource.org/licenses/Apache-2.0).
(C) Copyright 2018-2024 [Mika Hämäläinen](https://mikakalevi.com)
## 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}
}
Raw data
{
"_id": null,
"home_page": "https://github.com/mikahama/pdfy",
"name": "pdfy",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Mika H\u00e4m\u00e4l\u00e4inen",
"author_email": "mika@flyforpoints.com",
"download_url": "https://files.pythonhosted.org/packages/0f/d5/c55f8a9f093d167e3ddeb94aa97861b64fdd2b515467563333bc3684b78d/pdfy-1.2.1.tar.gz",
"platform": null,
"description": "# Pdfy #\n\n[](https://doi.org/10.5281/zenodo.4108770)\n\nPdfy 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.\n\n\n## Installation ##\n\nTo install the library, you need to run.\n\n pip install pdfy\n\nAdditionally, [you will need to install Chrome Driver](http://chromedriver.chromium.org/getting-started). \n\n## Usage ##\n\nUsing the library is as easy as:\n\n from pdfy import Pdfy\n p = Pdfy()\n p.html_to_pdf(\"html_file.htm\", pdf_path=\"pdf_file.pdf\")\n\n### More control over the PDF layout ###\n\nIf you need to have more control over the layout, you can pass additional parameters to html_to_pdf\n\n options = {\"paperWidth\": 8.3, \"paperHeight\":11.7}\n p.html_to_pdf(\"html_file.htm\", pdf_path=\"pdf_file.pdf\" options=options)\n\nThe full list of parameters is available on [Chrome's Developer site](https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF).\n\n### Not saving the PDF ###\n\nIn the absence of the pdf_path argument, the html_to_pdf function will return the PDF as a base64 encoded string.\n\n pdf = p.html_to_pdf(\"html_file.htm\")\n\n\n### Multiple instances ###\n\nThe 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:\n\n p = Pdfy(debug_port=9222) #9222 is the default port\n\n## Credits ##\n\nThis library is released under [the Apache 2.0 License](https://opensource.org/licenses/Apache-2.0).\n\n(C) Copyright 2018-2024 [Mika H\u00e4m\u00e4l\u00e4inen](https://mikakalevi.com)\n\n\n## Cite\n\n\t@software{mika_hamalainen_2020_4108770,\n\t author = {Mika H\u00e4m\u00e4l\u00e4inen and\n\t Hiromu Hota and\n\t Mike and\n\t Mirza Delic},\n\t title = {mikahama/pdfy 1.0.50},\n\t month = oct,\n\t year = 2020,\n\t publisher = {Zenodo},\n\t version = {1.0.50},\n\t doi = {10.5281/zenodo.4108770},\n\t url = {https://doi.org/10.5281/zenodo.4108770}\n\t}\n",
"bugtrack_url": null,
"license": null,
"summary": "A library for converting HTML files into PDF. The tool uses Chrome to render the HTML and print it into a pdf file.",
"version": "1.2.1",
"project_urls": {
"Homepage": "https://github.com/mikahama/pdfy"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d5d81ff22b7639b88bb001e0d7509fb8506e0c44113d934d920c9f3accef9946",
"md5": "dc8b1334f691016389882bf789c95403",
"sha256": "e43d97d2ed77ffe499f7f6b4b98afe87e7df7f2a8229f3ab924283ea781a2437"
},
"downloads": -1,
"filename": "pdfy-1.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "dc8b1334f691016389882bf789c95403",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7234,
"upload_time": "2024-08-10T15:27:44",
"upload_time_iso_8601": "2024-08-10T15:27:44.173232Z",
"url": "https://files.pythonhosted.org/packages/d5/d8/1ff22b7639b88bb001e0d7509fb8506e0c44113d934d920c9f3accef9946/pdfy-1.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0fd5c55f8a9f093d167e3ddeb94aa97861b64fdd2b515467563333bc3684b78d",
"md5": "e9764927ca7554e7942d0ff97580bbdf",
"sha256": "9e8d44d341d8ae404f0c91b7b68d73c5ca6f2473df634ab2c5a988c15467936a"
},
"downloads": -1,
"filename": "pdfy-1.2.1.tar.gz",
"has_sig": false,
"md5_digest": "e9764927ca7554e7942d0ff97580bbdf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6502,
"upload_time": "2024-08-10T15:27:45",
"upload_time_iso_8601": "2024-08-10T15:27:45.640934Z",
"url": "https://files.pythonhosted.org/packages/0f/d5/c55f8a9f093d167e3ddeb94aa97861b64fdd2b515467563333bc3684b78d/pdfy-1.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-10 15:27:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mikahama",
"github_project": "pdfy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pdfy"
}