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 compression, 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 JSString jsInputPath = inputPath.toJS;
final JSArray<JSString> result = config.createOneImage
? (await pdfToImage(jsInputPath, config.jsify()).toDart)
as JSArray<JSString>
: (await convertPdfToImages(jsInputPath, config.jsify()).toDart)
as JSArray<JSString>;
return result.toList();
}