Skip to content
pubscout

pdf

3.13.1, released 2 months ago by nfet.net

A PDF generation library for Dart and Flutter using a widget-like layout system.

WASM-readyRock solid
$ flutter pub add pdf
Source repository

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.

  • path_provider

    Pick path_provider to resolve local directories for saving the generated PDF files onto the device filesystem.

Works with

Packages commonly used together with pdf: ones it builds on, ones built on it, and its own family.