Skip to main content

build docs license downloads pypi pyver

PlutoPrint

PlutoPrint is a lightweight and easy-to-use Python library for generating high-quality PDFs and images directly from HTML or XML content. It is based on PlutoBook’s robust rendering engine and provides a simple API to convert your HTML into crisp PDF documents or vibrant image files. This makes it ideal for reports, invoices, or visual snapshots.

Invoices

Tickets

Invoices

Tickets

Installation

pip install plutoprint

PlutoPrint requires PlutoBook. On Windows (win_amd64), Linux (manylinux_2_28_x86_64) and macOS (macosx_14_0_arm64), prebuilt binaries are bundled with the package and no further steps are necessary. On other architectures or when building from source, see the Getting Started guide for dependency setup and build instructions.

On macOS and Linux, you can also install PlutoPrint using Homebrew:

brew update
brew install plutoprint

Quick Usage

Generate a PDF from the command line with the installed plutoprint script:

plutoprint input.html output.pdf --size=A4

Generate PDF with Python

import plutoprint

book = plutoprint.Book(plutoprint.PAGE_SIZE_A4)
book.load_url("hello.html")

# Export the entire document to PDF
book.write_to_pdf("hello.pdf")

# Export pages 2 to 15 (inclusive) in order
book.write_to_pdf("hello-range.pdf", 2, 15, 1)

# Export pages 15 to 2 (inclusive) in reverse order
book.write_to_pdf("hello-reverse.pdf", 15, 2, -1)

# Render pages manually with PDFCanvas (in reverse order)
with plutoprint.PDFCanvas("hello-canvas.pdf", book.get_page_size()) as canvas:
   canvas.scale(plutoprint.UNITS_PX, plutoprint.UNITS_PX)
   for page_index in range(book.get_page_count() - 1, -1, -1):
      canvas.set_size(book.get_page_size_at(page_index))
      book.render_page(canvas, page_index)
      canvas.show_page()

Generate PNG with Python

import plutoprint
import math

book = plutoprint.Book(media=plutoprint.MEDIA_TYPE_SCREEN)
book.load_html("<b>Hello World</b>", user_style="body { text-align: center }")

# Outputs an image at the document’s natural size
book.write_to_png("hello.png")

# Outputs a 320px wide image with auto-scaled height
book.write_to_png("hello-width.png", width=320)

# Outputs a 240px tall image with auto-scaled width
book.write_to_png("hello-height.png", height=240)

# Outputs an 800×200 pixels image (may stretch/squish content)
book.write_to_png("hello-fixed.png", 800, 200)

# Get the natural document size
width = math.ceil(book.get_document_width())
height = math.ceil(book.get_document_height())

# Outputs a high-resolution 5x scaled image
book.write_to_png("hello-scaled.png", width * 5, height * 5)

# Render manually on a canvas with white background
with plutoprint.ImageCanvas(width, height) as canvas:
   canvas.clear_surface(1, 1, 1)
   book.render_document(canvas)
   canvas.write_to_png("hello-canvas.png")

Generate QR Codes

Quick example of using -pluto-qrcode(<string>[, <color>]) to create QR codes with optional colors.

import plutoprint

HTML_CONTENT = """
<table>
  <tr>
    <th class="email">Email</th>
    <th class="tel">Tel</th>
  </tr>
  <tr>
    <th class="website">Website</th>
    <th class="github">GitHub</th>
  </tr>
</table>
"""

USER_STYLE = """
body {
  margin: 0;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f7f7f7;
  font: 16px Arial;
}

table {
  border-spacing: 2rem;
  background: #fff;
  padding: 2rem;
  border: 1px solid #ccc;
  border-radius: 16px;
}

th::before {
  display: block;
  width: 130px;
  height: 130px;
  margin: 0 auto 0.8rem;
}

.email::before   { content: -pluto-qrcode('mailto:contact@example.com', #16a34a); }
.tel::before     { content: -pluto-qrcode('tel:+1234567890', #2563eb); }
.website::before { content: -pluto-qrcode('https://example.com', #ef4444); }
.github::before  { content: -pluto-qrcode('https://github.com/plutoprint', #f59e0b); }
"""

