本文へ移動
rdlabo.devdocs

Print

printImage は base64 画像(MIME タイプを除いたもの)を Brother プリンターへ送ります。インストール のあとで呼び出します。プリンターの探索は Search、印刷結果は印刷前に Events を登録します。

実画像を自分で用意します(例: アプリ内の PNG/JPEG を encode し、data:...;base64, 接頭辞があれば除去)。portchannelInfoonPrinterAvailable で保持した BRLMChannelResult から取ります。modelName / labelName は端末と 対応モデル 表に合わせて選びます。固定 IP やダミー base64 を書かないでください。

import {
  BrotherPrint,
  BRLMPrinterLabelName,
  BRLMPrinterModelName,
} from '@rdlabo/capacitor-brotherprint';
import type { BRLMChannelResult, BRLMPrintOptions } from '@rdlabo/capacitor-brotherprint';

const printImage = async (printer: BRLMChannelResult, encodedImage: string) => {
  const options: BRLMPrintOptions = {
    modelName: BRLMPrinterModelName.QL_820NWB,
    labelName: BRLMPrinterLabelName.RollW62,
    encodedImage,
    numberOfCopies: 1,
    autoCut: true,
    port: printer.port,
    channelInfo: printer.channelInfo,
  };

  await BrotherPrint.printImage(options);
};

完全なページはデモを見てください:

https://github.com/rdlabo-dev/capacitor-brotherprint/blob/v8.2.1/demo/src/app/home/home.page.tshttps://github.com/rdlabo-dev/capacitor-brotherprint/blob/v8.2.1/demo/src/app/home/home.page.ts

method printImage(...)

printImage(options: BRLMPrintOptions) => Promise<void>

type alias BRLMPrintOptions

{ encodedImage: string; /** * Should use enum BRLMPrinterModelName */ modelName: BRLMPrinterModelName; } & Partial<BRLMChannelResult> & (BRLMPrinterQLModelSettings | BRLMPrinterTDModelSettings)