使用ColdFusion和JavaScript DYMO SDK创建条形码标签
我正在尝试使用DYMO SDK将条形码打印到包装的标签上。我希望能够在不使用DYMO软件的情况下创建条形码对象。我正在用ColdFusion编写这段代码。现在,我有一些代码生成的HTML条码,并显示在网页上。但是,当我使用DYMO SDK中的JavaScript打印标签时,它会错误地打印条形码,条形码的值只是“未知”。无论如何,希望有人有一些使用这个库的经验。下面是我用来打印标签的JavaScript:使用ColdFusion和JavaScript DYMO SDK创建条形码标签,javascript,coldfusion,Javascript,Coldfusion,我正在尝试使用DYMO SDK将条形码打印到包装的标签上。我希望能够在不使用DYMO软件的情况下创建条形码对象。我正在用ColdFusion编写这段代码。现在,我有一些代码生成的HTML条码,并显示在网页上。但是,当我使用DYMO SDK中的JavaScript打印标签时,它会错误地打印条形码,条形码的值只是“未知”。无论如何,希望有人有一些使用这个库的经验。下面是我用来打印标签的JavaScript: // prints the label printButton.onclick = func
// 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);
//打印标签
printButton.onclick=函数(){
试一试{
//开放标签
var-labelXml=\
\
景观\
地址\
30252地址\
\
\
\
条形码\
\
\
条形码文本\
旋转0\
假的\
真的\
条形码\
代码39\
中等\
底部\
\
\
没有\
0\
居中\
\
\
\
\
';
var label=dymo.label.framework.openLabelXml(labelXml);
//设置标签文本
label.setObjectText(“条形码”,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>
#属性。textbooth#
这是我用来显示它的测试HTML:
<div id="textTextArea">
<CF_barcode39 InputValue="ABCDEFGHIJ" BarWidth="2" BarHeight="50" TextTop="BarWidth=2 BarHeight=50" TextBottom="ABCDEFGHIJ">
</div>
我的服务器生成用于生成入场券的条形码。我强烈建议您按照install.txt文件中的说明操作,但基本上,您可以将一些文件复制到ColdFusion目录下的lib文件夹中。以下是我用于生成条形码的代码示例
<cfset bbq = createObject("component", "CFBarbecue").init() />
<cfset barcode = bbq.createImage( type="#var.barcodetype#", data="#session.cart.checkOut[i].BARCODE#", checkDigit=false, barWidth="1", barHeight="30", drawLabel="FALSE") />
我安装它已经有一段时间了,但我认为您不需要进行任何映射。上次我打印条形码时,只是选择正确的条形码字体的问题。感谢您的回复,没有关于DYMO SDK的详细文档,这使我很难理解我使用的XML字符串用于创建不同的标签对象。我现在可以使用条形码在浏览器中呈现标签预览视图,并且我非常确定我不需要使用coldfusion生成条形码。如果我正确创建xml字符串,dymo sdk会帮我完成这项工作。不幸的是,我现在在打印时遇到问题,因此我无法确定.