book = plutoprint.Book(plutoprint.PAGE_SIZE_LETTER.landscape())
book.load_html(HTML_CONTENT, USER_STYLE)
book.write_to_png("qrcard.png")
book.write_to_pdf("qrcard.pdf")

Expected output:

QR card

Generate Charts with Matplotlib

import plutoprint

import matplotlib.pyplot as plt
import urllib.parse
import io

class CustomResourceFetcher(plutoprint.ResourceFetcher):
   def fetch_url(self, url):
      if not url.startswith('chart:'):
         return super().fetch_url(url)
      values = [float(v) for v in urllib.parse.unquote(url[6:]).split(',')]
      labels = [chr(65 + i) for i in range(len(values))]

      plt.bar(labels, values)
      plt.title('Bar Chart')
      plt.xlabel('Labels')
      plt.ylabel('Values')

      buffer = io.BytesIO()
      plt.savefig(buffer, format='svg', transparent=True)

      return plutoprint.ResourceData(buffer.getvalue(), "image/svg+xml", "utf-8")

book = plutoprint.Book(plutoprint.PAGE_SIZE_A4.landscape(), plutoprint.PAGE_MARGINS_NONE)

book.custom_resource_fetcher = CustomResourceFetcher()

HTML_CONTENT = """
<body>
  <img src='chart:23,45,12,36,28,50'>
  <img src='chart:5,15,25,35,45'>
  <img src='chart:50,40,30,20,10'>
  <img src='chart:10,20,30,40,50,60,70'>
</body>
"""

USER_STYLE = """
body {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  background: #f7f7f7;
  height: 100vh;
  margin: 0;
}

img {
  background: #fff;
  border: 1px solid #ccc;
  margin: auto;
  max-height: 45vh;
}
"""

book.load_html(HTML_CONTENT, USER_STYLE)
book.write_to_png("charts.png")
book.write_to_pdf("charts.pdf")

Expected output:

Charts

Samples

Invoices
Invoice 1 Invoice 2 Invoice 3
Tickets
Ticket 1 Ticket 2
Ticket 3 Ticket 4

Support and Contribution

This project continues to grow through the encouragement and involvement of its users. If it has been helpful to you or your team, here are a few meaningful ways you can support its future:

  • Give it a Star on GitHub. Starring the project helps others discover it and shows your appreciation for the work behind it.

  • Sponsor the project to help drive new features, improve stability, and ensure the project continues to evolve for everyone who relies on it.

  • Share your feedback. If you have suggestions, feature requests, or notice an issue, please open a GitHub issue. Your voice and experience help guide the project’s direction.

License

