createPDFFromMultipleImages method
Future<String?>
createPDFFromMultipleImages({
- required List<
String> inputPaths, - required String outputPath,
- int? maxWidth,
- int? maxHeight,
- bool? needImageCompressor,
override
Creates a PDF from multiple image files.
This method sends a request to the native platform to create a PDF from the
images specified in the paths
parameter. The resulting PDF is saved in the
outputPath
directory.
Parameters:
inputPaths
: A list of file paths of the images to be converted into a PDF.outputPath
: The directory path where the created PDF should be saved.maxWidth
: The maximum width of each image in the PDF (default is 360).maxHeight
: The maximum height of each image in the PDF (default is 360).needImageCompressor
: Whether to compress images before converting them to PDF (default istrue
).
Returns:
- A
Future<String?>
representing the result of the operation. If the operation is successful, it returns a string message from the native platform; otherwise, it returnsnull
.
Implementation
@override
Future<String?> createPDFFromMultipleImages({
required List<String> inputPaths,
required String outputPath,
int? maxWidth,
int? maxHeight,
bool? needImageCompressor,
}) async {
try {
final result = await methodChannel.invokeMethod<String>(
'createPDFFromMultipleImage',
{
'paths': inputPaths,
'outputDirPath': outputPath,
'maxWidth': maxWidth ?? 360,
'maxHeight': maxHeight ?? 360,
'needImageCompressor': needImageCompressor ?? true,
},
);
return result;
} catch (e) {
debugPrint('Error creating PDF from images: $e');
return null;
}
}