Skip to main content

html2pdf

A simple python wrapper for wkhtmltopdf forked from python-wkhtmltopdf

Requirements

System:

  • Linux 32/64 or OSX only (Windows is not supported at this stage)

  • Xvfd

  • wkhtmltopdf

  • python 2.5+

Installation

wkhtmltopdf (Linux)

  1. Install Xvfd:

    $ sudo apt-get install xvfb
  2. Install Fonts:

    $ sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic
  3. Install wkhtmltopdf:

    $ sudo apt-get install wkhtmltopdf

wkhtmltopdf (OSX)

  1. Install wkhtmltopdf:

    $ brew install wkhtmltopdf

python-wkhtmltopdf (Any Platform)

  1. Development:

    $ git clone https://bitbucket.org/luisfernando/html2pdf.git
    $ cd html2pdf
    $ virtualenv .
    $ pip install -r requirements.pip
  2. PIP:

    $ pip install git+https://bitbucket.org/luisfernando/html2pdf.git
    
    or from pypi
    
    $ pip install html2pdf

Usage

Simple Usage::

  1. Render a URL:

    from wkhtmltopdf import HTMLURLToPDF
    
    make_pdf = HTMLURLToPDF(
        url='http://www.example.com',
        output_file='~/example.pdf',
    )
    make_pdf.render()
  2. Render a HTML string:

    from html2pdf import HTMLToPDF
    
    HTML = """
        <!DOCTYPE html>
        <html>
            <body>
            <h1>Hello World</h1>
            </body>
        </html>
    """
    
    h = HTMLToPDF(HTML, self.output_file)

Required Arguments:

  • url - the url to convert to pdf

  • output_file - the pdf file that you want to create

Optional Arguments:

  • enable-plugins (default: True)

  • disable-javascript (default: False)

  • no-background (default: False)

  • grayscale (default: False)

  • orientation (default: Portrait)

  • dpi (default: 100)

  • username (default: None)

  • password (default: None)

  • margin-bottom (default: 10)

  • margin-top (default: 10)

  • margin-left (default: 10)

  • margin-right (default: 10)

  • disable-smart-shrinking (default: False)

Authors:

Forked from wkhtmltopdf - Jonathan Bydendyk (jpbydendyk@gmail.com)

Metadata

Release files for html2pdf 0.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 html2pdf 0.1
File Size Uploaded Provenance
html2pdf-0.1.tar.gz 5.1 kB Without provenance Details

Release files / html2pdf-0.1.tar.gz

Download URL html2pdf-0.1.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a8876811688017c24636f36b90cadd423c9c324882b5a8369e1bf2a7b2181657
BLAKE2b-256 checksum
How to use checksums
3993171be713822899173eb02698ab7a45fd3511588d34c81e648503ef19ff2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for html2pdf 0.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.

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file No provenance

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