PlutoPrint is licensed under the MIT License, allowing for both personal and commercial use.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plutoprint-0.22.0.tar.gz (41.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

plutoprint-0.22.0-cp314-cp314-win_amd64.whl (20.2 MB view details)

Uploaded CPython 3.14Windows x86-64

plutoprint-0.22.0-cp314-cp314-manylinux_2_28_x86_64.whl (20.3 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

plutoprint-0.22.0-cp314-cp314-macosx_14_0_arm64.whl (18.3 MB view details)

Uploaded CPython 3.14macOS 14.0+ ARM64

plutoprint-0.22.0-cp313-cp313-win_amd64.whl (19.5 MB view details)

Uploaded CPython 3.13Windows x86-64

plutoprint-0.22.0-cp313-cp313-manylinux_2_28_x86_64.whl (20.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

plutoprint-0.22.0-cp313-cp313-macosx_14_0_arm64.whl (18.3 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

plutoprint-0.22.0-cp312-cp312-win_amd64.whl (19.5 MB view details)

Uploaded CPython 3.12Windows x86-64

plutoprint-0.22.0-cp312-cp312-manylinux_2_28_x86_64.whl (20.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

plutoprint-0.22.0-cp312-cp312-macosx_14_0_arm64.whl (18.3 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

plutoprint-0.22.0-cp311-cp311-win_amd64.whl (19.5 MB view details)

Uploaded CPython 3.11Windows x86-64

plutoprint-0.22.0-cp311-cp311-manylinux_2_28_x86_64.whl (20.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

plutoprint-0.22.0-cp311-cp311-macosx_14_0_arm64.whl (18.3 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

plutoprint-0.22.0-cp310-cp310-win_amd64.whl (19.5 MB view details)

Uploaded CPython 3.10Windows x86-64

plutoprint-0.22.0-cp310-cp310-manylinux_2_28_x86_64.whl (20.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

plutoprint-0.22.0-cp310-cp310-macosx_14_0_arm64.whl (18.3 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

Details for the file plutoprint-0.22.0.tar.gz.

File metadata

  • Download URL: plutoprint-0.22.0.tar.gz
  • Upload date:
  • Size: 41.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for plutoprint-0.22.0.tar.gz
Algorithm Hash digest
SHA256 3660300fe57880782f2488fddbdab19bf3e7fde6d6713a696c0c2869006dca10
MD5 d9693c140f9d2d7e12e0f4dad9c0027e
BLAKE2b-256 83d7c15fb7d9d017f09777ee8b70c04091a490e56c3b289c6a23706d62942a8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0.tar.gz:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plutoprint-0.22.0-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for plutoprint-0.22.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 df1a87163561b183625780620d60c3b4aa6547aa8775cf3290aa12b42ca83006
MD5 ac2107dfdd2bfd05c96db7da471c9129
BLAKE2b-256 899a3cc008a477a3d05909393c2bcf268a2ba8203ea5fd04d2f05311ae8bc046

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0-cp314-cp314-win_amd64.whl:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plutoprint-0.22.0-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for plutoprint-0.22.0-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 72985ef1494d6b062be14bec56d78be2d112c7b0925ccf011ab18666548b1ae0
MD5 94f404e922dcb833f166639032890b48
BLAKE2b-256 d4cb857d3a11b6a0ead4351974dd8a5cb7ce2c934eabcba8737d77ac76d7db01

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0-cp314-cp314-manylinux_2_28_x86_64.whl:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plutoprint-0.22.0-cp314-cp314-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for plutoprint-0.22.0-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 617dba010d9e72e58340c5c26b2ec7afc541a713b481d0aff424034608e92de4
MD5 d072567f9701b5a577953fd9107ad00f
BLAKE2b-256 e72082769eac4586bed2d27929111330e02110c6d13f102b3699e56c56295ed2

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0-cp314-cp314-macosx_14_0_arm64.whl:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plutoprint-0.22.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for plutoprint-0.22.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f6dd0cb3bbfe39caec61fc4e81745a9837e8e6a0a7481ca993badc72863b0e65
MD5 9b34845bdcf15e323f448d990f0aaa43
BLAKE2b-256 d7a2e79aef15cb44ce4725ba200bab21fcc7690f8967dbb4cd8df584e6c5e675

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0-cp313-cp313-win_amd64.whl:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plutoprint-0.22.0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for plutoprint-0.22.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f40c12905eb88510096cd4a0a60dc2a94f7c9c6bae8644035f2f1f3bd5c26924
MD5 d7049b5da951de554dae45f6eb26c149
BLAKE2b-256 2a02b478eacec8c8b16f47748038a298a4971e9d42dd7bb84f4700890f37b3af

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plutoprint-0.22.0-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for plutoprint-0.22.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c0cd4bbb07c07e18099e8077c9d35e9c7faf8184acaeed514aa69496b888f782
MD5 2511cdb7670f2a2a4b29f9c0caf46597
BLAKE2b-256 c7d7d25e4f30d04178490d1568d399f21ea2913182c8a13d7fdcc3f0c22eaeaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plutoprint-0.22.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for plutoprint-0.22.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3782288c44f02c3888b23ccf3e844c2db409afce9ad49127a51a3af87a499f15
MD5 86f96ac908ac787c019686432f8c4008
BLAKE2b-256 058f31ba7b214ada52677973dc673e5aa91ca07922b185cfe905fa358c7dbec6

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0-cp312-cp312-win_amd64.whl:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plutoprint-0.22.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for plutoprint-0.22.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cc20cb0c4961220de31992bfb37151745455878455c4231961cdc4e2bcfb319c
MD5 2745db4bf7a9ff0d8515ae30a6f8ffa6
BLAKE2b-256 e20db16075f97a142287e91fd6479dafc63b998c1d79c51e54a1aaa12c02d4e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plutoprint-0.22.0-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for plutoprint-0.22.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 587674c26271ee646632e2ef48ce56b8ae2dbe3b19f4f922eb07758b74082333
MD5 92e273beaa7101a45fd590799625e14d
BLAKE2b-256 be849cf047fe23c1b9f8f277aa65a284c8628a0fecfcef6c49d7a999931f0f7e

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plutoprint-0.22.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for plutoprint-0.22.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1d78337df8bb4cf8f1f5d3736465b2fc642f996862f0d6bce49ede1225773832
MD5 65e9c11fb285a27c359c243daf93cf7a
BLAKE2b-256 93255c8d82e3ea5c7315c701c70843cc552763edeb48653c858dd676477f245a

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0-cp311-cp311-win_amd64.whl:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plutoprint-0.22.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for plutoprint-0.22.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b41cd6b82c53616bfc29bdb15604ce6a80d9736ef42ba1aba2e212653213e758
MD5 d93f574d5ab5ad0b76ee4c106bcf2ed5
BLAKE2b-256 d2f0a8e6d44c01feca3d17fe011b20772315122f9e23bc1bfe8411dbf920d19c

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plutoprint-0.22.0-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for plutoprint-0.22.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 6c48ab913af78a3a48700b902faec8644534ceeac02286f9af1c3842b040f8ba
MD5 99124bc0799cfecf0c22b3e79a49b895
BLAKE2b-256 2804b24f94ddbe5cdbf6090430ab4d234a9435fee20f42ee2aaadd3bc4245b8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0-cp311-cp311-macosx_14_0_arm64.whl:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plutoprint-0.22.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for plutoprint-0.22.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c44fcac1ed1453dc355b12bb537d296357570d0207509f61898bbdcab368701c
MD5 b139f7a75daeac848c266fefbca84204
BLAKE2b-256 361e974ae1afe7891d904232ecb9ac4392ed24fa8595cffb83e7836b82def189

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0-cp310-cp310-win_amd64.whl:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plutoprint-0.22.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for plutoprint-0.22.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 08e5bfcc66437364832d62a93db45ed2258459dafd15ee3943056cfd9b37ae51
MD5 b20cf4d65a35fbd4b14c1a3fb06d6d8c
BLAKE2b-256 1b34b582471257e0b7878ea11cb34219933a8b6ecbb4d2318427bc056355a389

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0-cp310-cp310-manylinux_2_28_x86_64.whl:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plutoprint-0.22.0-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for plutoprint-0.22.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 4ad2dc1f94f946fd956aa45ead937babf68bc4d2ec629b38e96cddb3a41730fd
MD5 78df3ec1858904140567bd531906ad29
BLAKE2b-256 2d90b9b458b886cf1150cb10ae7305a3c18a3bd2f2ca9fb542d41652c7e7d0d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for plutoprint-0.22.0-cp310-cp310-macosx_14_0_arm64.whl:

Publisher: main.yml on plutoprint/plutoprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.22.0 This release

16 files

0.21.0

16 files

0.20.0

16 files

0.19.0

16 files

0.18.0

16 files

0.17.0

16 files

0.16.0

16 files

0.15.0

16 files

0.14.0

16 files

0.13.1

16 files

0.13.0

16 files

0.12.0

16 files

0.11.0

16 files

0.10.0

16 files

0.9.0

16 files

0.8.0

16 files

0.7.0

16 files

0.6.0

11 files

0.5.0

11 files

0.4.1

11 files

0.4.0

10 files

0.3.0

11 files

0.2.0

6 files

0.1.0

6 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page