---
title: "How to create and edit PDFs in Flutter with Nutrient"
canonical_url: "https://www.nutrient.io/blog/create-and-edit-pdfs-in-flutter/"
md_url: "https://www.nutrient.io/blog/create-and-edit-pdfs-in-flutter.md"
last_updated: "2026-08-11T02:52:57.338Z"
description: "Generate, edit, and annotate PDFs in a Flutter app with Nutrient Flutter SDK — blank pages, images, HTML, annotations, and a built-in editor."
---

**TL;DR**

With the [Nutrient Flutter PDF SDK](https://www.nutrient.io/sdk/flutter/) you can both create and edit PDFs from a single Dart codebase:

- Generate PDFs from blank pages, patterns, images, or HTML with `Nutrient.generatePdf`.

- Display documents in the `NutrientView` widget and let users annotate and edit through the built-in UI.

- Add, read, and remove annotations programmatically with the annotation model classes.

[Start a free trial](https://www.nutrient.io/try/) or [launch the demo](https://www.nutrient.io/guides/flutter/demo.md) to try it.

This post shows how to create and edit PDFs in a Flutter app using the [Nutrient Flutter PDF SDK](https://www.nutrient.io/sdk/flutter/). You’ll generate documents programmatically, display them in a viewer, and add annotations — all from one Dart codebase that runs on iOS, Android, and web.

Flutter is a free, open source framework from Google for building cross-platform apps from a single codebase.

## The Nutrient Flutter PDF library

Nutrient offers a commercial [Flutter PDF library](https://www.nutrient.io/sdk/flutter/) that ships with a range of out-of-the-box features, including:

- A customizable [viewer UI](https://www.nutrient.io/guides/flutter/user-interface.md) that drops into your app as a widget.

- Tools for [annotating documents](https://www.nutrient.io/guides/flutter/annotations.md), filling [PDF forms](https://www.nutrient.io/guides/flutter/forms.md), and signing.

- PDF generation from blank pages, images, and HTML.

- Support for multiple file types — from image files (JPG, PNG, and TIFF) to PDF documents.

- [Active development](https://www.nutrient.io/guides/flutter/changelog.md) with regular updates and fixes.

## Setting up the SDK

Add the dependency to your project:

```bash

flutter pub add nutrient_flutter

```

Then complete the platform setup — on Android, set the base activity to `FlutterAppCompatActivity`; on iOS, set the deployment target to 16.0. For the full step-by-step configuration, follow the [getting started on Flutter](https://www.nutrient.io/sdk/flutter/getting-started.md) guide.

Since version 3.9.0, the SDK must be initialized with a license key before use. Pass `null` to run in trial mode (this shows a watermark):

```dart

import 'package:flutter/material.dart';
import 'package:nutrient_flutter/nutrient_flutter.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  // Pass `null` to use the trial version.
  Nutrient.initialize(androidLicenseKey: null, iosLicenseKey: null);

  runApp(const MyApp());
}

```

## Generating a PDF

The `Nutrient.generatePdf` method creates a document from a list of [`NewPage`](https://pub.dev/documentation/nutrient_flutter/latest/nutrient_flutter/Nutrient-class.html) objects and writes it to an output path. Each `NewPage` can be a blank page, a pattern, an image, or a page from an existing document.

### Blank pages and patterns

Create a `NewPage` with `NewPage.fromPattern`, passing a [`PagePattern`](https://pub.dev/documentation/nutrient_flutter/latest/nutrient_flutter/Nutrient-class.html) (such as `PagePattern.blank`) and an optional page size:

```dart

List<NewPage> pages = [
  // A blank A5 page.
  NewPage.fromPattern(PagePattern.blank, pageSize: PageSize.a5),
];

final tempDir = await Nutrient.getTemporaryDirectory();
final outputPath = '${tempDir.path}/generated.pdf';

var filePath = await Nutrient.generatePdf(pages, outputPath);

// Open the generated document in the viewer.
await Nutrient.present(filePath!);

```

Nutrient also ships predefined patterns — `PagePattern.dots5mm`, `PagePattern.grid5mm`, and `PagePattern.line5mm` — for dotted, grid, and lined pages.![Generating and opening a blank PDF on iOS](@/assets/images/blog/2023/create-and-edit-pdfs-in-flutter/blank-pdf-generation-ios.gif)

### From images

To turn an image into a PDF page, wrap it in a [`PdfImagePage`](https://pub.dev/documentation/nutrient_flutter/latest/nutrient_flutter/Nutrient-class.html) and pass it to `NewPage.fromImage`:

```dart

File img = File('<readable-image-path>');

List<NewPage> pages = [
  NewPage.fromImage(PdfImagePage.fromUri(img.uri, PagePosition.center)),
];

var filePath = await Nutrient.generatePdf(pages, outputPath);

```

### From HTML

You can also render an HTML string (or a URI) straight to a PDF:

```dart

const html = '<html><body><h1>Invoice</h1><p>Generated with Nutrient.</p></body></html>';

String? generatedPdf = await Nutrient.generatePdfFromHtmlString(html, outputPath);

```

## Displaying and editing a PDF

To show a document, add the `NutrientView` widget to your screen. The widget includes a full editing UI — users can annotate, fill forms, and sign without any extra code:

```dart

import 'package:nutrient_flutter/nutrient_flutter.dart';

Scaffold(
  body: NutrientView(
    documentPath: 'file:///path/to/document.pdf',
  ),
);

```

## Adding annotations programmatically

Beyond the built-in UI, you can add, read, and remove annotations in code using the annotation model classes. Once you have a reference to the loaded [`PdfDocument`](https://www.nutrient.io/guides/flutter/annotations/), add an annotation with `addAnnotation`:

```dart

// Create a link annotation pointing to a URL.
final linkAnnotation = LinkAnnotation(
  id: 'link-annotation-1',
  bbox: [50.0, 700.0, 200.0, 30.0],
  pageIndex: 0,
  action: UriAction(uri: 'https://nutrient.io'),
);

await document.addAnnotation(linkAnnotation);

```

Read the annotations on a page with `getAnnotations`, and remove one with `removeAnnotation`:

```dart

List<Annotation> annotations = await document.getAnnotations(0, AnnotationType.all);

if (annotations.isNotEmpty) {
  await document.removeAnnotation(annotations[0]);
}

```

For the full list of annotation types and how to obtain the document reference from the viewer, see the [annotations guide](https://www.nutrient.io/guides/flutter/annotations.md).

## Filling forms and signing

The same document supports interactive [PDF forms](https://www.nutrient.io/guides/flutter/forms.md) and [electronic signatures](https://www.nutrient.io/guides/flutter/signatures.md): Users can fill and sign through the `NutrientView` UI, and you can read or write form field values programmatically — useful for prefilling a form or exporting submitted data to your backend. Cryptographic [digital signatures](https://www.nutrient.io/guides/flutter/signatures/digital-signatures.md) aren’t bridged in the Flutter SDK; they’re applied through the native iOS, Android, or Web layer.

## Open source options vs. Nutrient

If you only need to generate or display PDFs, Flutter has capable open source packages:

- **`pdf` and `printing`** build PDFs from a widget-style layout and then preview, print, or share them. They’re a good fit when you generate documents like invoices or reports but don’t need to open and edit arbitrary PDFs.

- **`flutter_pdfview` and `pdfx`** render existing PDFs for read-only viewing.

What these libraries don’t cover is everything _after_ viewing — interactive annotation editing, form filling, electronic signatures (with cryptographic digital signing available through the native iOS, Android, or Web SDKs), redaction, and a configurable viewer UI. Reach for the Nutrient Flutter PDF SDK when document interaction is core to your app, or when you want generation, viewing, and editing from one maintained SDK with commercial support. For simple, single-purpose generate-or-view tasks, an open source package may be all you need.

## Conclusion

In this post, you generated PDFs from blank pages, images, and HTML; displayed them in the `NutrientView` widget; and added annotations programmatically with the Nutrient Flutter PDF SDK. From here, the same SDK handles forms, signing, and redaction across iOS, Android, and web.

If you run into any issues, [reach out](https://www.nutrient.io/support/request/) to our Support team. To see the SDK in action, check out [our demo](https://www.nutrient.io/guides/flutter/demo.md) or [start a free trial](https://www.nutrient.io/try/).

## FAQ

#### How do I generate a PDF in Flutter?

Use the Nutrient Flutter PDF SDK’s `Nutrient.generatePdf` method. Pass it a list of `NewPage` objects — built from blank pages, patterns, images, or HTML — and an output path, and it writes the PDF to disk.

#### Can I edit and annotate PDFs in Flutter?

Yes. The `NutrientView` widget includes a built-in editor so users can annotate, fill forms, and sign. You can also add, read, and remove annotations programmatically using the SDK’s annotation model classes.

#### Which platforms does the Nutrient Flutter PDF SDK support?

The SDK runs on iOS, Android, and web from a single Dart codebase, with native rendering on each platform.

#### Can I create a PDF from HTML in Flutter?

Yes. Use `Nutrient.generatePdfFromHtmlString` to render an HTML string to a PDF, or `Nutrient.generatePdfFromHtmlUri` to render from a URI.

## Related reading

- [How to build a Flutter PDF viewer](https://www.nutrient.io/blog/how-to-build-a-flutter-pdf-viewer.md) — Focused on displaying PDFs in Flutter

- [How to build a React Native PDF viewer](https://www.nutrient.io/blog/how-to-build-a-react-native-pdf-viewer.md) — The same workflow for React Native
---

## Related pages

- [The business case for accessibility: Five ways it drives enterprise value](/blog/5-ways-accessibility-drives-enterprise-value.md)
- [Accessibility Untangled Why It Matters Guide](/blog/accessibility-untangled-why-it-matters-guide.md)
- [Advanced Techniques For React Native Ui Components](/blog/advanced-techniques-for-react-native-ui-components.md)
- [`vector_store` holds your indexed documents (see the multimodal RAG post](/blog/agentic-rag.md)
- [Ai Document Automation Extraction To Action](/blog/ai-document-automation-extraction-to-action.md)
- [Ai Legal Assistant Document Authoring](/blog/ai-legal-assistant-document-authoring.md)
- [Angular File Viewer Pdf Image Office Files](/blog/angular-file-viewer-pdf-image-office-files.md)
- [Auto Tagging And Document Accessibility In Dotnet Sdk](/blog/auto-tagging-and-document-accessibility-in-dotnet-sdk.md)
- [Best Document Ai Platforms](/blog/best-document-ai-platforms.md)
- [Best Document Viewers](/blog/best-document-viewers.md)
- [The CEO’s AI playbook: Why decision architecture beats model selection](/blog/ceo-ai-playbook-decision-architecture.md)
- [1. Extract and chunk the PDF.](/blog/chat-with-pdf.md)
- [Complete Guide To Pdfjs](/blog/complete-guide-to-pdfjs.md)
- [Construction Document Data Extraction](/blog/construction-document-data-extraction.md)
- [Convert One Drive Files To Pdf In Sharepoint](/blog/convert-one-drive-files-to-pdf-in-sharepoint.md)
- [Create Pdfs With React](/blog/create-pdfs-with-react.md)
- [Creating A Document Scanner With Ocr In Python](/blog/creating-a-document-scanner-with-ocr-in-python.md)
- [Creating And Filling Pdf Forms Programmatically In Javascript](/blog/creating-and-filling-pdf-forms-programmatically-in-javascript.md)
- [The CTO’s AI playbook: Why accountability architecture beats orchestration](/blog/cto-ai-playbook-accountability-architecture.md)
- [Digital Signatures](/blog/digital-signatures.md)
- [Digital Workflow Automation](/blog/digital-workflow-automation.md)
- [Document Ai Vs Ocr](/blog/document-ai-vs-ocr.md)
- [Document Extraction Confidence Scores](/blog/document-extraction-confidence-scores.md)
- [Document Viewer](/blog/document-viewer.md)
- [Document Watermarking](/blog/document-watermarking.md)
- [Emerging threats: Your logging system may be an agentic threat vector](/blog/emerging-threats-your-logging-system.md)
- [Extract Patient Data On Premises](/blog/extract-patient-data-on-premises.md)
- [app.py](/blog/extract-text-from-pdf-using-python.md)
- [Fillable Pdf](/blog/fillable-pdf.md)
- [How To Add Digital Signature To Pdf Using React](/blog/how-to-add-digital-signature-to-pdf-using-react.md)
- [How To Build A Dotnet Maui Pdf Viewer](/blog/how-to-build-a-dotnet-maui-pdf-viewer.md)
- [How To Build A Flutter Pdf Viewer](/blog/how-to-build-a-flutter-pdf-viewer.md)
- [or](/blog/how-to-build-a-javascript-pdf-viewer-with-pdfjs.md)
- [How To Build A Javascript Pdf Viewer](/blog/how-to-build-a-javascript-pdf-viewer.md)
- [or](/blog/how-to-build-a-nextjs-pdf-viewer.md)
- [How To Build A Powerpoint Viewer Using Javascript](/blog/how-to-build-a-powerpoint-viewer-using-javascript.md)
- [Using Yarn](/blog/how-to-build-a-react-excel-viewer.md)
- [How To Build A React Native Pdf Viewer](/blog/how-to-build-a-react-native-pdf-viewer.md)
- [How To Build A React Powerpoint Viewer](/blog/how-to-build-a-react-powerpoint-viewer.md)
- [How To Build A Reactjs File Viewer](/blog/how-to-build-a-reactjs-file-viewer.md)
- [or](/blog/how-to-build-a-reactjs-pdf-viewer-with-react-pdf.md)
- [or](/blog/how-to-build-a-reactjs-pdf-viewer.md)
- [How To Build A Reactjs Viewer With Pdfjs](/blog/how-to-build-a-reactjs-viewer-with-pdfjs.md)
- [How To Build A Vuejs Pdf Viewer With Pdfjs](/blog/how-to-build-a-vuejs-pdf-viewer-with-pdfjs.md)
- [How To Build A Vuejs Pdf Viewer](/blog/how-to-build-a-vuejs-pdf-viewer.md)
- [How To Build An Android Pdf Viewer](/blog/how-to-build-an-android-pdf-viewer.md)
- [How To Build An Angular Pdf Viewer With Ng2 Pdf Viewer](/blog/how-to-build-an-angular-pdf-viewer-with-ng2-pdf-viewer.md)
- [How To Build An Angular Pdf Viewer With Pdfjs](/blog/how-to-build-an-angular-pdf-viewer-with-pdfjs.md)
- [How To Convert Docx To Pdf Using Javascript](/blog/how-to-convert-docx-to-pdf-using-javascript.md)
- [How To Convert Docx To Pdf Using Python](/blog/how-to-convert-docx-to-pdf-using-python.md)
- [How To Convert Html To Pdf Using Html2pdf](/blog/how-to-convert-html-to-pdf-using-html2pdf.md)
- [or](/blog/how-to-convert-html-to-pdf-using-react.md)
- [How To Convert Html To Pdf Using Wkhtmltopdf And Csharp](/blog/how-to-convert-html-to-pdf-using-wkhtmltopdf-and-csharp.md)
- [or](/blog/how-to-convert-html-to-pdf-using-wkhtmltopdf-and-python.md)
- [How To Convert Word To Pdf In Nodejs](/blog/how-to-convert-word-to-pdf-in-nodejs.md)
- [or](/blog/how-to-create-a-react-js-signature-pad.md)
- [How To Create Pdfs With React To Pdf](/blog/how-to-create-pdfs-with-react-to-pdf.md)
- [How To Edit Pdfs Using Ios Pdf Library](/blog/how-to-edit-pdfs-using-ios-pdf-library.md)
- [How To Embed A Pdf Viewer In Your Website](/blog/how-to-embed-a-pdf-viewer-in-your-website.md)
- [How To Extract Tables From Pdf And Images](/blog/how-to-extract-tables-from-pdf-and-images.md)
- [How To Generate Pdf From Html With Nodejs](/blog/how-to-generate-pdf-from-html-with-nodejs.md)
- [base_url tells WeasyPrint where to resolve relative asset paths](/blog/how-to-generate-pdf-reports-from-html-in-python.md)
- [How To Merge Pdfs Using Javascript](/blog/how-to-merge-pdfs-using-javascript.md)
- [How To Ocr Pdfs In Linux](/blog/how-to-ocr-pdfs-in-linux.md)
- [How To Print Pdf In Csharp](/blog/how-to-print-pdf-in-csharp.md)
- [Open an image.](/blog/how-to-use-tesseract-ocr-in-python.md)
- [From an HTML string.](/blog/html-in-pdf-format.md)
- [Javascript Pdf Editors](/blog/javascript-pdf-editors.md)
- [Javascript Pdf Libraries](/blog/javascript-pdf-libraries.md)
- [Linearized Pdf](/blog/linearized-pdf.md)
- [or](/blog/merge-pdfs.md)
- [Swift Package Manager](/blog/mobile-pdf-sdk.md)
- [`elements` come from your document parser — each has a type and content.](/blog/multimodal-rag.md)
- [Nutrient Vs Conga Composer](/blog/nutrient-vs-conga-composer.md)
- [Online Document Viewer](/blog/online-document-viewer.md)
- [Open Pdf In Your Web App](/blog/open-pdf-in-your-web-app.md)
- [Building WCAG 2.2, Section 508, and PDF/UA-compliant PDFs with an SDK](/blog/pdf-accessibility.md)
- [Pdf Data Extraction Developer Guide](/blog/pdf-data-extraction-developer-guide.md)
- [Pdf Extraction Benchmark Opendataloader Bench](/blog/pdf-extraction-benchmark-opendataloader-bench.md)
- [Pdf Extraction Document Case Studies](/blog/pdf-extraction-document-case-studies.md)
- [Pdf Page Labels](/blog/pdf-page-labels.md)
- [Pdf Sdk Compliance Security Checklist](/blog/pdf-sdk-compliance-security-checklist.md)
- [Pdf Sdk Performance Benchmark](/blog/pdf-sdk-performance-benchmark.md)
- [Pdf Ua Compliance Guide](/blog/pdf-ua-compliance-guide.md)
- [Pdfjs Accessibility Structtree Printing](/blog/pdfjs-accessibility-structtree-printing.md)
- [Pdfjs Advanced Loading Streaming Workers](/blog/pdfjs-advanced-loading-streaming-workers.md)
- [Pdfjs Annotation Editor Layer](/blog/pdfjs-annotation-editor-layer.md)
- [Pdfjs Area Annotations Canvas Capture](/blog/pdfjs-area-annotations-canvas-capture.md)
- [Pdfjs Coordinate Systems Pdf To Screen](/blog/pdfjs-coordinate-systems-pdf-to-screen.md)
- [Pdfjs Document Outline Bookmarks Metadata](/blog/pdfjs-document-outline-bookmarks-metadata.md)
- [Pdfjs Eventbus Guide](/blog/pdfjs-eventbus-guide.md)
- [macOS](/blog/pdfjs-file-format-conversion-to-pdf.md)
- [macOS](/blog/pdfjs-generating-pdf-thumbnails-pdf2pic.md)
- [Pdfjs Limitations Commercial Upgrade](/blog/pdfjs-limitations-commercial-upgrade.md)
- [Pdfjs Native Annotation Layer Forms](/blog/pdfjs-native-annotation-layer-forms.md)
- [Pdfjs Navigation Zoom Rotation](/blog/pdfjs-navigation-zoom-rotation.md)
- [Pdfjs Pdf Page Manipulation Pdf Lib](/blog/pdfjs-pdf-page-manipulation-pdf-lib.md)
- [Pdfjs React Viewer Setup](/blog/pdfjs-react-viewer-setup.md)
- [Pdfjs Rendering Overlays React Portals](/blog/pdfjs-rendering-overlays-react-portals.md)
- [Pdfjs Server Side Text Extraction](/blog/pdfjs-server-side-text-extraction.md)
- [Pdfjs Sticky Note Annotations](/blog/pdfjs-sticky-note-annotations.md)
- [Pdfjs Text Highlight Annotations](/blog/pdfjs-text-highlight-annotations.md)
- [Pdfjs Text Search Pdffindcontroller](/blog/pdfjs-text-search-pdffindcontroller.md)
- [Pdfjs Thumbnail Sidebar](/blog/pdfjs-thumbnail-sidebar.md)
- [Process Flows](/blog/process-flows.md)
- [React Native Pdf Annotation](/blog/react-native-pdf-annotation.md)
- [Using Yarn](/blog/react-pdf-editor.md)
- [or](/blog/sample-blog-updated.md)
- [Sdk Product Updates Q2 2026](/blog/sdk-product-updates-q2-2026.md)
- [Add DWS MCP Server to your Claude Code project.](/blog/teaching-llms-to-read-pdfs.md)
- [Open an image file.](/blog/tesseract-python-guide.md)
- [Define the HTML part of the document.](/blog/top-10-ways-to-generate-pdfs-in-python.md)
- [Top 5 Javascript Pdf Viewers](/blog/top-5-javascript-pdf-viewers.md)
- [or](/blog/top-js-pdf-libraries.md)
- [Convert an HTML file to PDF.](/blog/top-ten-ways-to-convert-html-to-pdf.md)
- [Vector Pdf](/blog/vector-pdf.md)
- [Wcag2 Accessibility Requirements Documents](/blog/wcag2-accessibility-requirements-documents.md)
- [Web Sdk Is Now Headless](/blog/web-sdk-is-now-headless.md)
- [What Are Annotations](/blog/what-are-annotations.md)
- [What Is A Vpat](/blog/what-is-a-vpat.md)
- [What Is Document Processing](/blog/what-is-document-processing.md)
- [What Is Intelligent Document Processing](/blog/what-is-intelligent-document-processing.md)
- [What Is Pdf Ua](/blog/what-is-pdf-ua.md)
- [Why Pdfium Is A Trusted Platform For Pdf Rendering](/blog/why-pdfium-is-a-trusted-platform-for-pdf-rendering.md)
- [Why Your Ai Agent Hallucinates Pdf Table Data](/blog/why-your-ai-agent-hallucinates-pdf-table-data.md)

