import { StarXpandCommand } from "star-io10-web"; export class LabelSample06_For203dpiAnd300dpi_DrinkLabel5_Template { static async createTemplate(): Promise { let builder = new StarXpandCommand.StarXpandCommandBuilder(); builder.addDocument( new StarXpandCommand.DocumentBuilder() // Change the printable area setting for this layout according to the printer resolution. // 48.0 for 203dpi, 48.7 for 300dpi .settingPrintableArea(48.0) //.settingPrintableArea(48.7) .addPrinter( new StarXpandCommand.PrinterBuilder() // By setting the base print size of text to x1.5 for 300dpi, // you can print text at the same size as 203dpi. //.styleBaseMagnification(new BaseMagnificationParameter().setText(BaseMagnification.X1_5)) .styleAlignment(StarXpandCommand.Printer.Alignment.Center) .styleLineSpace(1.0) .add( new StarXpandCommand.PrinterBuilder() .styleInvert(true) .styleMagnification( new StarXpandCommand.MagnificationParameter(2, 2), ) .actionPrintText("${header}\n"), ) .add( new StarXpandCommand.PrinterBuilder() .styleMagnification( new StarXpandCommand.MagnificationParameter(1, 2), ) .actionPrintText("${order_types}\n"), ) .add( new StarXpandCommand.PrinterBuilder() .styleMagnification( new StarXpandCommand.MagnificationParameter(2, 2), ) .actionPrintText("#${order_number%04d}\n"), ) .actionPrintText("${time}\n") .actionPrintText("--------------------------------\n") .add( new StarXpandCommand.PrinterBuilder() .styleAlignment(StarXpandCommand.Printer.Alignment.Left) .styleMagnification( new StarXpandCommand.MagnificationParameter(1, 2), ) .actionPrintText("${product_name}\n") .add( new StarXpandCommand.PrinterBuilder( new StarXpandCommand.Printer.PrinterParameter().setTemplateExtension( new StarXpandCommand.TemplateExtensionParameter().setEnableArrayFieldData( true, ), ), ) .styleHorizontalPositionTo(3.0) .actionPrintText("${item_list.detail}\n"), ), ) .actionPrintText("--------------------------------\n") .add( new StarXpandCommand.PrinterBuilder() .styleInvert(true) .styleMagnification( new StarXpandCommand.MagnificationParameter(2, 2), ) .actionPrintText("${footer}\n"), ) .actionCut(StarXpandCommand.Printer.CutType.Partial), ), ); return await builder.getCommands(); } static async getFieldData(): Promise { return Promise.resolve( `{ "header" : " * MODIFY * ", "order_types" : "Eat In", "order_number" : 2956, "time" : "9:49:16 AM", "product_name" : "Star Macchiato", "item_list" : [ { "detail" : "Almond Milk" } ], "footer" : " * MODIFY * " }`, ); } }