createImageFromPDF method
Future<List<String> ?>
createImageFromPDF({
- required String inputPath,
- required String outputPath,
- int? maxWidth,
- int? maxHeight,
- bool? createOneImage,
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.maxWidth
: The maximum width of each extracted image (default is 360).maxHeight
: The maximum height of each extracted image (default is 360).createOneImage
: Whether to create a single image from all PDF pages 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,
int? maxWidth,
int? maxHeight,
bool? createOneImage,
}) async {
try {
final List<dynamic>? result =
await methodChannel.invokeMethod<List<dynamic>>(
'createImageFromPDF',
{
'path': inputPath,
'outputDirPath': outputPath,
'maxWidth': maxWidth ?? 360,
'maxHeight': maxHeight ?? 360,
'createOneImage': createOneImage ?? true,
},
);
return result?.cast<String>();
} catch (e) {
debugPrint('Error creating images from PDF: $e');
return null;
}
}