У меня есть веб-страница для печати метки адреса, которая раньше нормально работала на старом DYMO SDK, которая теперь печатает строки из текстового поля в другом порядке, используя DYMO Connect SDK. Например, ниже в текстовом поле aspx Строка 1 Строка 2 Строка 3 Строка 4
печатается следующим образом: Строка 3 (пустая строка) Строка 1 Строка 2 и Строка 4 вместе
Ниже javascript что я использую для печати.
function prtLabel() {
var textTextArea = document.getElementById('txtLabelText');
try {
// open label
dymo.label.framework.init();
var labelXml = '<?xml version="1.0" encoding="utf-8"?>\
<DieCutLabel Version="8.0" Units="twips">\
<PaperOrientation>Landscape</PaperOrientation>\
<Id>Address</Id>\
<PaperName>30330 Return Address</PaperName>\
<DrawCommands>\
<RoundRectangle X="0" Y="0" Width="1581" Height="5040" Rx="270" Ry="270" />\
</DrawCommands>\
<ObjectInfo>\
<AddressObject>\
<Name>Address</Name>\
<ForeColor Alpha="255" Red="0" Green="0" Blue="0" />\
<BackColor Alpha="0" Red="255" Green="255" Blue="255" />\
<LinkedObjectName></LinkedObjectName>\
<Rotation>Rotation0</Rotation>\
<IsMirrored>False</IsMirrored>\
<IsVariable>True</IsVariable>\
<HorizontalAlignment>Left</HorizontalAlignment>\
<VerticalAlignment>Middle</VerticalAlignment>\
<TextFitMode>ShrinkToFit</TextFitMode>\
<UseFullFontHeight>True</UseFullFontHeight>\
<Verticalized>False</Verticalized>\
<StyledText>\
<Element>\
<String>DYMO\n3 Glenlake Parkway\nAtlanta, GA 30328</String>\
<Attributes>\
<Font Family="Arial" Size="10" Bold="False" Italic="False" Underline="False" Strikeout="False" />\
<ForeColor Alpha="255" Red="0" Green="0" Blue="0" />\
</Attributes>\
</Element>\
</StyledText>\
<ShowBarcodeFor9DigitZipOnly>False</ShowBarcodeFor9DigitZipOnly>\
<BarcodePosition>BelowAddress</BarcodePosition>\
<LineFonts>\
<Font Family="Arial" Size="10" Bold="False" Italic="False" Underline="False" Strikeout="False" />\
<Font Family="Arial" Size="10" Bold="False" Italic="False" Underline="False" Strikeout="False" />\
<Font Family="Arial" Size="10" Bold="False" Italic="False" Underline="False" Strikeout="False" />\
<Font Family="Arial" Size="10" Bold="False" Italic="False" Underline="False" Strikeout="False" />\
</LineFonts>\
</AddressObject>\
<Bounds X="332" Y="150" Width="5760" Height="1260" />\
</ObjectInfo>\
</DieCutLabel>';
var label = dymo.label.framework.openLabelXml(labelXml);
// set label text
label.setObjectText("Address", textTextArea.value);
// select printer to print on
// for simplicity sake just use the first LabelWriter printer
var printers = dymo.label.framework.getPrinters();
if (printers.length === 0) {
throw "No DYMO printers are installed. Install DYMO printers.";
}
var printerName = "";
for (var i = 0; i < printers.length; ++i) {
var printer = printers[i];
if (printer.printerType === "LabelWriterPrinter") {
printerName = printer.name;
break;
}
}
if (printerName == "")
throw "No LabelWriter printers found. Install LabelWriter printer";
// finally print the label
label.print(printerName);
//close the window
closeprtwin();
}
catch (e) {
alert(e.message || e);
closewin();
}
}
function closeprtwin() {
window.open('', '_self', '');
window.close();
}