我正在尝试使用 DYMO SDK 将条形码打印到包裹标签上。我希望能够在不使用 DYMO 软件的情况下创建条形码对象。我正在 ColdFusion 中编写此代码。现在我有一些代码可以将条形码生成为 HTML 并将其显示在网页上。但是,当我使用 DYMO SDK 中的 JavaScript 打印标签时,它会错误地打印条形码,条形码的值只是“未知”。无论如何,希望有人有使用这个库的经验。这是我用来打印标签的 JavaScript:
// prints the label
printButton.onclick = function () {
try {
// open label
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/>\
<ObjectInfo>\
<BarcodeObject>\
<Name>Barcode</Name>\
<ForeColor Alpha="255" Red="0" Green="0" Blue="0" />\
<BackColor Alpha="0" Red="255" Green="255" Blue="255" />\
<LinkedObjectName>BarcodeText</LinkedObjectName>\
<Rotation>Rotation0</Rotation>\
<IsMirrored>False</IsMirrored>\
<IsVariable>True</IsVariable>\
<Text>BARCODE</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="332" Y="150" Width="4455" Height="1260" />\
</ObjectInfo>\
</DieCutLabel>';
var label = dymo.label.framework.openLabelXml(labelXml);
// set label text
label.setObjectText("Barcode", textTextArea.value);
这是我用来生成条形码的代码:
<cfoutput>
<!---span style="#Attributes.TextFontTop#">#Attributes.TextTop#</span--->
<div>
<cfloop index="i" from="1" to="#len(Attributes.InputValue)#">
<span style="border-right:#val(mid(code39[asc(mid(Attributes.InputValue,i,1))],1,1)*(Attributes.BarWidth)+(Attributes.BarWidth/2))#px solid; border-color: black; height: #Attributes.BarHeight#px;margin-bottom:#Attributes.MarginBottom#px;margin-top:#Attributes.MarginTop#px;"></span>
<span style="border-right:#val(mid(code39[asc(mid(Attributes.InputValue,i,1))],6,1)*(Attributes.BarWidth)+(Attributes.BarWidth/2))#px solid; border-color: white; height: #Attributes.BarHeight#px;margin-bottom:#Attributes.MarginBottom#px;margin-top:#Attributes.MarginTop#px;"></span>
<span style="border-right:#val(mid(code39[asc(mid(Attributes.InputValue,i,1))],2,1)*(Attributes.BarWidth)+(Attributes.BarWidth/2))#px solid; border-color: black; height: #Attributes.BarHeight#px;margin-bottom:#Attributes.MarginBottom#px;margin-top:#Attributes.MarginTop#px;"></span>
<span style="border-right:#val(mid(code39[asc(mid(Attributes.InputValue,i,1))],7,1)*(Attributes.BarWidth)+(Attributes.BarWidth/2))#px solid; border-color: white; height: #Attributes.BarHeight#px;margin-bottom:#Attributes.MarginBottom#px;margin-top:#Attributes.MarginTop#px;"></span>
<span style="border-right:#val(mid(code39[asc(mid(Attributes.InputValue,i,1))],3,1)*(Attributes.BarWidth)+(Attributes.BarWidth/2))#px solid; border-color: black; height: #Attributes.BarHeight#px;margin-bottom:#Attributes.MarginBottom#px;margin-top:#Attributes.MarginTop#px;"></span>
<span style="border-right:#val(mid(code39[asc(mid(Attributes.InputValue,i,1))],8,1)*(Attributes.BarWidth)+(Attributes.BarWidth/2))#px solid; border-color: white; height: #Attributes.BarHeight#px;margin-bottom:#Attributes.MarginBottom#px;margin-top:#Attributes.MarginTop#px;"></span>
<span style="border-right:#val(mid(code39[asc(mid(Attributes.InputValue,i,1))],4,1)*(Attributes.BarWidth)+(Attributes.BarWidth/2))#px solid; border-color: black; height: #Attributes.BarHeight#px;margin-bottom:#Attributes.MarginBottom#px;margin-top:#Attributes.MarginTop#px;"></span>
<span style="border-right:#val(mid(code39[asc(mid(Attributes.InputValue,i,1))],9,1)*(Attributes.BarWidth)+(Attributes.BarWidth/2))#px solid; border-color: white; height: #Attributes.BarHeight#px;margin-bottom:#Attributes.MarginBottom#px;margin-top:#Attributes.MarginTop#px;"></span>
<span style="border-right:#val(mid(code39[asc(mid(Attributes.InputValue,i,1))],5,1)*(Attributes.BarWidth)+(Attributes.BarWidth/2))#px solid; border-color: black; height: #Attributes.BarHeight#px;margin-bottom:#Attributes.MarginBottom#px;margin-top:#Attributes.MarginTop#px;"></span>
<span style="border-right:2px solid; border-color: white; height: 50px;margin-bottom:2px;margin-top:2px;"></span> <!--- space between individual codes --->
</cfloop>
</div>
<span style="#Attributes.TextFontBottom#">#Attributes.TextBottom#</span>
这是我用来显示它的测试 HTML:
<div id="textTextArea">
<CF_barcode39 InputValue="ABCDEFGHIJ" BarWidth="2" BarHeight="50" TextTop="BarWidth=2 BarHeight=50" TextBottom="ABCDEFGHIJ">
</div>