Skip to content

Commit

Permalink
change pageFormat, add landscape variable, remove custom pageFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGumpIT committed Feb 5, 2024
1 parent b4d1075 commit 7ea66c8
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions app/lib/cubits/current_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -637,21 +637,46 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {
if (area == null || page == null) {
continue;
}
final pageFormat =
PdfPageFormat(area.width * quality, area.height * quality);

final image = await render(document, page, info,
width: area.width,
height: area.height,
x: area.position.x,
y: area.position.y,
quality: quality,
renderBackground: renderBackground);
if (image == null) continue;
pdf.addPage(pw.Page(
pageFormat: pageFormat,
build: (context) {
return pw.Image(pw.MemoryImage(image.buffer.asUint8List()));
}));

// * * use this variable for set landscape
bool landscape = false;
if (landscape == true) {
if (image == null) continue;
pdf.addPage(pw.Page(
pageFormat: PdfPageFormat.a4.landscape,
orientation: pw.PageOrientation.landscape,
build: (pw.Context contex) {
return pw.FullPage(
ignoreMargins: true,
child: pw.Image(
pw.MemoryImage(image.buffer.asUint8List()),
fit: pw.BoxFit.fill,
),
);
}));
} else {
if (image == null) continue;
pdf.addPage(pw.Page(
// pageFormat: PdfPageFormat.a4.landscape,orientation: pw.PageOrientation.landscape,
pageFormat: PdfPageFormat.a4,
build: (pw.Context contex) {
return pw.FullPage(
ignoreMargins: true,
child: pw.Image(
pw.MemoryImage(image.buffer.asUint8List()),
fit: pw.BoxFit.fill,
),
);
}));
}
}
return pdf;
}
Expand Down

0 comments on commit 7ea66c8

Please sign in to comment.