createDocument method
Future<Document?>
createDocument({
- DeltaAttributesOptions? deltaOptionalAttr,
- bool overrideAttributesPassedByUser = false,
- void onException(
- dynamic error
- bool shouldProcessDeltas = true,
Creates the PDF document an return this one
Implementation
Future<pw.Document?> createDocument({
qpdf.DeltaAttributesOptions? deltaOptionalAttr,
bool overrideAttributesPassedByUser = false,
void Function(dynamic error)? onException,
bool shouldProcessDeltas = true,
}) async {
deltaOptionalAttr ??= qpdf.DeltaAttributesOptions.common();
final qpdf.Converter<Delta, pw.Document> converter = qpdf.PdfService(
pageFormat: pageFormat,
fonts: globalFontsFallbacks,
onRequestBoldFont: onRequestBoldFont,
onRequestBothFont: onRequestBoldItalicFont,
customTheme: themeData,
textDirection: textDirection.toPdf(),
customBuilders: customBuilders,
blockQuoteBackgroundColor: blockQuoteBackgroundColor,
blockQuoteDividerColor: blockQuoteDividerColor,
codeBlockBackgroundColor: codeBlockBackgroundColor,
codeBlockFont: codeBlockFont,
codeBlockNumLinesTextStyle: codeBlockNumLinesTextStyle,
codeBlockTextStyle: codeBlockTextStyle,
blockQuoteTextStyle: blockQuoteTextStyle,
onRequestFallbacks: onRequestFallbackFont,
onDetectAlignedParagraph: onDetectAlignedParagraph,
onDetectCommonText: onDetectCommonText,
onDetectBlockquote: onDetectBlockquote,
onDetectCodeBlock: onDetectCodeBlock,
blockQuotePaddingLeft: blockQuotePaddingLeft,
blockQuotePaddingRight: blockQuotePaddingRight,
blockQuotethicknessDividerColor: blockQuotethicknessDividerColor,
onDetectHeaderBlock: onDetectHeaderBlock,
onDetectImageBlock: onDetectImageBlock,
onDetectInlineRichTextStyles: onDetectInlineRichTextStyles,
onDetectLink: onDetectLink,
onDetectList: onDetectList,
onRequestFont: onRequestFont,
backM: !shouldProcessDeltas
? backMatterDelta
: processDelta(backMatterDelta, deltaOptionalAttr,
overrideAttributesPassedByUser),
frontM: !shouldProcessDeltas
? frontMatterDelta
: processDelta(frontMatterDelta, deltaOptionalAttr,
overrideAttributesPassedByUser),
onRequestItalicFont: onRequestItalicFont,
document: !shouldProcessDeltas
? document
: processDelta(
document, deltaOptionalAttr, overrideAttributesPassedByUser)!,
);
try {
return await converter.generateDoc();
} catch (e) {
onException?.call(e);
rethrow;
}
}