import { StarXpandCommand } from "star-io10-web"; export class LabelSample02_For300dpi_JapaneseFoodLabelCake_Template { static async createTemplate(): Promise { let builder = new StarXpandCommand.StarXpandCommandBuilder(); builder.addDocument( new StarXpandCommand.DocumentBuilder() .settingPrintableArea(48.7) .addPrinter( new StarXpandCommand.PrinterBuilder() // モデルにより対応する文字エンコーディング指定APIが異なります。 // 下記ページのSupported Modelを参照し、ご利用のモデルが対応するAPIを使用してください。 // https://www.star-m.jp/products/s_print/sdk/star-io10-web/manual/ja/api-reference/star-xpand-command/printer-builder/style-cjk-character-priority.html .styleCjkCharacterPriority([ StarXpandCommand.Printer.CjkCharacterType.Japanese, ]) // https://www.star-m.jp/products/s_print/sdk/star-io10-web/manual/ja/api-reference/star-xpand-command/printer-builder/style-second-priority-character-encoding.html //.styleSecondPriorityCharacterEncoding(CharacterEncodingType.Japanese) .addPageMode( new StarXpandCommand.Printer.PageModeAreaParameter(48.7, 33.3), new StarXpandCommand.PageModeBuilder() .actionPrintRectangle( new StarXpandCommand.Printer.PageModeRectangleParameter( 0.0, 2.3, 41.0, 31.0, ), ) .actionPrintRuledLine( new StarXpandCommand.Printer.PageModeRuledLineParameter( 0.0, 5.0, 41.0, 5.0, ), ) .actionPrintRuledLine( new StarXpandCommand.Printer.PageModeRuledLineParameter( 0.0, 13.5, 41.0, 13.5, ), ) .actionPrintRuledLine( new StarXpandCommand.Printer.PageModeRuledLineParameter( 0.0, 16.2, 41.0, 16.2, ), ) .actionPrintRuledLine( new StarXpandCommand.Printer.PageModeRuledLineParameter( 0.0, 18.9, 41.0, 18.9, ), ) .actionPrintRuledLine( new StarXpandCommand.Printer.PageModeRuledLineParameter( 0.0, 24.5, 41.0, 24.5, ), ) .actionPrintRuledLine( new StarXpandCommand.Printer.PageModeRuledLineParameter( 12.5, 2.3, 12.5, 33.3, ), ) .styleHorizontalPositionTo(0.5) .styleVerticalPositionTo(0.0) .actionPrintText("品 名") .styleHorizontalPositionTo(20.0) .actionPrintText("${name}\n") .styleHorizontalPositionTo(0.5) .actionPrintText("名 称") .styleHorizontalPositionTo(23.0) .actionPrintText("${classification}\n") .styleHorizontalPositionTo(0.5) .actionPrintText("原材料名") .addPageMode( new StarXpandCommand.Printer.PageModeAreaParameter(26.0, 16.0) .setX(13.0) .setY(5.5), new StarXpandCommand.PageModeBuilder().actionPrintText( "${ingredients}\n", ), ) .styleHorizontalPositionTo(0.5) .styleVerticalPositionTo(14.0) .actionPrintText("内容量") .styleHorizontalPositionTo(13.0) .actionPrintText("${contents}\n") .styleHorizontalPositionTo(0.5) .actionPrintText("消費期限") .styleHorizontalPositionTo(13.0) .actionPrintText("${expiry_date}\n") .styleHorizontalPositionTo(0.5) .actionPrintText("保存方法") .addPageMode( new StarXpandCommand.Printer.PageModeAreaParameter(26.0, 12.0) .setX(13.0) .setY(19.5), new StarXpandCommand.PageModeBuilder().actionPrintText( "${preservation_method}", ), ) .styleHorizontalPositionTo(0.5) .styleVerticalPositionTo(25.0) .actionPrintText("製造者") .addPageMode( new StarXpandCommand.Printer.PageModeAreaParameter(26.0, 12.0) .setX(13.0) .setY(25.0), new StarXpandCommand.PageModeBuilder().actionPrintText( "${manufacturer}", ), ) .actionPrintImage( new StarXpandCommand.Printer.PageModeImageParameter( "japanese_food_label_cake_plastic.png", 42.0, 0.0, 48, ), ) .stylePrintDirection(StarXpandCommand.Printer.PageModePrintDirection.BottomToTop) .styleHorizontalPositionTo(2.0) .styleVerticalPositionTo(43.0) .actionPrintBarcode( new StarXpandCommand.Printer.BarcodeParameter( "${sku}", StarXpandCommand.Printer.BarcodeSymbology.Jan13, ) .setBarDots(3) .setHeight(3.0) .setPrintHri(true), ), ) .actionCut(StarXpandCommand.Printer.CutType.Partial), ), ); return await builder.getCommands(); } static async getFieldData(): Promise { return Promise.resolve( `{ "name" : "ロールケーキ", "classification" : "洋菓子", "ingredients" : "卵、砂糖、小麦粉、ショートニング、油脂、ベーキングパウダー", "contents" : "1個", "expiry_date" : "2010年01月31日", "preservation_method" : "直射日光・高温多湿を避けて、保存してください。", "manufacturer" : "スターショップ\\nXXX県XXX市XXX町123-1\\nTEL 1234-567-890", "sku" : "0123456789012" }`, ); } }