postProcess method
Implementation
void postProcess(Document document) {
final canvas = _pdfPage!.getGraphics();
canvas.reset();
final _margin = resolvedMargin;
var constraints = mustRotate
? BoxConstraints(
maxWidth: pageFormat.height - _margin!.vertical,
maxHeight: pageFormat.width - _margin.horizontal)
: BoxConstraints(
maxWidth: pageFormat.width - _margin!.horizontal,
maxHeight: pageFormat.height - _margin.vertical);
final calculatedTheme = theme ?? document.theme ?? ThemeData.base();
final context = Context(
document: document.document,
page: _pdfPage!,
canvas: canvas,
).inheritFromAll(<Inherited>[
calculatedTheme,
if (pageTheme.textDirection != null)
InheritedDirectionality(pageTheme.textDirection),
]);
Widget? background;
Widget? content;
Widget? foreground;
content = _build(context);
final size = layout(content, context, constraints);
if (_pdfPage!.pageFormat.height == double.infinity) {
_pdfPage!.pageFormat =
_pdfPage!.pageFormat.copyWith(width: size.x, height: size.y);
constraints = mustRotate
? BoxConstraints(
maxWidth: _pdfPage!.pageFormat.height - _margin.vertical,
maxHeight: _pdfPage!.pageFormat.width - _margin.horizontal)
: BoxConstraints(
maxWidth: _pdfPage!.pageFormat.width - _margin.horizontal,
maxHeight: _pdfPage!.pageFormat.height - _margin.vertical);
}
if (pageTheme.buildBackground != null) {
background = pageTheme.buildBackground!(context);
layout(background, context, constraints);
}
if (pageTheme.buildForeground != null) {
foreground = pageTheme.buildForeground!(context);
layout(foreground, context, constraints);
}
assert(() {
if (Document.debug) {
debugPaint(context);
}
return true;
}());
if (background != null) {
paint(background, context);
}
paint(content, context);
if (foreground != null) {
paint(foreground, context);
}
}