This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/flutter/pdf-generation/from-images.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Image to PDF with Flutter PDF generation library | Nutrient

PDF generation is available only on the legacy method-channel API (package:nutrient_flutter/nutrient_flutter.dart), which is deprecated in Nutrient Flutter SDK 6. The APIs on this page aren’t part of the bindings API yet. They still work in SDK 6; import the legacy library to use them alongside bindings.dart if you use both. Nutrient plans to add a bindings equivalent. In the meantime, refer to the platform adapters guide to use native processors. For details, refer to the Flutter SDK 6 migration guide.

To convert an image to a PDF, follow these steps:

  1. Create a PdfImagePage object(opens in a new tab) to specify the image location and compression instructions.
  2. Create a NewPage object(opens in a new tab) to specify the page size and the PdfImagePage object(opens in a new tab) you created.
  3. Call the Nutrient.generatePdf() method with these parameters:

Generate PDFs from images

The following example creates a PDF from an image:

// Image file from which to generate the PDF.
File img = File('<readable-image-path>');
// File path where the generated PDF will be saved.
String outputPath = '<writable-output-file-path>';
// A list of PDF pages from the image URI.
List<NewPage> pages = [
NewPage.fromImage(
PdfImagePage.fromUri(img.uri, PagePosition.center)),
NewPage.fromImage(
PdfImagePage.fromUri(img.uri, PagePosition.center)),
];
// Generate a PDF from an image and save it at `[outputPath]`.
var filePath = await Nutrient.generatePdf(
pages, outputPath); // Or `generatePDFFromImage`.

For more information about generating PDF files from HTML strings and URLs, refer to the Nutrient(opens in a new tab) API reference and the PDF generation example(opens in a new tab) from the Catalog app(opens in a new tab).