dart_pdf_printing library

Optional print preview, sheet composition and system printing for Flutter.

Classes

DartPdfPrintingLocalizations
Callers can lookup localized strings with an instance of DartPdfPrintingLocalizations returned by DartPdfPrintingLocalizations.of(context).
PrintDestination
Explicitly selecting a destination opts Windows into direct spooling. Other platforms continue to use their native print surfaces.
PrintPreferences
Print choices shared by successive jobs and app launches. Source page lists and crop regions belong to a document and are deliberately never stored.
PrintPreviewDialog
Print settings and, on Windows, destination printer controls. Adding files creates a separate print document.
PrintPreviewResult
The source document and options confirmed for this print job.
PrintPrinter
An installed Windows print queue. Its name is the stable native identifier.
PrintPrinterSettings
The chosen queue's driver preferences and currently supported controls.
PrintPrinterTray
PrintProgressDialog
Modal dialog shown while a print job rasterises its pages, tracking "page X of Y".
PrintSettings
A snapshot of a print job. All lengths are physical PDF points, except region, which uses the viewer's rotated page coordinates before UserUnit.

Functions

listPrintPrinters() → Future<List<PrintPrinter>>
loadPrintPrinterSettings(String printer) → Future<PrintPrinterSettings>
lookupDartPdfPrintingLocalizations(Locale locale) → DartPdfPrintingLocalizations
parsePrintPageRange(String input, int pageCount) → List<int>?
Parses one-based comma-separated pages and inclusive ranges. Duplicate pages are emitted once, in the order entered; invalid input returns null.
platformProvidesPrintPreview({TargetPlatform? platform}) → bool
Whether the platform's own print flow already shows the user what the job will look like.
preparePrintDocument(PdfDocument document, PrintSettings settings, {bool includeCopies = true, bool twoSided = false, int? sheetIndex}) → Uint8List
Produces the exact printable sheet geometry as a fresh vector PDF.
printJobName(String title) → String
A clean print-job / suggested-filename label: the tab title without a trailing .pdf, falling back to a default when it would be empty.
printPdfBytes({required Uint8List bytes, required String title, void onProgress(int rendered, int total)?, bool useDocumentPageSize = false, PrintDestination? destination}) → Future<void>
Prints bytes through the running platform's own print system, without any bundled PDF engine.
printPdfWithPreview(BuildContext context, {required PdfDocument document, required String title, int currentPage = 0, List<int> selectedPages = const [], Future<List<PdfDocument>> addFiles()?}) → Future<void>
Opens layout options and a preview, composes the confirmed sheets, then prints to the selected Windows queue or opens the system print dialog. Dismissing the preview submits nothing.
printPdfWithProgress(BuildContext context, {required Uint8List bytes, required String title, bool useDocumentPageSize = false, PrintDestination? destination}) → Future<void>
Prints a PDF with a progress dialog while desktop pages are prepared. Whole-PDF backends and jobs of at most two pages skip this extra dialog. Set useDocumentPageSize for sheets produced by preparePrintDocument.
printSheetCount(PrintSettings settings) → int
Number of printed sides before duplex pairing and copies are expanded.
showPrintPreviewDialog(BuildContext context, {required PdfDocument document, required String title, int currentPage = 0, List<int> selectedPages = const [], Future<List<PdfDocument>> addFiles()?}) → Future<PrintPreviewResult?>
Shows the same composed sheets that are sent to the printer.
showPrintPrinterProperties(String printer, {PrintDestination? settings}) → Future<PrintPrinterSettings?>
Opens the selected driver's advanced preferences only when requested. The native backend preserves its opaque settings across application restarts.
validatePrintSettings(PdfDocument document, PrintSettings settings) → void
Validates the whole job using page metadata only, so an invalid later sheet can be reported while the print dialog still owns its settings. No content or image streams are decoded.

Typedefs

PdfPrinter = Future<void> Function({required Uint8List bytes, required String title})
Callback for a host-owned print action. Receives the current PDF bytes and a document title suitable for a print-job name.