패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.0.4

esc_pos_utils_plus

ESC/POS 인쇄를 위한 기본 플러터/다트 클래스입니다. 티켓 클래스는 열식 프린터에 보낼 수 있는 ESC/POS 명령을 생성합니다.

AndroidiOSLinuxmacOSWebWindows
30일 다운로드
14.2만
좋아요
126
Pub 점수
140

패키지 설치

flutter pub add esc_pos_utils_plus

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

ESC/POS 열식 인쇄를 위한 핵심 클래스를 제공하는 Flutter/Dart 패키지입니다. 영수증, 라벨, 티켓 인쇄를 위한 ESC/POS 명령을 생성하는 Ticket 클래스가 포함되어 있습니다. 여러 플랫폼 간 호환성을 고려하여 설계되었으며, 블루투스, Wi-Fi 또는 USB를 통해 형식화된 인쇄 작업을 열식 프린터에 전송할 수 있게 해줍니다. 텍스트 정렬, 글꼴 스타일, 바코드, 이미지 처리를 위한 내장 메서드로 명령 생성이 간편합니다. 포인트 오브 세일 시스템, 키오스크, 영수증 생성 앱에 적합합니다.

사용 사례

  • POS 시스템에서 영수증 인쇄
  • 소매용 레이블 생성
  • 이벤트 티켓 인쇄
  • 주문 확인 출력
  • 모바일 프린터 통합

주요 기능

  • ESC/POS 명령 생성
  • 크로스 플랫폼 지원
  • 텍스트 서식 옵션
  • 바코드 및 이미지 삽입
  • 티켓 생성을 위한 간단한 API

적합한 대상

  • 소매 애플리케이션
  • 포인트 오브 세일 소프트웨어
  • 키오스크 시스템
  • 모바일 인쇄 솔루션
  • 사물인터넷 장치 통합

고려 사항

  • 호환되는 열식 인쇄기 필요
  • 블루투스/와이파이 연결 설정 필요
  • ESC/POS 프로토콜에 한정
  • 내장된 프린터 탐지 없음
  • 특정 플랫폼의 권한이 적용될 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

esc_pos_utils

Pub Version

Base Flutter/Dart classes for ESC/POS printing. Generator class generates ESC/POS commands that can be sent to a thermal printer.

This is the "base" library that used for:

Main Features

  • Connect to Wi-Fi / Ethernet printers
  • Simple text printing using text method
  • Tables printing using row method
  • Text styling:
    • size, align, bold, reverse, underline, different fonts, turn 90°
  • Print images
  • Print barcodes
    • UPC-A, UPC-E, JAN13 (EAN13), JAN8 (EAN8), CODE39, ITF (Interleaved 2 of 5), CODABAR (NW-7), CODE128
  • Paper cut (partial, full)
  • Beeping (with different duration)
  • Paper feed, reverse feed

Note: Your printer may not support some of the presented features (some styles, partial/full paper cutting, reverse feed, barcodes...).

Generate a Ticket

Simple ticket with styles:
List<int> testTicket() {
  final List<int> bytes = [];
  // Using default profile
  final profile = await CapabilityProfile.load();
  final generator = Generator(PaperSize.mm80, profile);
  List<int> bytes = [];

  bytes += generator.text(
      'Regular: aA bB cC dD eE fF gG hH iI jJ kK lL mM nN oO pP qQ rR sS tT uU vV wW xX yY zZ');
  bytes += generator.text('Special 1: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ',
      styles: PosStyles(codeTable: PosCodeTable.westEur));
  bytes += generator.text('Special 2: blåbærgrød',
      styles: PosStyles(codeTable: PosCodeTable.westEur));

  bytes += generator.text('Bold text', styles: PosStyles(bold: true));
  bytes += generator.text('Reverse text', styles: PosStyles(reverse: true));
  bytes += generator.text('Underlined text',
      styles: PosStyles(underline: true), linesAfter: 1);
  bytes += generator.text('Align left', styles: PosStyles(align: PosAlign.left));
  bytes += generator.text('Align center', styles: PosStyles(align: PosAlign.center));
  bytes += generator.text('Align right',
      styles: PosStyles(align: PosAlign.right), linesAfter: 1);

  bytes += generator.text('Text size 200%',
      styles: PosStyles(
        height: PosTextSize.size2,
        width: PosTextSize.size2,
      ));

  bytes += generator.feed(2);
  bytes += generator.cut();
  return bytes;
}
Print a table row:
generator.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),
    ),
  ]);
Print an image:

This package implements 3 ESC/POS functions:

  • ESC * - print in column format
  • GS v 0 - print in bit raster format (obsolete)
  • GS ( L - print in bit raster format

Note that your printer may support only some of the above functions.

import 'dart:io';
import 'package:image/image.dart';

final ByteData data = await rootBundle.load('assets/logo.png');
final Uint8List bytes = data.buffer.asUint8List();
final Image image = decodeImage(bytes);
// Using `ESC *`
generator.image(image);
// Using `GS v 0` (obsolete)
generator.imageRaster(image);
// Using `GS ( L`
generator.imageRaster(image);
Print a Barcode:
final List<int> barData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 4];
generator.barcode(Barcode.upcA(barData));
Print a QR Code:

Using native ESC/POS commands:

generator.qrcode('example.com');

To print a QR Code as an image (if your printer doesn't support native commands), add qr_flutter and path_provider as a dependency in your pubspec.yaml file.

String qrData = "google.com";
const double qrSize = 200;
try {
  final uiImg = await QrPainter(
    data: qrData,
    version: QrVersions.auto,
    gapless: false,
  ).toImageData(qrSize);
  final dir = await getTemporaryDirectory();
  final pathName = '${dir.path}/qr_tmp.png';
  final qrFile = File(pathName);
  final imgFile = await qrFile.writeAsBytes(uiImg.buffer.asUint8List());
  final img = decodeImage(imgFile.readAsBytesSync());

  generator.image(img);
} catch (e) {
  print(e);
}

Using Code Tables

Different printers support different sets of code tables. Some printer models are defined in CapabilityProfile class. So, if you want to change the default code table, it's important to choose the right profile:

// Xprinter XP-N160I
final profile = await CapabilityProfile.load('XP-N160I');
final generator = Generator(PaperSize.mm80, profile);
bytes += generator.setGlobalCodeTable('CP1252');

All available profiles can be retrieved by calling :

final profiles = await CapabilityProfile.getAvailableProfiles();

How to Help

  • Add a CapabilityProfile to support your printer's model. A new profile should be added to lib/resources/capabilities.json file
  • Test your printer and add it in the table: Wifi/Network printer or Bluetooth printer
  • Test and report bugs
  • Share your ideas about what could be improved (code optimization, new features...)

카테고리

의존성

의존성 목록 2 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.

순위