Skip to main content

flet-printing

Native print dialog / share sheet for Flet apps — wraps the Flutter printing package.

Flet has no built-in printing API. Flutter has a mature one. This extension bridges the gap, the same way official extensions like flet-audio wrap audioplayers.

The demand is documented: flet-dev/flet#894 (Jan 2023) asked for exactly this — PDF printing via the printing package — was closed as "completed" without a shipped solution, and the follow-up question "What's the completed solution for this?" (Feb 2024) was never answered. This package is that answer.

日本語補足: Fletには印刷APIがありません(0.85時点・全API確認済み)。 Flutterのprintingパッケージ(ネイティブ印刷ダイアログ・共有シート)を Flet拡張として包んだものです。ワープロ的なアプリの「ファイル→印刷…」を Fletで実装できます。

Usage

import flet as ft
from flet_printing import Printing

def main(page: ft.Page):
    printing = Printing()
    page.services.append(printing)

    async def print_click(e):
        pdf = open("document.pdf", "rb").read()
        sent = await printing.print_pdf(pdf, name="document")
        # sent=True: 印刷された / False: ダイアログでキャンセル

    page.add(ft.FilledButton("印刷…", on_click=print_click))

ft.run(main)

API:

  • await printing.print_pdf(pdf, name="document") — open the platform print dialog (printer selection / copies / duplex / save-as-PDF) for the given PDF bytes. Returns False if the user cancelled.
  • await printing.share_pdf(pdf, filename="document.pdf") — open the platform share sheet (mobile) / save dialog (desktop).

PdfPreview — display a PDF with print/share built in

from flet_printing import PdfPreview

page.add(PdfPreview(src=pdf_bytes, pdf_file_name="document.pdf",
                    expand=True))

Renders the PDF pages (scrollable) with an action bar: print and share buttons work out of the box. Properties: src (bytes or base64), allow_printing, allow_sharing, use_actions, pdf_file_name, on_printed/on_shared events. can_change_page_format / can_change_orientation are off by default (the PDF you pass is already laid out).

There is deliberately no HTML-to-PDF here: printing's convertHtml is deprecated. Generate the PDF yourself (e.g. headless Chrome for exact CJK typesetting) and pass the bytes to print_pdf.

Installation

Like every third-party Flet extension, this works with apps compiled via flet build (the prebuilt flet run client only bundles official extensions).

Add to your app's pyproject.toml:

dependencies = [
  "flet-printing",
  "flet>=0.85.3",
]

then flet build linux (or windows / macos / apk / ipa).

A runnable example lives in examples/flet_printing_example (build verified on Linux: extension registers, app launches, print dialog opens from the button).

Platform support

Follows the printing package: Android / iOS / macOS / Windows / Linux (via CUPS) / web. See the printing package docs for details.

License

MIT

Release files for flet-printing 0.2.0

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

Source distribution (sdist)

Source distribution for flet-printing 0.2.0
File Size Uploaded
flet_printing-0.2.0.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flet-printing 0.2.0
File Interpreter ABI Platform
flet_printing-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.8 kB

Release files / flet_printing-0.2.0.tar.gz

Download URL flet_printing-0.2.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
54bd96700702705fa05dd3004045c9a916c007a94042f957217b1bea07b1ecf4
BLAKE2b-256 checksum
How to use checksums
dc8a18ca756f165c6541bef2f6445620de9ed51940d905c0bd0cb87887c3ca3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.

Transparency log

Release files / flet_printing-0.2.0-py3-none-any.whl

Download URL flet_printing-0.2.0-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d219c1861f979320a2ddeadddc83136e220275403aa5ef10c772984e4cce0b9
BLAKE2b-256 checksum
How to use checksums
7141812da1d25b5b14b12c2570c5958d7ca573a1c09535695b582bea7ae0df5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

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