createPDFFromMultipleImages method
Future<String>
createPDFFromMultipleImages({
- required List<
MergeInput> inputs, - required String outputPath,
- PdfFromMultipleImageConfig config = const PdfFromMultipleImageConfig(),
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 inputs parameter. The resulting PDF is saved in the
outputPath directory.
Parameters:
inputs: A list of MergeInput to be converted into a PDF.outputPath: The directory path where the created PDF 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).keepAspectRatio: Indicates whether to maintain the aspect ratio of the images (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<MergeInput> inputs,
required String outputPath,
PdfFromMultipleImageConfig config = const PdfFromMultipleImageConfig(),
}) async {
final inputPaths = await Future.wait(inputs.map(
(MergeInput input) async => await DocumentUtils.prepareInput(input)));
final JSArray<JSString> jsInputPaths = inputPaths.toJSArray();
final JSString result =
(await createPdfFromImages(jsInputPaths, config.toMap().jsify()).toDart)
as JSString;
return result.toDart;
}