trySavePdf method
Future<void>
trySavePdf({
- required String fileName,
- SaveMode saveMode = SaveMode.filePicker,
- String filePickerTitle = "",
- PdfPageMode pageMode = PdfPageMode.thumbs,
- bool compress = false,
- PdfVersion pdfVersion = PdfVersion.pdf_1_5,
- PdfPageFormat pageFormat = PdfPageFormat.undefined,
- PageOrientation? pageOrientation,
- String? title,
- String? author,
- String? creator,
- String? subject,
- String? keywords,
- String? producer,
- void onError()?,
This method saves into a PDF file the binary data obtained from a widget rendering
task, based on the directive passed to saveMode
.
If there is no Widget attached or if an error occurs during the convertion, this
method executes the callback passed to the onError
argument.
Implementation
Future<void> trySavePdf({
required String fileName,
SaveMode saveMode = SaveMode.filePicker,
String filePickerTitle = "",
PdfPageMode pageMode = PdfPageMode.thumbs,
bool compress = false,
PdfVersion pdfVersion = PdfVersion.pdf_1_5,
PdfPageFormat pageFormat = PdfPageFormat.undefined,
pdf_widgets.PageOrientation? pageOrientation,
String? title,
String? author,
String? creator,
String? subject,
String? keywords,
String? producer,
void Function()? onError
}) async {
try {
await savePdf(
fileName: fileName,
saveMode: saveMode,
filePickerTitle: filePickerTitle,
pageMode: pageMode,
compress: compress,
pdfVersion: pdfVersion,
pageFormat: pageFormat,
pageOrientation: pageOrientation,
title: title,
author: author,
creator: creator,
subject: subject,
keywords: keywords,
producer: producer
);
} on Exception catch(_) {
if(onError != null) {
onError();
}
}
}