toEscPosPrinter method

Future<List<Image>> toEscPosPrinter(
  1. BuildContext context, {
  2. int maxHeight = 2000,
  3. double? maxWidth,
  4. int margin = 0,
  5. double fixedRatio = 0,
})

Converte o DANFE em uma lista de imagens decodificadas para impressoras ESC/POS.

Retorna objetos Image do pacote image, adequados para processamento com bibliotecas ESC/POS.

Parâmetros:

  • context: BuildContext necessário para renderização.
  • maxHeight: Altura máxima por chunk de imagem. Padrão é 2000.
  • maxWidth: Largura máxima das imagens. Se não fornecido, usa a largura do papel.
  • margin: Margem horizontal. Padrão é 0.
  • fixedRatio: Proporção fixa para qualidade da imagem.

Retorno:

  • Um Future<List<decoder.Image>> contendo as imagens decodificadas.

Exemplo:

List<decoder.Image> rasterImages = await imageDanfe.toEscPosPrinter(context);
for (var image in rasterImages) {
  await escPosPrinter.printRaster(image);
}

Implementation

Future<List<decoder.Image>> toEscPosPrinter(
  BuildContext context, {
  int maxHeight = 2000,
  double? maxWidth,
  int margin = 0,
  double fixedRatio = 0,
}) async {
  return await _printerGateway.toEscPosPrinter(
    context,
    maxHeight: maxHeight,
    maxWidth: maxWidth ?? paperSize.maxWidth,
    margin: margin,
    fixedRatio: fixedRatio,
  );
}