9

変数を含む事前に作成されたラベル(Zeba Label Designerを使用して作成)を印刷し、印刷する前にそれらの変数を設定するにはどうすればよいですか。

次のコードがありますが、変数の設定方法がわかりません(たとえば、デザインしたラベルにQRコードがあり、印刷する前にデータを設定したい)。

TcpPrinterConnection zebraPrinterConnection = new TcpPrinterConnection("192.168.1.100", TcpPrinterConnection.DEFAULT_ZPL_TCP_PORT);
 try {
     ZebraPrinter printer = ZebraPrinterFactory.getInstance(zebraPrinterConnection);
     printer.getFileUtil().sendFileContents("/sdcard/documents/labels/sample.lbl");
     zebraPrinterConnection.close();
 } catch (ZebraPrinterConnectionException e) {
     e.printStackTrace();
 } catch (ZebraPrinterLanguageUnknownException e) {
     e.printStackTrace();
 } catch (ZebraIllegalArgumentException e) {
     e.printStackTrace();
 }
4

1 に答える 1

7

Zebra Label Designer からの出力を見て変数を取得し、sdk を介してそれらを接続する必要があります。

ZebraLink SDK に付属のドキュメントを確認してください。保存された形式を印刷する方法についての良い例がたくさんあります。例の 1 つを次に示します。この例では、「First Name」変数の番号は 12 です。「Last Name」変数の番号は 11 です。

 ^XA
 ^DFE:FORMAT.ZPL
 ^FS
 ^FT26,243^A0N,56,55^FH\^FN12"First Name"^FS
 ^FT26,296^A0N,56,55^FH\^FN11"Last Name"^FS
 ^FT258,73^A0N,39,38^FH\^FDVisitor^FS
 ^BY2,4^FT403,376^B7N,4,0,2,2,N^FH^FDSerial Number^FS
 ^FO5,17^GB601,379,8^FS
 ^XZ

 TcpPrinterConnection zebraPrinterConnection = new TcpPrinterConnection("192.168.1.32", TcpPrinterConnection.DEFAULT_ZPL_TCP_PORT);
 try {
     zebraPrinterConnection.open();
     ZebraPrinter printer = ZebraPrinterFactory.getInstance(zebraPrinterConnection);
     Map<Integer, String> vars = new HashMap<Integer, String>();
     vars.put(12, "John");
     vars.put(11, "Smith");
     printer.getFormatUtil().printStoredFormat("E:FORMAT.ZPL", vars);
     zebraPrinterConnection.close();
 } catch (ZebraPrinterConnectionException e) {
     e.printStackTrace();
 } catch (ZebraPrinterLanguageUnknownException e) {
     e.printStackTrace();
 }
于 2011-10-11T19:55:23.637 に答える