3.13.1, released 2 months ago by nfet.net
A PDF generation library for Dart and Flutter using a widget-like layout system.
What it does
Provides low-level PDF byte generation alongside a high-level widget system modeled after Flutter's layout concepts. It supports multi-page layouts with automatic pagination, TrueType fonts, SVGs, images, and tables. Documents can be serialized directly into byte arrays or streamed for memory-bounded output.
AI-written summary of version 3.13.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to generate PDF reports, invoices, or multi-page documents programmatically across Flutter or pure Dart environments.
- You want to build PDF document layouts using familiar Flutter-like widgets such as Row, Column, Container, and Table.
- You require automatic page breaking and header/footer management across variable-length content.
Skip it when
- You only need to display, view, or open existing PDF files (you need a viewer or opener package instead).
- You need hardware printing or OS share sheets out-of-the-box without pairing it with an additional plugin like printing.
Strengths
- Familiar declarative widget layout system reduces the learning curve for Flutter developers.
- Supports automatic multi-page flows with configurable headers, footers, and page breaks via MultiPage.
- Pure Dart implementation works across Android, iOS, Web, macOS, Linux, and Windows.
Weaknesses
- Does not handle native printing or device share dialogs directly; requires separate packages like printing.
- Loading, editing, or encrypting existing PDFs requires external dependencies or separate crypto libraries.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 9
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart' as pw;
final pdf = pw.Document();
pdf.addPage(
pw.Page(
pageFormat: PdfPageFormat.a4,
build: (pw.Context context) {
return pw.Center(
child: pw.Text('Hello World'),
);
},
),
);
final bytes = await pdf.save();Alternatives
Packages that do the same job and could replace pdf.
- open_file
Pick open_file if you need to view or launch the generated PDF in the device's default viewer rather than generating the document itself.
71Compare - path_provider
Pick path_provider to resolve local directories for saving the generated PDF files onto the device filesystem.
93Compare
Works with
Packages commonly used together with pdf: ones it builds on, ones built on it, and its own family.
- archivepdf depends on itEncodes and decodes archive and compression formats such as zip, tar, gzip, and zlib.
- cryptopdf depends on itProvides SHA, MD5, and HMAC hashing functions for Dart.
- xmlpdf depends on itFull-featured XML and XPath library for DOM parsing, SAX streaming, and fluent building.
- vector_mathpdf depends on itVector math library for 2D/3D/4D vectors, matrices, quaternions, and geometry.
- imagepdf depends on itPure Dart library to load, manipulate, encode, and decode various image formats.
- path_parsingpdf depends on itPure Dart library for parsing SVG path strings and generating Dart path code.
- barcodepdf depends on itBarcode generation library for Dart that can generate generic drawing operations for any backend.
- bidipdf depends on itConverts logical RTL strings to their visual representation using the Unicode Bidirectional Algorithm.