#1434 print: do not rotate image to fit page

This commit is contained in:
Thibault Deckers 2025-02-16 22:24:07 +01:00
parent 5f26cfbbf3
commit ec9cb234a8

View file

@ -41,23 +41,21 @@ class EntryPrinter with FeedbackMixin {
final displaySize = entry.displaySize; final displaySize = entry.displaySize;
final pageTheme = pdf.PageTheme( final pageTheme = pdf.PageTheme(
pageFormat: pageFormat, pageFormat: pageFormat,
orientation: displaySize.height > displaySize.width ? pdf.PageOrientation.portrait : pdf.PageOrientation.landscape, orientation: displaySize.aspectRatio < 1 ? pdf.PageOrientation.portrait : pdf.PageOrientation.landscape,
margin: pdf.EdgeInsets.zero, margin: pdf.EdgeInsets.zero,
theme: null, theme: null,
clip: false, clip: false,
textDirection: null, textDirection: null,
); );
final mustRotate = pageTheme.mustRotate;
final childSize = mustRotate ? Size(displaySize.height, displaySize.width) : displaySize;
return pdf.Page( return pdf.Page(
pageTheme: pageTheme, pageTheme: pageTheme,
build: (context) => pdf.FullPage( build: (context) => pdf.FullPage(
ignoreMargins: true, ignoreMargins: true,
child: pdf.Center( child: pdf.Center(
child: pdf.Transform.scale( child: pdf.Transform.scale(
scale: min(pageFormat.availableWidth / childSize.width, pageFormat.availableHeight / childSize.height), scale: min(pageFormat.availableWidth / displaySize.width, pageFormat.availableHeight / displaySize.height),
child: pdf.Transform.rotateBox( child: pdf.Transform.rotateBox(
angle: pageTheme.mustRotate ? -0.5 * pi : 0, angle: 0,
unconstrained: true, unconstrained: true,
child: imageWidget, child: imageWidget,
), ),