Working with PDFs in Flutter is common, especially for applications that handle documents. Extracting images from PDFs can be essential for various features like previewing, editing, or sharing. In this guide, we’ll walk you through how to take an Image from a PDF in Flutter.
How to take an Image from a PDF in Flutter

Prerequisites
Before you start, ensure you have Flutter installed and set up. You will also need to add specific dependencies to your pubspec.yaml
file.
Required Dependencies
dependencies: flutter: sdk: flutter pdf: ^3.6.0 pdf_image_renderer: ^1.0.0
Make sure to run flutter pub get
to install these packages.
Step-by-Step Guide to Extract Images
- Import the Necessary Packages
import 'package:flutter/material.dart'; import 'package:pdf_image_renderer/pdf_image_renderer.dart';
- Load the PDF File You can load a PDF from assets, file storage, or network:
final pdfPath = 'assets/sample.pdf';
- Extract Images from the PDF
Future<void> extractImage() async { final pdfRenderer = PdfImageRenderer(filePath: pdfPath); for (int i = 0; i < await pdfRenderer.getPageCount(); i++) { final image = await pdfRenderer.renderPage( background: Colors.white, x: 0, y: 0, width: 300, height: 400, scale: 2.0, pageNumber: i + 1, ); if (image != null) { // Display or process the image print('Image extracted from page ${i + 1}'); } } }
- Display the Extracted Image
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('PDF Image Extractor')), body: Center( child: ElevatedButton( onPressed: extractImage, child: Text('Extract Image'), ), ), ); }
Key Considerations
- Ensure the PDF file permissions are properly configured.
- Optimize performance when working with large PDFs.
- Handle errors gracefully to improve user experience.

Conclusion
Extracting images from PDFs in Flutter is straightforward with the right tools. Following the steps outlined above, you can efficiently integrate PDF image extraction into your Flutter applications.