Print on DYMO label printer from website
Asked Answered
C

2

6

How to print on DYMO label printer throuhg website? I have build the following file as described here but not succeeded need more help to print remotely.

    <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Print a Label</title> 
<script src = "http://labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.latest.js" type="text/javascript" charset="UTF-8"> </script>
<script src = "PrintLabel.js" type="text/javascript" charset="UTF-8"> </script>
</head>

<body>
<h1>DYMO Label Framework JavaScript Library Samples: Print Label</h1> 

    <div id="textDiv">
        <label for="textTextArea">Label text:</label><br/>
        <textarea name="textTextArea" id="textTextArea"  rows='5' cols='40'></textarea>
    </div>

        <div id="printDiv">
            <button id="printButton">Print</button>
        </div>

</body> 

</html> 
Cleora answered 19/12, 2015 at 10:14 Comment(0)
W
1

You cannot print remotely but the following code is fine to work locally using DYMO Javascript framework.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
    <head>
        <title>Sample DYMO Label Plug-In</title>


            <script src="http://labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.latest.js"
            type="text/javascript" charset="UTF-8">   



            function GetDYMOPrinters()
            {   

                var printers = dymo.label.framework.getPrinters();
                if (printers.length == 0)
                throw "No DYMO printers are installed. Install DYMO printers.";
                var printerName = "";
                for (var i = 0; i < printers.length; ++i)
                {
                    var printer = printers[i];
                    if (printer.printerType == "LabelWriterPrinter")
                    {
                        printerName = printer.name;
                        break;
                    }
                }

            var label = DYMO.Label.Framework.Label.Open("MyText.label");
            label.SetObjectText("NameTxt", "John Smith");

            label.print("DYMO LabelWriter");
            }
     </script>

    </head>
    <body onload="  GetDYMOPrinters()">
         <form action="" method="post" id="DYMOLabel">
        <center>
        <h2>DYMO Label  Example</h2>
         <input type=button value="Get DYMO Printers" onClick="GetDYMOPrinters()">
     </center>
    </form>




    </body>
</html>
Weatherley answered 20/12, 2015 at 13:19 Comment(2)
It shows nothing but seems to be fine. Let me see problem locally.Cleora
I think in order for this to work you would have to replace "mytext.label" with a whole bunch of XML, the label definition. This is basically the example code from the Dymo site...Gignac
T
7

To print a label directly from browser with DYMO without printer dialog you need

  1. DYMO Label Framework JS SDK
  2. DYMO Label Software (DLS).

You may download them here.

DLS needs to be installed on the computer where you have connected the DYMO device to. DLS comes with a DYMO Web Service that makes access possible through the browser.

Then, you can create a label XML file with DLS consisting of textareas and images.

Finally you can open the label XML file in JS with the Framework, and replace the textareas with text and the images with other images and then print it.

Here an example how to replace image from your labelXML with an PNG provided by an url:

// connect to printer
var printer = dymo.label.framework.getLabelWriterPrinters()[0].modelName;

// create label from XML file
var label = dymo.label.framework.openLabelXml(getLabelXml());

// load image from url and store as Base64
var image = dymo.label.framework.loadImageAsPngBase64("www.example.de/image.png");

// overwrite image "Image" from XML label with loaded image
label.setObjectText('Image', image);

// print it
label.print(printer);

You may find more help in my blog post.

Troop answered 27/7, 2019 at 10:5 Comment(2)
I'm trying to use your example but can't get an image printed (no js errors) #58996267Reel
@adam the above solution will work on the chrome browser also?Quadruplicate
W
1

You cannot print remotely but the following code is fine to work locally using DYMO Javascript framework.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
    <head>
        <title>Sample DYMO Label Plug-In</title>


            <script src="http://labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.latest.js"
            type="text/javascript" charset="UTF-8">   



            function GetDYMOPrinters()
            {   

                var printers = dymo.label.framework.getPrinters();
                if (printers.length == 0)
                throw "No DYMO printers are installed. Install DYMO printers.";
                var printerName = "";
                for (var i = 0; i < printers.length; ++i)
                {
                    var printer = printers[i];
                    if (printer.printerType == "LabelWriterPrinter")
                    {
                        printerName = printer.name;
                        break;
                    }
                }

            var label = DYMO.Label.Framework.Label.Open("MyText.label");
            label.SetObjectText("NameTxt", "John Smith");

            label.print("DYMO LabelWriter");
            }
     </script>

    </head>
    <body onload="  GetDYMOPrinters()">
         <form action="" method="post" id="DYMOLabel">
        <center>
        <h2>DYMO Label  Example</h2>
         <input type=button value="Get DYMO Printers" onClick="GetDYMOPrinters()">
     </center>
    </form>




    </body>
</html>
Weatherley answered 20/12, 2015 at 13:19 Comment(2)
It shows nothing but seems to be fine. Let me see problem locally.Cleora
I think in order for this to work you would have to replace "mytext.label" with a whole bunch of XML, the label definition. This is basically the example code from the Dymo site...Gignac

© 2022 - 2024 — McMap. All rights reserved.