---
title: "Image to PDF with Flutter PDF generation library | Nutrient"
canonical_url: "https://www.nutrient.io/guides/flutter/pdf-generation/from-images/"
md_url: "https://www.nutrient.io/guides/flutter/pdf-generation/from-images.md"
last_updated: "2026-05-30T02:20:01.297Z"
description: "Image to PDF with Flutter PDF generation library | guide for Nutrient Flutter SDK with detailed instructions and code examples."
---

# Generate a PDF from an image in Flutter

To convert an image to a PDF, follow the steps below.

1. Create a [`PdfImagePage` object](https://github.com/PSPDFKit/pspdfkit-flutter/blob/master/lib/src/processor/pdf_image_page.dart) to specify the location of the image and instructions for compression.

2. Create a [`NewPage` object](https://github.com/PSPDFKit/pspdfkit-flutter/blob/master/lib/src/processor/new_page.dart) to specify the page size and the previously created [`PdfImagePage` object](https://github.com/PSPDFKit/pspdfkit-flutter/blob/master/lib/src/processor/pdf_image_page.dart).

3. Call the `Nutrient.generatePdf()` method with the following parameters:
   - A list of [`NewPage` objects](https://github.com/PSPDFKit/pspdfkit-flutter/blob/master/lib/src/processor/new_page.dart).
   - An `outputFile` parameter specifying the location where to save the generated PDF.

## Generate PDFs from images

The following code demonstrates how to create a PDF from an image:

```dart

// 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 on generating PDF files from HTML strings and URLs, see the [`Nutrient`](https://pub.dev/documentation/nutrient_flutter/latest/nutrient_flutter/Nutrient-class.html) API reference and the [PDF Generation Example](https://github.com/PSPDFKit/pspdfkit-flutter/blob/master/example/lib/pdf_generation_example.dart) from the [Catalog app](https://github.com/PSPDFKit/pspdfkit-flutter).
---

## Related pages

- [Create PDFs from HTML in Flutter](/guides/flutter/pdf-generation/from-html.md)
- [Generate a blank PDF in Flutter](/guides/flutter/pdf-generation/blank-pdf.md)
- [Generate a PDF from a template in Flutter](/guides/flutter/pdf-generation/from-template.md)
- [PDF Generation library for Flutter](/guides/flutter/pdf-generation.md)

