flutter_to_pdf
0.4.1, released a year ago by dunef.com
Export any Flutter widget to a PDF document, page, or widget natively in Dart.
What it does
Allows developers to wrap Flutter widgets in an ExportFrame and export them directly to PDF documents, pages, or widgets. It supports customization through export options such as page formats, text fields, checkboxes, custom TTF fonts, and image capture for complex widgets like CustomPaint and charts.
AI-written summary of version 0.4.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to generate PDF files from standard Flutter widget layouts.
- You want to export forms, invoices, or UI components directly to PDF without dealing with low-level PDF painting code.
Skip it when
- You need complex multi-page document pagination layouts natively designed with PDF primitives rather than Flutter widgets.
- Your UI heavily relies on unsupported platform-specific platform views.
Strengths
- Lets you use standard Flutter widget trees for PDF creation.
- Supports custom TTF fonts and interactive text fields or checkboxes.
- Provides a CaptureWrapper for complex custom paints and charts.
Weaknesses
- Requires unique keys for text fields, checkboxes, and captured wrapper widgets to apply individual options properly.
- Not documented for server-side Dart usage outside of Flutter.
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Simply add the package dependency and import it in your Dart code. Custom fonts or specific widget keys may require configuration.
final ExportDelegate exportDelegate = ExportDelegate();
ExportFrame(
frameId: 'someFrameId',
exportDelegate: exportDelegate,
child: SomeWidget(),
);
final pdf = await exportDelegate.exportToPdfDocument('someFrameId');Alternatives
Packages that do the same job and could replace flutter_to_pdf.
- syncfusion_flutter_pdfviewer
Flutter PDF Viewer library to display PDF documents seamlessly and efficiently.
86Compare - native_pdf_view
Flutter plugin to render and display PDF files across Web, macOS, Windows, Android, and iOS.
50Compare - file_selector_macos
macOS implementation of the file_selector plugin
82Compare - pdf_combiner
Merge multiple PDF documents and images into a single file or extract images from PDFs.
85Compare
Works with
Packages commonly used together with flutter_to_pdf: ones it builds on, ones built on it, and its own family.