Here is one more sample demonstrates capabilities of DYMO Label JavaScript library. The correspondent JavaScript file is here.
Getting Printers
First, the sample shows how to retrieve a list of available DYMO printers. For each printer it shows all the available properties. To get the printer list use dymo.label.framework.getPrinters function. The function returns an array contains information regarding each printer. The sample calls getPrinters and then put all the information onto a table, see createPrintersTable() for details.
Note: There are helpful function to filter the result list to contain only LabelWriter or Tape printers; use dymo.label.framework.getLabelWriterPrinters or dymo.label.framework.getTapePrinters accordingly. This might be useful if your application is designed to print on die-cut labels or D1 tapes only.
Print Multiple Labels
Next, the sample shows how to print multiple labels at once, in one print job. The sample leverages the library’s LabelSet functionality do archive that. For each printer the sample creates one label set record represent data to be printed on one label. also the sample demonstrates how to apply different text styles to the print data. It uses a feature called text markup, the ability to apply formatting attributes/tags very similar to HTML ones.
// create label set to print printers' data var labelSetBuilder = new dymo.label.framework.LabelSetBuilder(); for (var i = 0; i < printers.length; i++) { var printer = printers[i]; // process each printer info as a separate label var record = labelSetBuilder.addRecord(); // compose text data // use framework's text markup feature to set text formatting // because text markup is xml you can use any xml tools to compose it // here we will use simple text manipulations to avoid cross-browser compatibility. var info = "<font family='Courier New' size='14'>"; // default font info = info + "Printer: <b>" + printer.name + "n</b>"; info = info + "PrinterType: " + printer.printerType; info = info + "n<font size='10'>is local: " + printer.isLocal; info = info + "nis online: " + printer.isConnected + "</font>"; if (typeof printer.isTwinTurbo != "undefined") { if (printer.isTwinTurbo) info = info + "<i><u><br/>The printer is TwinTurbo!!!</u></i>"; else info = info + "<font size='6'><br/>Oops, the printer is NOT TwinTurbo</font>"; } if (typeof printer.isAutoCutSupported != "undefined") { if (printer.isAutoCutSupported) info = info + "<i><u><br/>The printer supports auto-cut!!!</u></i>"; else info = info + "<font size='6'><br/>The printer does not supports auto-cut</font>"; } info = info + "</font>"; // when printing put info into object with name "Text" record.setTextMarkup("Text", info); }
See print() function for a complete sample.
Note: Here is another blog post regarding using text markup. And one more regarding printing multiple labels.