DYMO标签JavaScript打印框架 [英] DYMO label JavaScript printing framework
问题描述
我的项目涉及在Dymo 400 Turbo上打印患者标签。我已经安装了最新的框架DYMO.Label.Framework.latest.js,我正在尝试使用我在网上找到的一种方法来打印标签。我的问题是XML是为地址标签设计的,而不是更长的患者标签。当我发送到打印机时,它会超过下一个标签,浪费一个。另外,我想在条形码中打印ID而不是地址或邮政编码。有什么想法吗?
这是我的XML:
' <?xml version =1.0encoding =utf-8?> \
< DieCutLabel Version =8.0Units =twips> \
< PaperOrientation>风景< / PaperOrientation> \
< Id>地址< / Id> \
< PaperName> 30252地址< / PaperName> \
< DrawCommands> \
< RoundRectangle X =0Y =0Width =1581Height =5040Rx =270Ry =270/> \
< / DrawCommands> \\ \\
< ObjectInfo> \
< AddressObject> \
<名称>地址< /名称> \
< ForeColor Alpha =255红色= 0绿色=0蓝色=0/> \
< BackColor Alpha =0Red =255Green =255Blue =255/> \
< LinkedObjectName>< / LinkedObjectName> \
< Rotation> ; Rotation0< / Rotation> \
< IsMirrored> False< / IsMirrored> \
< IsVariable> True< / IsVariable> \
< HorizontalAlignment> Left< / HorizontalAlignment> ; \
< VerticalAlignment>中< / VerticalAlignment> \
< TextFitMode> ShrinkToFit< / TextFitMode> \
< UseFullFontHeight> True< / UseFullFontHeight> \
< Verticalized> False< / Verticalized> \
< StyledText> \
< Element> \
< Attributes> \
< Font Family =ArialSize =8Bold =FalseItalic =FalseUnderline =FalseStrikeout = False/> \
< ForeColor Alpha =255Red =0Green =0Blue =0/> \
< / Attributes> \\ \\
< / Element> \
< / StyledText> \
< LineFonts> \
< Font Family =ArialSize =8 Bold =FalseItalic =FalseUnderline =FalseStrikeout =False/> \
< Font Family =ArialSize =8Bold =FalseItalic = FalseUnderline =FalseStrikeout =False/> \
< ; Font Family =ArialSize =8Bold =FalseItalic =FalseUnderline =FalseStrikeout =False/> \
< / LineFonts> \
< / AddressObject> \
< Bounds X =332Y =150Width =4455Height =1260/> \
< / ObjectInfo> \
< / DieCutLabel>'
我用这个加载标签:
var label = dymo.label.framework.openLabelXml(labelXml);
var labelToPrint = getLabelToPrint();
if(!label){
$(#lblError)。text(没有输入要打印的信息);
$(#MessageDialog)。dialog({title:No Information});
$(#MessageDialog)。dialog(open);
返回;
}
if(label.getAddressObjectCount()> 0){
var add = label.getAddressText(0);
label.setAddressText(0,labelToPrint);
}
//使用LabelSet和文本标记设置数据
var labelSet = new dymo.label.framework.LabelSetBuilder();
var textMarkup ='';
var fontSize = 18; //设置第一行的字体大小
if(labelToPrint ==''){
$(#lblError)。text(没有输入任何信息打印);
$(#MessageDialog)。dialog({title:No Information});
$(#MessageDialog)。dialog(open);
返回false;
}
else {
var lines = labelToPrint.split('\ n');
var boldLinesCount = lines.length< = 3? 1:2;
for(var x = 0; x< lines.length; x ++){
textMarkup + = lines [x] +'\ n';
}
// textMarkup + = lines [0] +'\ n';
// textMarkup + = lines [1] +'\ n';
// textMarkup + = lines [2];
label.setAddressText(0,textMarkup);
//label.setObjectText(\"Barcode,lines [0]);
label.setObjectText(Address,textMarkup);
var record = labelSet.addRecord();
record.setTextMarkup('Text',textMarkup); //设置标签文本
}
Dymo LabelWriter 450. 2016年,这台打印机和文档都在颠覆世界。这是一场地狱和噩梦。 DYMO?请记录好。
第1步:
A)获取最新版本的Javascript库并有驱动程序
B)旧版本搞砸了,浪费时间。
C)开始的更好的地方:
My project involves printing patient labels on a Dymo 400 Turbo. I have installed the latest framework, DYMO.Label.Framework.latest.js, and am trying to use one approach I have found on the web to print the label. My problem is that the XML was designed for an address label and not a longer patient label. When I send to the printer it advances past the next label, wasting one. Plus I want to print the ID not the address or zip code in the bar code. Anyone have any ideas?
This is my XML:
'<?xml version="1.0" encoding="utf-8"?>\
<DieCutLabel Version="8.0" Units="twips">\
<PaperOrientation>Landscape</PaperOrientation>\
<Id>Address</Id>\
<PaperName>30252 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>\
<Attributes>\
<Font Family="Arial" Size="8" Bold="False" Italic="False" Underline="False" Strikeout="False" />\
<ForeColor Alpha="255" Red="0" Green="0" Blue="0" />\
</Attributes>\
</Element>\
</StyledText>\
<LineFonts>\
<Font Family="Arial" Size="8" Bold="False" Italic="False" Underline="False" Strikeout="False" />\
<Font Family="Arial" Size="8" Bold="False" Italic="False" Underline="False" Strikeout="False" />\
<Font Family="Arial" Size="8" Bold="False" Italic="False" Underline="False" Strikeout="False" />\
</LineFonts>\
</AddressObject>\
<Bounds X="332" Y="150" Width="4455" Height="1260" />\
</ObjectInfo>\
</DieCutLabel>'
I load up the label with this:
var label = dymo.label.framework.openLabelXml(labelXml);
var labelToPrint = getLabelToPrint();
if (!label) {
$("#lblError").text("There is no information entered to print");
$("#MessageDialog").dialog({ title: "No Information" });
$("#MessageDialog").dialog("open");
return;
}
if (label.getAddressObjectCount() > 0) {
var add = label.getAddressText(0);
label.setAddressText(0, labelToPrint);
}
// set data using LabelSet and text markup
var labelSet = new dymo.label.framework.LabelSetBuilder();
var textMarkup = '';
var fontSize = 18; // sets font size of first line
if (labelToPrint == '') {
$("#lblError").text("There is no information entered to print");
$("#MessageDialog").dialog({ title: "No Information" });
$("#MessageDialog").dialog("open");
return false;
}
else {
var lines = labelToPrint.split('\n');
var boldLinesCount = lines.length <= 3 ? 1 : 2;
for (var x = 0; x < lines.length; x++) {
textMarkup += lines[x] + '\n';
}
//textMarkup += lines[0] + '\n';
//textMarkup += lines[1] + '\n';
//textMarkup += lines[2];
label.setAddressText(0, textMarkup);
//label.setObjectText("Barcode", lines[0]);
label.setObjectText("Address", textMarkup);
var record = labelSet.addRecord();
record.setTextMarkup('Text', textMarkup); // set label text
}
Dymo LabelWriter 450. In 2016 the world is upside down with this printer and with there documentation. Its a hell and nightmare. Dymo? please document it well.
Step 1:
A) Get latest versions of Javascript library and there driver
B) old versions are screwed, full waste of time. C) better place to get start with: http://developers.dymo.com/2016/01/05/dymo-label-software-version-8-5-3-for-patch-release-macwin/
Step 2: copy paste, and smile.
<html>
<head>
<script type="text/javascript" src="http://www.labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.2.0.2.js"></script>
<script type="text/javascript">
function startupCode() {
var printers = dymo.label.framework.getPrinters();
if (printers.length == 0)
throw "No DYMO printers are installed. Install DYMO printers.";
dymo.label.framework.getPrintersAsync().then(function(printers){
// Successful result, printers variable has a list of all supported by the DYMO Label Framework
console.log(printers);
}).thenCatch(function(error){
// Error
});
var labelXml = '<?xml version="1.0" encoding="utf-8"?>\
<DieCutLabel Version="8.0" Units="twips">\
<PaperOrientation>Landscape</PaperOrientation>\
<Id>Address</Id>\
<PaperName>30252 Address</PaperName>\
<DrawCommands>\
<RoundRectangle X="0" Y="0" Width="1581" Height="5040" Rx="270" Ry="270" />\
</DrawCommands>\
<ObjectInfo>\
<BarcodeObject>\
<Name>BARCODE</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>\
<Text></Text>\
<Type>Code39</Type>\
<Size>Medium</Size>\
<TextPosition>Bottom</TextPosition>\
<TextFont Family="Arial" Size="8" Bold="False" Italic="False" Underline="False" Strikeout="False" />\
<CheckSumFont Family="Arial" Size="8" Bold="False" Italic="False" Underline="False" Strikeout="False" />\
<TextEmbedding>None</TextEmbedding>\
<ECLevel>0</ECLevel>\
<HorizontalAlignment>Center</HorizontalAlignment>\
<QuietZonesPadding Left="0" Top="0" Right="0" Bottom="0" />\
</BarcodeObject>\
<Bounds X="331" Y="178" Width="4260" Height="420" />\
</ObjectInfo>\
</DieCutLabel>';
var label = dymo.label.framework.openLabelXml(labelXml);
label.setObjectText("BARCODE", '000220200');
label.print("DYMO LabelWriter 450"); // This is the NAME of the printer which i found
}
function frameworkInitShim() {
dymo.label.framework.trace = 1; //true
dymo.label.framework.init(startupCode);
}
window.onload = frameworkInitShim;
</script>
</head>
<body>
</body>
</html>
Step 3: Printed correctly and console output was correct for debugging.
这篇关于DYMO标签JavaScript打印框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!