createImageFromPDF method

  1. @override
Future<List<String>?> createImageFromPDF({
  1. required String inputPath,
  2. required String outputPath,
  3. int? maxWidth,
  4. int? maxHeight,
  5. 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 is true).

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 returns null.

Implementation

@override
Future<List<String>?> createImageFromPDF({
  required String inputPath,
  required String outputPath,
  int? maxWidth,
  int? maxHeight,
  bool? createOneImage,
}) async {
  final result = await methodChannel.invokeMethod<List<dynamic>>(
    'createImageFromPDF',
    {
      'path': inputPath,
      'outputDirPath': outputPath,
      'maxWidth': maxWidth ?? 360,
      'maxHeight': maxHeight ?? 360,
      'createOneImage': createOneImage ?? true,
    },
  );
  return result?.cast<String>();
}