Converting images to PDFs in Flutter is straightforward with the image_to_pdf_converter package.
Installation
flutter pub add image_to_pdf_converter
Import the Package
import 'package:image_to_pdf_converter/image_to_pdf_converter.dart';
import 'dart:io';
Usage
// The first image in the list will be page 1 and so on
final List<File> imageFiles = [
File('/path/to/image1.jpg'),
File('/path/to/image2.jpg'),
];
// Generate the PDF file
final File pdfFile = await ImageToPdf.imageList(listOfFiles: imageFiles);
That's it. You can now save, share, or upload the PDF file as needed.
Top comments (0)