hendren
hendren

Reputation: 19

I am trying to print columns with space between columns in flutter using network printer but problem it show columns without space

*printing columns inside row using network printer*

this is code that I used

import 'package:esc_pos_printer/esc_pos_printer.dart';
import 'package:esc_pos_utils/esc_pos_utils.dart';

printItem() async {
  const PaperSize paper = PaperSize.mm80;

  final profile = await CapabilityProfile.load();
  final printer = NetworkPrinter(paper, profile, spaceBetweenRows: 30);

  final PosPrintResult res =
      await printer.connect('192.168.100.30', port: 9100);

  if (res == PosPrintResult.success) {
    printer.row([
      PosColumn(
        text: 'col3',
        width: 3,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col6',
        width: 6,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col3',
        width: 3,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
    ]);
    printer.row([
      PosColumn(
        text: 'col3',
        width: 3,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col6',
        width: 6,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col3',
        width: 3,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
    ]);
    printer.feed(2);
    printer.cut();
    printer.disconnect();
    print('Print result: ${res.msg}');
  }
}

this result of the code: enter image description here this is a link that flutters dependency that I used: enter link description here this is result that expected for columns how to be: enter image description here

Upvotes: 2

Views: 1407

Answers (1)

Zeeshan
Zeeshan

Reputation: 9

printer.row([
 PosColumn(
        text: '',
        width: 2,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col3',
        width: 3,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
 PosColumn(
        text: '',
        width: 2, #As your width size
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col6',
        width: 6,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
PosColumn(
        text: '',
        width: 2,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col3',
        width: 3,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
    ]);

Upvotes: -1

Related Questions