A plugin that allows Flutter apps to generate and print documents to android or ios compatible printers

See the example on how to use the plugin.

Example document

This example is also available on the web here:

This plugin uses the pdf package for pdf creation. Please refer to for documentation.

Buy Me A Coffee


final pdf = Document();

      pageFormat: PdfPageFormat.a4,
      build: (Context context) {
        return Center(
          child: Text("Hello World"),
        ); // Center
      })); // Page

To load an image from an ImageProvider:

const imageProvider = const AssetImage('assets/image.png');
final PdfImage image = await pdfImageFromImageProvider(pdf: pdf.document, image: imageProvider);

    build: (Context context) {
      return Center(
        child: Image(image),
      ); // Center
    })); // Page

To use a TrueType font from a flutter bundle:

final font = await rootBundle.load("assets/open-sans.ttf");
final ttf = Font.ttf(font);

    build: (Context context) {
      return Center(
        child: Text('Dart is awesome', style: TextStyle(font: ttf, fontSize: 40)),
      ); // Center
    })); // Page

To save the pdf file using the path_provider library:

final output = await getTemporaryDirectory();
final file = File("${output.path}/example.pdf");
await file.writeAsBytes(;

You can also print the document using the iOS or Android print service:

await Printing.layoutPdf(
      onLayout: (PdfPageFormat format) async =>;

Or share the document to other applications:

await Printing.sharePdf(bytes:, filename: 'my-document.pdf');

To print an HTML document:

await Printing.layoutPdf(
    onLayout: (PdfPageFormat format) async => await Printing.convertHtml(
          format: format,
          html: '<html><body><p>Hello!</p></body></html>',

Convert a Pdf to images, one image per page, get only pages 1 and 2 at 72 dpi:

await for (var page in Printing.raster(, pages: [0, 1], dpi: 72)) {
  final image = page.toImage();
  // ...or page.toPng()


  1. Add this to your package's pubspec.yaml file:

      printing: any       # <-- Add this line
  2. Enable Swift on the iOS project, in ios/Podfile:

    target 'Runner' do
       use_frameworks!    # <-- Add this line
  3. Set minimum Android version in android/app/build.gradle:

    defaultConfig {
        minSdkVersion 21  // <-- Change this line to 21 or more