generatePdf method
Generate PDF from Images, Template, and Patterns.
pages
: NewPages to be added to the PDF.
outputPath
: The path to the output file.
Returns the path to the generated PDF path or null if the input is invalid or if the PDF generation fails.
Implementation
Future<String?> generatePdf(List<NewPage> pages, String outputPath) async {
try {
return await _channel.invokeMethod(
'generatePDF',
<String, dynamic>{
'pages': pages
.map((page) => page.toMap())
.toList(), // Converting [NewPage] to map
'outputFilePath': outputPath,
},
);
} on PlatformException catch (e) {
if (kDebugMode) {
print(e);
}
return null;
}
}