打印从PHP/Web应用程序到Dymo LabelWriter 450 Turbo的多个标签



我希望使用Dymo LabelWriter 450 Turbo添加功能以打印多个标签。我已经从DYMO站点下载了Dymo-Label-V.8-sdk.dmg,但看不到任何JavaScript/Web相关的SDK文件或文档 - 我只能看到Applescript示例在这里无济于事。/p>

是否有人知道这是否可能(标签的数据将来自连接到PHP Web应用程序的后端数据库)。我在Dymo开发人员网站上找不到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);

相关内容

  • 没有找到相关文章

最新更新