createImageFromPDF method
Future<List<String> ?>
createImageFromPDF({
- required String inputPath,
- required String outputPath,
- ImageFromPdfConfig config = const ImageFromPdfConfig(),
override
Creates images from a PDF file.
This method sends a request to the native platform to extract images from the
PDF file specified in the path
parameter and saves the images in the outputDirPath
directory.
Parameters:
inputPath
: The file path of the PDF from which images will be extracted.outputPath
: The directory path where the images should be saved.config
: A configuration object that specifies how to process the images.rescale
: The scaling configuration for the images (default is the original image).compression
: The image compression level for the images, affecting file size, quality and clarity (default is ImageCompression.none).createOneImage
: Indicates whether to create a single image or separate images for each page (default istrue
).
Returns:
- A
Future<List<String>?>
representing a list of image file paths. If the operation is successful, it returns a list of file paths to the extracted images; otherwise, it returnsnull
.
Implementation
@override
Future<List<String>?> createImageFromPDF({
required String inputPath,
required String outputPath,
ImageFromPdfConfig config = const ImageFromPdfConfig(),
}) async {
final result = await methodChannel.invokeMethod<List<dynamic>>(
'createImageFromPDF',
{
'path': inputPath,
'outputDirPath': outputPath,
'height': config.rescale.height,
'width': config.rescale.width,
'compression': config.compression.value,
'createOneImage': config.createOneImage,
},
);
return result?.cast<String>();
}