问题描述
我希望添加使用Dymo LabelWriter 450 Turbo打印多个标签的功能.我已经从Dymo网站下载了DYMO-Label-v.8-SDK.dmg,但是看不到任何与Javascript/Web相关的SDK文件或文档-我所看到的只是AppleScript示例,在这里无济于事./p>
有人知道这是否可行(标签数据将来自连接到PHP Web应用程序的后端数据库).我在Dymo Developer网站上找不到Javascript SDK的任何文档-仅是几年前的一些示例,因此甚至不确定当前的状态,最新的版本等以及是否可以打印多个标签?
我实际上是使用完全相同的打印机在自己的Web应用程序中构建了此功能,今天我感到很友好.这是我在生产级应用程序中为我工作的内容.祝你好运!
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>DYMO: QR-code</title>
<!-- JQuery -->
<script src = "http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript" charset="UTF-8"> </script>
<!-- Dymo Script -->
<script src="DYMO.Label.Framework.2.0.2.js" type="text/javascript" charset="UTF-8"></script>
<!-- QR Code -->
<script src="QRCode.js" type="text/javascript" charset="UTF-8"> </script>
<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="jumbotron">
<h3>DYMO Label Framework JavaScript Library Samples: QR code</h3>
<div class="header">
<div id="sampleDesctiption">
<span>
This sample shows different ways to print a label with a QR-code barcode.
</span>
</div>
</div>
</div>
<div class="container">
<div class="printControls">
<div class="row">
<div class="col-md-6">
<div id="printersDiv">
<label for="printersSelect">Printer:</label><br/>
<select class="form-control" id="printersSelect"></select>
</div>
</div>
</div>
<div id="printDiv" style="padding-top:20px">
<button class="btn btn-primary btn-lg" id="printButton">Print QR Code</button>
</div>
</div>
</div>
</div>
</body>
</html>
QRCode.js
// stores loaded label info
var barcodeLabel;
// called when the document loaded
function onload() {
var printersSelect = document.getElementById('printersSelect');
var printButton = document.getElementById('printButton');
// loads all supported printers into a combo box
function loadPrinters() {
var printers = dymo.label.framework.getLabelWriterPrinters();
if (printers.length == 0) {
alert("No DYMO printers are installed. Install DYMO printers.");
return;
}
console.log("got here: ", printers );
for (var i = 0; i < printers.length; i++) {
var printer = printers[i];
var printerName = printer.name;
var option = document.createElement('option');
option.value = printerName;
option.appendChild(document.createTextNode(printerName));
printersSelect.appendChild(option);
}
}
printButton.onclick = function () {
var label_text = 'QRCode Text Here..';
barcodeLabel.setObjectText('Barcode', label_text);
// Should Be Printer Name, Dymo 450 Turbo..
console.log("print: ", printersSelect.value );
barcodeLabel.print( printersSelect.value );
}
function getBarcodeLabelXml() {
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>False</IsVariable>\
<Text></Text>\
<Type>QRCode</Type>\
<Size>Small</Size>\
<TextPosition>None</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="300" Right="600" Bottom="0" />\
</BarcodeObject>\
<Bounds X="331" Y="57.9999999999999" Width="2880" Height="1435" />\
</ObjectInfo>\
</DieCutLabel>';
return labelXml;
}
function loadLabelFromWeb() {
barcodeLabel = dymo.label.framework.openLabelXml( getBarcodeLabelXml() );
}
// Load Labels
loadLabelFromWeb();
// load printers list on startup
loadPrinters();
};
// Run's Dymo Javascript..
dymo.label.framework.init(onload);
I'm looking to add the functionality to print multiple labels using a Dymo LabelWriter 450 Turbo. I've downloaded the DYMO-Label-v.8-SDK.dmg from the Dymo site but can't see any Javascript/web related SDK files or documentation - all I can see are AppleScript examples which won't help here.
Does anyone know if this is possible (data for labels will come from backend database connected to PHP web app). I can't find any documentation for a Javascript SDK on the Dymo Developer website - only some examples from a few years ago so not even sure what is the current state and which is the latest version etc and whether there is a way to print multiple labels?
I actually just built this functionality in my own web app using the exact same printer and I'm feeling friendly today. Here is what I have working for me in a production level application. Good luck!
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>DYMO: QR-code</title>
<!-- JQuery -->
<script src = "http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript" charset="UTF-8"> </script>
<!-- Dymo Script -->
<script src="DYMO.Label.Framework.2.0.2.js" type="text/javascript" charset="UTF-8"></script>
<!-- QR Code -->
<script src="QRCode.js" type="text/javascript" charset="UTF-8"> </script>
<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="jumbotron">
<h3>DYMO Label Framework JavaScript Library Samples: QR code</h3>
<div class="header">
<div id="sampleDesctiption">
<span>
This sample shows different ways to print a label with a QR-code barcode.
</span>
</div>
</div>
</div>
<div class="container">
<div class="printControls">
<div class="row">
<div class="col-md-6">
<div id="printersDiv">
<label for="printersSelect">Printer:</label><br/>
<select class="form-control" id="printersSelect"></select>
</div>
</div>
</div>
<div id="printDiv" style="padding-top:20px">
<button class="btn btn-primary btn-lg" id="printButton">Print QR Code</button>
</div>
</div>
</div>
</div>
</body>
</html>
QRCode.js
// stores loaded label info
var barcodeLabel;
// called when the document loaded
function onload() {
var printersSelect = document.getElementById('printersSelect');
var printButton = document.getElementById('printButton');
// loads all supported printers into a combo box
function loadPrinters() {
var printers = dymo.label.framework.getLabelWriterPrinters();
if (printers.length == 0) {
alert("No DYMO printers are installed. Install DYMO printers.");
return;
}
console.log("got here: ", printers );
for (var i = 0; i < printers.length; i++) {
var printer = printers[i];
var printerName = printer.name;
var option = document.createElement('option');
option.value = printerName;
option.appendChild(document.createTextNode(printerName));
printersSelect.appendChild(option);
}
}
printButton.onclick = function () {
var label_text = 'QRCode Text Here..';
barcodeLabel.setObjectText('Barcode', label_text);
// Should Be Printer Name, Dymo 450 Turbo..
console.log("print: ", printersSelect.value );
barcodeLabel.print( printersSelect.value );
}
function getBarcodeLabelXml() {
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>False</IsVariable>\
<Text></Text>\
<Type>QRCode</Type>\
<Size>Small</Size>\
<TextPosition>None</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="300" Right="600" Bottom="0" />\
</BarcodeObject>\
<Bounds X="331" Y="57.9999999999999" Width="2880" Height="1435" />\
</ObjectInfo>\
</DieCutLabel>';
return labelXml;
}
function loadLabelFromWeb() {
barcodeLabel = dymo.label.framework.openLabelXml( getBarcodeLabelXml() );
}
// Load Labels
loadLabelFromWeb();
// load printers list on startup
loadPrinters();
};
// Run's Dymo Javascript..
dymo.label.framework.init(onload);
这篇关于从PHP/Web应用程序向Dymo LabelWriter 450 Turbo打印多个标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!