Skip to content

Commit

Permalink
fix(print): remove excess top on ios print
Browse files Browse the repository at this point in the history
  • Loading branch information
iandis committed Sep 29, 2022
1 parent cc2a618 commit f947827
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions lib/blue_print_pos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,36 @@ class BluePrintPos {
batchOptions.getStartEnd(contentLength);

for (final List<int> startEnd in startEndIter) {
final ReceiptSectionText section = receiptSectionText.getSection(
startEnd[0],
startEnd[1],
);
// This is to prevent cropped section at the bottom
if (Platform.isIOS) {
section.addSpacerPx(15);
}
final Uint8List bytes = await contentToImage(
content: receiptSectionText.getContent(startEnd[0], startEnd[1]),
content: section.getContent(),
duration: duration,
textScaleFactor: textScaleFactor,
);
List<int>? croppedExcessTop;
// This is to remove the excess top
if (Platform.isIOS) {
final img.Image? image = img.decodeImage(bytes);
if (image != null) {
final img.Image cropped = img.copyCrop(
image,
0,
45,
image.width,
image.height - 45,
);
croppedExcessTop = img.encodeJpg(cropped);
}
}
final List<int> byteBuffer = await _getBytes(
bytes,
croppedExcessTop ?? bytes,
paperSize: paperSize,
feedCount: feedCount,
useCut: useCut,
Expand Down

0 comments on commit f947827

Please sign in to comment.