'Flutter printing plugin is trimming some text from right side in 80mm page format printing

I am trying to print receipt in 80mm page format using the following plugin: https://pub.dev/packages/printing/example

Receipt is not printing properly. It is trimming the text from right side of page. Here is the view my print receipt Receipt1. Price column is not printing in the receipt.

Here is my code snippet for this receipt layout:

doc.addPage(
    pw.Page(
      pageFormat: PdfPageFormat.roll80,
      theme: pw.ThemeData.withFont(
        base: pw.Font.ttf(font1),
        bold: pw.Font.ttf(font2),
      ),
      margin: pw.EdgeInsets.all(0.0),
      build: (context) {
        return pw.Column(
          mainAxisSize: pw.MainAxisSize.min,
          crossAxisAlignment: pw.CrossAxisAlignment.start,
          children: [
            pw.Container(
              //padding: EdgeInsets.symmetric( horizontal: 15),
              margin: pw.EdgeInsets.only(top: 30),

              alignment: pw.Alignment.center,
              child: pw.ClipOval(
                child: pw.Container(
                  width: 70,
                  height: 70,
                  child: pw.Image(
                    profileImage,
                    fit: pw.BoxFit.cover,
                  ),
                ),
              ),
            ),
            pw.SizedBox(
              height: 30,
            ),
            pw.Container(
              alignment: pw.Alignment.center,
              child: pw.Text(
                name,
                style: pw.TextStyle(
                  color: PdfColors.black,
                  fontWeight: pw.FontWeight.bold,
                  fontSize: 18,
                  font: pw.Font.ttf(font1),
                ),
              ),
            ),
            pw.SizedBox(height: 8),
            pw.Container(
              alignment: pw.Alignment.center,
              child: pw.Text(
                address,
                textAlign: pw.TextAlign.center,
                style: pw.TextStyle(
                  color: PdfColors.black,
                  fontWeight: pw.FontWeight.normal,
                  fontSize: 12,
                  font: pw.Font.ttf(font1),
                ),
              ),
            ),
            pw.SizedBox(
              height: 2,
            ),
            pw.Container(
              alignment: pw.Alignment.center,
              child: pw.Text(
                'Phone No:  ' + phone,
                textAlign: pw.TextAlign.center,
                style: pw.TextStyle(
                  color: PdfColors.black,
                  fontWeight: pw.FontWeight.normal,
                  fontSize: 12,
                  font: pw.Font.ttf(font1),
                ),
              ),
            ),
            pw.SizedBox(
              height: 2,
            ),
            pw.Container(
              alignment: pw.Alignment.center,
              child: pw.Text(
                website,
                textAlign: pw.TextAlign.center,
                style: pw.TextStyle(
                  color: PdfColors.black,
                  fontWeight: pw.FontWeight.normal,
                  fontSize: 12,
                  font: pw.Font.ttf(font1),
                ),
              ),
            ),
            pw.SizedBox(
              height: 20,
            ),
            pw.Container(
              alignment: pw.Alignment.centerLeft,
              child: pw.Text(
                invoiceData['tax_invoice'] == 1
                    ? 'TAX INVOICE  ' + date + ' ' + time
                    : date + ' ' + time,
                style: pw.TextStyle(
                  color: PdfColors.black,
                  fontWeight: pw.FontWeight.normal,
                  fontSize: 12,
                  font: pw.Font.ttf(font1),
                ),
              ),
            ),
            pw.SizedBox(
              height: 10,
            ),
            pw.Container(
              child: pw.Container(
                alignment: pw.Alignment.centerLeft,
                child: pw.Text(
                  'Self Service',
                  style: pw.TextStyle(
                    color: PdfColors.black,
                    fontWeight: pw.FontWeight.normal,
                    fontSize: 12,
                    font: pw.Font.ttf(font1),
                  ),
                ),
              ),
            ),
            pw.SizedBox(
              height: 10,
            ),
            pw.Container(
              child: pw.Row(
                crossAxisAlignment: pw.CrossAxisAlignment.start,
                children: [
                  pw.Container(
                    //width: 30,
                    width: 20,
                    alignment: pw.Alignment.centerLeft,
                    child: pw.SizedBox(
                      child: pw.Text(
                        'Qty',
                        style: pw.TextStyle(
                          color: PdfColors.black,
                          fontWeight: pw.FontWeight.normal,
                          fontSize: 12,
                          font: pw.Font.ttf(font1),
                        ),
                      ),
                    ),
                  ),
                  pw.SizedBox(
                    width: 5,
                  ),
                  pw.Expanded(
                    child: pw.Container(
                      alignment: pw.Alignment.centerLeft,
                      child: pw.Text(
                        'Item',
                        style: pw.TextStyle(
                          color: PdfColors.black,
                          fontWeight: pw.FontWeight.normal,
                          fontSize: 12,
                          font: pw.Font.ttf(font1),
                        ),
                      ),
                    ),
                  ),
                  pw.SizedBox(
                    width: 5,
                  ),
                  pw.Container(
                    //width: 70,
                    alignment: pw.Alignment.centerRight,
                    child: pw.Text(
                      'Price',
                      style: pw.TextStyle(
                        color: PdfColors.black,
                        fontWeight: pw.FontWeight.normal,
                        fontSize: 12,
                        font: pw.Font.ttf(font1),
                      ),
                    ),
                  ),
                ],
              ),
            ),
            pw.SizedBox(
              height: 5,
            ),
            pw.Column(
              crossAxisAlignment: pw.CrossAxisAlignment.start,
              children: [
                pw.Container(
                  child: pw.ListView.separated(
                    itemCount: orderItem.length,
                    itemBuilder: (context, index) {
                      return pw.Container(
                        child: pw.Row(
                          children: [
                            pw.Container(
                              //width: 30,
                              width: 20,
                              alignment: pw.Alignment.centerLeft,
                              child: pw.SizedBox(
                                child: pw.Text(
                                  orderItem[index].quantity.toString(),
                                  style: pw.TextStyle(
                                    color: PdfColors.black,
                                    fontWeight: pw.FontWeight.normal,
                                    fontSize: 12,
                                    font: pw.Font.ttf(font1),
                                  ),
                                ),
                              ),
                            ),
                            pw.SizedBox(
                              width: 5,
                            ),
                            pw.Expanded(
                              child: pw.Container(
                                alignment: pw.Alignment.centerLeft,
                                child: pw.Column(
                                  children: [
                                    pw.Container(
                                      alignment: pw.Alignment.centerLeft,
                                      child: pw.Text(
                                        orderItem[index].name,
                                        style: pw.TextStyle(
                                          color: PdfColors.black,
                                          fontWeight: pw.FontWeight.normal,
                                          fontSize: 12,
                                          font: pw.Font.ttf(font1),
                                        ),
                                      ),
                                    ),
                                    invoiceData['modifiers'] == 1
                                        ? pw.Container(
                                            alignment: pw.Alignment.centerLeft,
                                            child: getExtras(
                                                orderItem[index], font1),
                                          )
                                        : pw.SizedBox(),
                                  ],
                                ),
                              ),
                            ),
                            pw.SizedBox(
                              width: 5,
                            ),
                            pw.Container(
                              //width: 70,
                              alignment: pw.Alignment.centerRight,
                              child: pw.Text(
                                orderItem[index].totalPrice.toStringAsFixed(2),
                                style: pw.TextStyle(
                                  color: PdfColors.black,
                                  fontWeight: pw.FontWeight.normal,
                                  fontSize: 12,
                                  font: pw.Font.ttf(font1),
                                ),
                              ),
                            ),
                          ],
                        ),
                      );
                    },
                    separatorBuilder: (context, index) {
                      return pw.SizedBox(height: 5);
                    },
                  ),
                ),
                pw.SizedBox(
                  height: 20,
                ),
                invoiceData['show_subtotal'] == 1
                    ? pw.Container(
                        child: pw.Row(
                          children: [
                            pw.Container(
                              width: 25,
                            ),
                            pw.Expanded(
                              child: pw.Container(
                                alignment: pw.Alignment.centerLeft,
                                child: pw.Text(
                                  'SUB TOTAL',
                                  style: pw.TextStyle(
                                    color: PdfColors.black,
                                    fontWeight: pw.FontWeight.normal,
                                    fontSize: 12,
                                    font: pw.Font.ttf(font1),
                                  ),
                                ),
                              ),
                            ),
                            pw.Container(
                              // width: 150,
                              alignment: pw.Alignment.centerRight,
                              child: pw.Text(
                                '\$' + globals.totalPrice.toStringAsFixed(2),
                                style: pw.TextStyle(
                                  color: PdfColors.black,
                                  fontWeight: pw.FontWeight.normal,
                                  fontSize: 12,
                                  font: pw.Font.ttf(font1),
                                ),
                              ),
                            ),
                          ],
                        ),
                      )
                    : pw.SizedBox(),
                pw.Container(
                  child: pw.Row(
                    children: [
                      pw.Container(
                        width: 25,
                      ),
                      pw.Expanded(
                        child: pw.Container(
                          alignment: pw.Alignment.centerLeft,
                          child: pw.Text(
                            'GST',
                            style: pw.TextStyle(
                              color: PdfColors.black,
                              fontWeight: pw.FontWeight.normal,
                              fontSize: 12,
                              font: pw.Font.ttf(font1),
                            ),
                          ),
                        ),
                      ),
                      pw.Container(
                        // width: 150,
                        alignment: pw.Alignment.centerRight,
                        child: pw.Text(
                          '\$' + globals.totalGST.toStringAsFixed(2),
                          style: pw.TextStyle(
                            color: PdfColors.black,
                            fontWeight: pw.FontWeight.normal,
                            fontSize: 12,
                            font: pw.Font.ttf(font1),
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
                pw.Container(
                  child: pw.Row(
                    children: [
                      pw.Container(
                        width: 25,
                      ),
                      pw.Expanded(
                        child: pw.Container(
                          alignment: pw.Alignment.centerLeft,
                          child: pw.Text(
                            'TOTAL',
                            style: pw.TextStyle(
                              color: PdfColors.black,
                              fontWeight: pw.FontWeight.normal,
                              fontSize: 12,
                              font: pw.Font.ttf(font1),
                            ),
                          ),
                        ),
                      ),
                      pw.Container(
                        // width: 150,
                        alignment: pw.Alignment.centerRight,
                        child: pw.Text(
                          '\$' + globals.totalPrice.toStringAsFixed(2),
                          style: pw.TextStyle(
                            color: PdfColors.black,
                            fontWeight: pw.FontWeight.normal,
                            fontSize: 12,
                            font: pw.Font.ttf(font1),
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
                pw.Container(
                  // width: 150,
                  alignment: pw.Alignment.centerRight,
                  child: pw.Text(
                    'EFTPOS',
                    style: pw.TextStyle(
                      color: PdfColors.black,
                      fontWeight: pw.FontWeight.normal,
                      fontSize: 12,
                      font: pw.Font.ttf(font1),
                    ),
                  ),
                ),
              ],
            ),
            pw.SizedBox(
              height: 30,
            ),
            pw.Container(
              alignment: pw.Alignment.centerLeft,
              child: pw.Text(
                'Receipt No. ' + orderID,
                style: pw.TextStyle(
                  color: PdfColors.black,
                  fontWeight: pw.FontWeight.normal,
                  fontSize: 20,
                  font: pw.Font.ttf(font2),
                ),
              ),
            ),
            pw.SizedBox(
              height: 5,
            ),
            pw.Container(
              alignment: pw.Alignment.centerLeft,
              child: pw.Text(
                note,
                style: pw.TextStyle(
                  color: PdfColors.black,
                  fontWeight: pw.FontWeight.normal,
                  fontSize: 12,
                  font: pw.Font.ttf(font1),
                ),
              ),
            ),
          ],
        );
      },
    ),
  );
  
  return doc.save();

Anyone help me out with this issue. Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source