DYMO Label Inside Out

February 21, 2012

Announcing DYMO LabelWriter/LabelManager SDK 1.4.0 for Linux

Filed under: News,SDK News — pi @ 8:53 pm
Tags: ,

We are proud to announce the release of the DYMO LabelWriter/LabelManager SDK 1.4.0 for Linux.

This release adds support for the LabelWriter 3xx series printers. Please check the DYMO SDK for Linux document for a complete list of supported DYMO LabelWriter/LabelManager printers.

The SDK is available from here. The DYMO LabelWriter/LabelManager SDK for Linux page is here

February 1, 2012

DYMO SDK Extension Update for Firefox 10.0

Filed under: News,SDK News — pi @ 10:44 pm
Tags:

The Firefox extension for DYMO SDK has been updated to support Firefox 10. The extension is available here. The FAQ article is here.

Please note that the Firefox extension is deprecated. No new development will be done for the extension. For new projects please use the Javascript library from the DYMO Label Framework. We encourage developers to switch to the new API even for current projects. Here are some benefits the new DYMO Label Framework API provides in comparison to the extension:

  • DYMO Label Framework API provides a cross-browser and cross-platform pure Javascript API. The same API supports all major browsers on Windows and Mac. The Firefox extension API can be used only in Firefox on Windows.
  • All necessary Framework installation is done by the DYMO Label software installer. By contrast the Firefox extension must be downloaded by customers separately and installed manually.
  • DYMO Label Framework supports and will support all the DYMO printers. New printers will not be supported by the extension.

The auto-update functionality isn’t included in this version. We will add it later.

January 9, 2012

DYMO SDK Extension Update for Firefox 9.0

Filed under: News,SDK News — pi @ 11:36 pm
Tags:

The Firefox extension for DYMO SDK has been updated to support Firefox 9. The extension is available here. The FAQ article is here.

Please note that the Firefox extension is deprecated. No new development will be done for the extension. For new projects please use the Javascript library from the DYMO Label Framework. We encourage developers to switch to the new API even for current projects. Here are some benefits the new DYMO Label Framework API provides in comparison to the extension:

  • DYMO Label Framework API provides a cross-browser and cross-platform pure Javascript API. The same API supports all major browsers on Windows and Mac. The Firefox extension API can be used only in Firefox on Windows.
  • All necessary Framework installation is done by the DYMO Label software installer. By contrast the Firefox extension must be downloaded by customers separately and installed manually.
  • DYMO Label Framework supports and will support all the DYMO printers. New printers will not be supported by the extension.

The auto-update functionality isn’t included in this version. We will add it later.

December 23, 2011

Happy Holidays and Farewell

Filed under: Uncategorized — Vladimir @ 6:37 am

Happy holidays to all DYMO users and developers! Thank you for being with DYMO, for all the questions, comments, and feedback. It’s invaluable!

2011 was quite a year, with a lot of new releases and new features.

It started with releasing of DYMO Label software 8.3 that added full support for new DYMO Label Framework API and JavaScript Library.

Next, we expanded the presence in the web and mobile dimensions by releasing DYMO Label Web SDK, DYMO Label Mobile SDK for iOS, and DYMO Label Mobile SDK for Android. Although SDKs are still officially in the beta stage, we know they were successfully used, e.g. MailChimp used it on iPad for visitor management, and Google itself used it on Android during developers conferences.

Because of Firefox’s new release schedule and changes into internal architecture we did one, two, three, four, five updates to the Firefox extension, and another one is coming soon. Again, a note of caution: the extension is obsolete, for new projects use DYMO Label JavaScript library.

To support Mac OS X 10.7 Lion, we released DYMO Label software 8.3.1 and did some internal fixes to JavaScript library.

Finally, DYMO Label SDK for Windows was released with updated samples and documentation.

On the sad note, after dozen years with DYMO, I am leaving the company and this is my last post.

Anyway, Happy Holidays! Happy New Year! Let new year be better, brighter, more peaceful than 2011. May the Force be with you. Live long and prosper. Bye.

December 16, 2011

Printing QR-code: Part 2

Filed under: DYMO Label Framework,SDK Samples — Vladimir @ 7:50 am
Tags: , ,

The previous post demonstrated different ways of printing QR-code from a .NET application. This blog post will demonstrate how to achieve the same goal from a web application. The complete sample is available here. The corresponding JavaScript is here.

Prerequisites

First, make sure the latest DYMO Label software is installed. It is always available on DYMO web-site, at the time of writing it is version 8.3.1.

Use Barcode Object

The easiest way to print QR-code is to use built-in support for QR-code in DYMO Label Framework. First, design your label using DYMO Label software. Unfortunately, DYMO Label itself does not have ability to specify QR-code barcode type in the UI yet. So, add the Barcode object to the label and put it into desired position. Don’t specify the barcode symbology, use the default Code39. Save the label in to a file, open the file in any XML editor and change thetag to “QRCode”.

<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>Large</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>Left</HorizontalAlignment>
    <QuietZonesPadding Left="0" Top="0" Right="0" Bottom="0" />
</BarcodeObject>

See Barcode.label from the sample. After the label is ready, the actual steps to print it is quite easy: open the label, set desired data, print. Here is a snippet from the sample:

printButton.onclick = function()
{
    try
    {
        if (!barcodeLabel)
            throw "Load label before printing";

        if (!printersSelect.value)
            throw "Select printer.";

        barcodeLabel.setObjectText('Barcode', 'http://developers.dymo.com');
        barcodeLabel.print(printersSelect.value);
    }
    catch(e)
    {
        alert(e.message || e);
    }
}

First, we check that the label is loaded and the printer is selected. Next, the barcode data is set to be the blog’s URL. And finally, the label is printed.

Use Image Object

Printing QR-code by using Barcode object is easy. The only drawback, it is hard to control the actual barcode size. tag can be used for that but it support only three predefined sizes Small/Medium/Large, but still the overall size will depend on the actual barcode data. The longer the data string, the larger is the barcode. So, the idea is to use some library to generate QR-code image of desired size, and then print it using the Image object. As before, design a label using DYMO Label software. Put an Image object on the label where the barcode should be printed. Set the Image objet size to the desired barcode size. When specifying the barcode image size in pixels calculate it based on the printer resolution, that is 300 dpi for LabelWriter printers and 180 dpi for Tape printers. For example, if you want the barcode to be 1” in size, specify the barcode image size as 300×300 pixels. See BarcodeAsImage.label from the sample project.

Image object accepts image data as a string that contains base64-encoded png stream. The question is, how to get/generate this string. Again, there are several ways of doing that.

Generate and base64-encode QR-code image on the server-side

One way is to generate QR-code image on the server using some library. Then encode the image using base64 and return it to the client as a string. Finally, on the client side, call setObjectText on the Image object and print.

printAsImageButton.onclick = function()
{
    try
    {
        if (!barcodeAsImageLabel)
            throw "Load label before printing";

        if (!printersSelect.value)
            throw "Select printer";

        $.get("qr.base64", function(qr)
        {
            try
            {
                barcodeAsImageLabel.setObjectText('Image', qr);

                barcodeAsImageLabel.print(printersSelect.value);
            }
            catch(e)
            {
                alert(e.message || e);
            }
        }, "text");

    }
    catch(e)
    {
        alert(e.message || e);
    }
}

In the sample, we just request “qr.base64” resource that contains precalculated QR-code image for “http://developers.dymo.com”. In real application, you will probably pass the data to be encoded as a resource parameter.

Generate QR-code image on the server-side and base64-encode it on the client-side.

Base64-encoded strings are larger then binary png data. So, to reduce network traffic, we can return original png data from the server and base64-encode it on the client. To encode the data we will create , render our image on it, and then get encoded data using canvas.toDataURL() method.

printAsImageCanvasButton.onclick = function()
{
    try
    {
        if (!barcodeAsImageLabel)
            throw "Load label before printing";

        if (!printersSelect.value)
            throw "Select printer.";

        var img = new Image();
        img.onload = function()
        {
            try
            {
                var canvas = document.createElement('canvas');
                canvas.width = img.width;
                canvas.height = img.height;

                var context = canvas.getContext('2d');
                context.drawImage(img, 0, 0);

                var dataUrl = canvas.toDataURL('image/png');
                var pngBase64 = dataUrl.substr('data:image/png;base64,'.length);

                barcodeAsImageLabel.setObjectText('Image', pngBase64);
                barcodeAsImageLabel.print(printersSelect.value);
            }
            catch(e)
            {
                alert(e.message || e);
            }
        };
        img.onerror = function()
        {
            alert('Unable to load "qr.png"');
        };
        img.src = 'qr.png';
    }
    catch(e)
    {
        alert(e.message || e);
    }
}

Note: image loading is asynchronous process. So, we can’t just assign img.src property and immediately draw it on a canvas; we have to wait until the image is loaded completely from the server. To handle that, we do main work in onload handler. also, toDataURL returns data url, to get the data itself, we have to remove the url prefix.

Again, as in the previous case, qr.png resource contains recalculated QR-code image for “http://developers.dymo.com”. In real application, you will probably pass the data to be encoded as a resource parameter.

A drawback of this method is that it requires support in the browser. All major browsers already support it, but be aware that in Internet Explorer it is supported starting from version 9 only.

Use third-party service

Instead of generating QR-code image on your own server, is it possible to use one of the many free online QR-code generator/service? The answer is yes, but it is even more trickier than the previous way. The problem, as usual in web development, is the security. But default is it not possible to grab canvas pixels if an image from a different domain has been drawn on the canvas. It is possible to overcome it, but it requires three parties to participate properly. First, your JavaScript has to set img.crossOrigin property to ‘anonymous’. This will tell the browser that you are trying to access a cross-domain resource, so the browser can send appropriate request headers, e.g. the browser will not send cookies. Next, the server itself should allow its resources to be accessible from other domains. Only few of many QR-code online generators do allow it. And the last, the browser itself should support CORS for . It is very recent addition to the standards, so at the time of writing only Chrome does support it. In any other browsers you will still get “security exception” error. Here are some links regarding and cross-domain limitations:

http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#security-with-canvas-elements

http://blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html

http://code.google.com/p/chromium/issues/detail?id=82042

Update (2011-12-20): works in Firefox 9 as well.

printAsImageCanvas2Button.onclick = function()
{
    try
    {
        if (!barcodeAsImageLabel)
            throw "Load label before printing";

        if (!printersSelect.value)
            throw "Select printer.";

        var img = new Image();
        img.crossOrigin = 'anonymous';
        img.onload = function()
        {
            try
            {
                var canvas = document.createElement('canvas');
                canvas.width = img.width;
                canvas.height = img.height;

                var context = canvas.getContext('2d');
                context.drawImage(img, 0, 0);

                var dataUrl = canvas.toDataURL('image/png');
                var pngBase64 = dataUrl.substr('data:image/png;base64,'.length);

                barcodeAsImageLabel.setObjectText('Image', pngBase64);
                barcodeAsImageLabel.print(printersSelect.value);
            }
            catch(e)
            {
                alert(e.message || e);
            }
        };
        img.onerror = function()
        {
            alert('Unable to load qr-code image');
        };
        img.src = 'https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=http%3A//developers.dymo.com&choe=UTF-8';
    }
    catch(e)
    {
        alert(e.message || e);
    }
}

The code is very similar to the previous example. The only difference is that we set img.crossOrigin property and we use Google’s Infographics API to generate the qr-code image. Notice that in this example the image is generated dynamically, and barcode data is passed as the part of the url.

Pure client-side JavaScript

At the time of writing, it seems there is no self-contained pure JavaScript solutions to create QR-code images using <canvas> completely on the client-side. In the future it might be one more way of doing QR-code printing.

Conclusion

It is quite simple to print QR-code barcode even if built-in support is somewhat limited.

December 2, 2011

Announcing DYMO Label SDK 8.3.1

Filed under: News,SDK News — Vladimir @ 12:20 pm
Tags: , , , ,

We are proud to announce the release of DYMO Label SDK 8.3.1. This release contains updated documentation and samples, especially for the new DYMO Label Framework API. The SDK installer is available from here.

Note: do not forget to install DYMO Label software, it is required to run any application that uses the SDK. For more information see this blog post.

Online documentation:

DYMO Label Framework .NET Reference documentation

DYMO Label JavaScript Library documentation

November 29, 2011

Printing QR-code: Part 1

Filed under: DYMO Label Framework,SDK Samples — Vladimir @ 8:14 am
Tags: , , ,

This blog post will demonstrate how it is easy to print a label with a QR-code barcode from any .NET application. Even more, it will show how to do that in two different ways. The sample VS 2008 project is available here.

Prerequisites

First, make sure the latest DYMO Label software is installed. It is always available on DYMO web-site, at the time of writing it is version 8.3.1. Next, in Visual Studio create a new .NET project and add a reference to DYMO.Label.Framework assembly. This will make possible to use DYMO Label Framework API in the project.

Use Barcode Object

The easiest way to print QR-code is to use built-in support for QR-code in DYMO Label Framework. First, design your label using DYMO Label software. Unfortunately, DYMO Label itself does not have ability to specify QR-code barcode type in the UI yet. So, add the Barcode object to the label and put it into desired position. Don’t specify the barcode symbology, use the default Code39. Save the label in to a file, open the file in any XML editor and change the <Type> tag to “QRCode”.

<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>Large</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>Left</HorizontalAlignment>
    <QuietZonesPadding Left="0" Top="0" Right="0" Bottom="0" />
</BarcodeObject>

See Barcode.label file in the sample project. After the label is ready, the actual steps to print it is quite easy: open the label, set desired data, print. Here is a snippet from the sample:

private void PrintBarcodeButton_Click(object sender, RoutedEventArgs e)
{
    // load label template
    var label = DYMO.Label.Framework.Label.Open(
        Application.GetResourceStream(
            new Uri("Barcode.label", UriKind.Relative)).Stream);

    // set barcode data
    label.SetObjectText("Barcode", "http://developers.dymo.com");

    // print
    label.Print(PrintersComboBox.Text);
}

First, label is loaded from a file, stored as a resource in the application assembly. Next, the barcode data is set to be the blog’s URL. And finally, the label is printed on the printer selected in the UI.

Use Image Object

Printing QR-code by using Barcode object is easy. The only drawback, it is hard to control the actual barcode size. <Size> tag can be used for that but it support only three predefined sizes Small/Medium/Large, but still the overall size will depend on the actual barcode data. The longer the data string, the larger is the barcode. So, the idea is to use some library to generate QR-code image of desired size, and then print it using the Image object. As before, design a label using DYMO Label software. Put an Image object on the label where the barcode should be printed. Set the Image’s Scale Mode to None to avoid image scaling and possible problems with the scanning/reading of the printed barcode. See BarcodeAsImage.label from the sample project. Then use selected library to generate the QR-code image. When specifying the barcode image size in pixels calculate it based on the printer resolution, that is 300 dpi for LabelWriter printers and 180 dpi for Tape printers. For example, if you want the barcode to be 1” in size, specify the barcode image size as 300×300 pixels. Actuals API calls are very similar to the first case.

private void PrintBarcodeAsImageButton_Click(object sender, RoutedEventArgs e)
{
    // load label template
    var label = DYMO.Label.Framework.Label.Open(
        Application.GetResourceStream(
            new Uri("BarcodeAsImage.label", UriKind.Relative)).Stream);

    // set data as a barcode image
    var imageStream = Application.GetResourceStream(
            new Uri("qr.png", UriKind.Relative)).Stream;

    label.SetImagePngData("Image", imageStream);

    // print
    label.Print(PrintersComboBox.Text);
}

First, label is loaded from a file, stored as a resource in the application assembly. Next, the barcode image is “generated”; for the simplicity, already created png file is used instead of library calls. Next, the image data is assigned to the Image object. And finally, the label is printed on the printer selected in the UI.

Conclusion

It is quite simple to print QR-code barcode even if built-in support is somewhat limited. The next post will show how to do the same thing by using DYMO Label JavaScript library.

November 17, 2011

JavaScript Library Samples: Printers and Multiple Labels Printing

Filed under: DYMO Label Framework,SDK Samples — Vladimir @ 5:29 am
Tags: ,

Here is one more sample demonstrates capabilities of DYMO Label JavaScript library. The correspondent JavaScript file is here.

Getting Printers

First, the sample shows how to retrieve a list of available DYMO printers. For each printer it shows all the available properties. To get the printer list use dymo.label.framework.getPrinters function. The function returns an array contains information regarding each printer. The sample calls getPrinters and then put all the information onto a table, see createPrintersTable() for details.

Note: There are helpful function to filter the result list to contain only LabelWriter or Tape printers; use dymo.label.framework.getLabelWriterPrinters or dymo.label.framework.getTapePrinters accordingly. This might be useful if your application is designed to print on die-cut labels or D1 tapes only.

Print Multiple Labels

Next, the sample shows how to print multiple labels at once, in one print job. The sample leverages the library’s LabelSet functionality do archive that. For each printer the sample creates one label set record represent data to be printed on one label. also the sample demonstrates how to apply different text styles to the print data. It uses a feature called text markup, the ability to apply formatting attributes/tags very similar to HTML ones. 

// create label set to print printers' data
var labelSetBuilder = new dymo.label.framework.LabelSetBuilder();
for (var i = 0; i < printers.length; i++)
{
    var printer = printers[i];

    // process each printer info as a separate label
    var record = labelSetBuilder.addRecord();

    // compose text data
    // use framework's text markup feature to set text formatting
    // because text markup is xml you can use any xml tools to compose it
    // here we will use simple text manipulations to avoid cross-browser compatibility.
    var info = "<font family='Courier New' size='14'>"; // default font
    info = info + "Printer: <b>" + printer.name + "\n</b>";
    info = info + "PrinterType: " + printer.printerType;
    info = info + "\n<font size='10'>is local: " + printer.isLocal;
    info = info + "\nis online: " + printer.isConnected + "</font>";

    if (typeof printer.isTwinTurbo != "undefined")
    {
        if (printer.isTwinTurbo)
            info = info + "<i><u><br/>The printer is TwinTurbo!!!</u></i>";
        else
            info = info + "<font size='6'><br/>Oops, the printer is NOT TwinTurbo</font>";
    }

    if (typeof printer.isAutoCutSupported != "undefined")
    {
        if (printer.isAutoCutSupported)
            info = info + "<i><u><br/>The printer supports auto-cut!!!</u></i>";
        else
            info = info + "<font size='6'><br/>The printer does not supports auto-cut</font>";
    }

    info = info + "</font>";

    // when printing put info into object with name "Text"
    record.setTextMarkup("Text", info);
}

See print() function for a complete sample.

Note: Here is another blog post regarding using text markup. And one more regarding printing multiple labels.

November 10, 2011

DYMO SDK Extension Update for Firefox 8.0

Filed under: News,SDK News — pi @ 11:02 pm
Tags:

The Firefox extension for DYMO SDK has been updated to support Firefox 8. The extension is available here. The FAQ article is here.

Please note that the Firefox extension is deprecated. No new development will be done for the extension. For new projects please use the Javascript library from the DYMO Label Framework. We encourage developers to switch to the new API even for current projects. Here are some benefits the new DYMO Label Framework API provides in comparison to the extension:

  • DYMO Label Framework API provides a cross-browser and cross-platform pure Javascript API. The same API supports all major browsers on Windows and Mac. The Firefox extension API can be used only in Firefox on Windows.
  • All necessary Framework installation is done by the DYMO Label software installer. By contrast the Firefox extension must be downloaded by customers separately and installed manually.
  • DYMO Label Framework supports and will support all the DYMO printers. New printers will not be supported by the extension.

The auto-update functionality isn’t included in this version. We will add it later.

October 12, 2011

SDK Troubleshooting Tips

Filed under: Tips — Vladimir @ 5:29 am
Tags:

Suppose you are a developer and you are integrating a DYMO LabelWriter or LabelManager printer into your application by using DYMO Label Framework or older DYMO Label SDK API. Usually the integration is quite simple and "just works", and you can print a first label in a matter of minutes. Sometimes however, something might went wrong and don’t have the expected result. Or everything is fine on your machine, but the application does not work on the customer’s machine. What to do? Here are some tips could help in troubleshooting and investigating the problem.

Check DYMO Label software version

In most common usage scenarios, the DYMO Label software is required to be installed on the same machine where your application is running (for more information, see this and this). Usually we recommend to install the latest available version, unless there are knowing problems with a particular release. The latest version is available from DYMO site, here is the link.

Do a test print from DYMO Label software

Try printing a label from the DYMO Label software. DYMO Label software and the SDK libraries share a lot of underling code, so, if you can’t print by using the SDK, there is a big chance there will be problems with the DYMO Label as well. So, if you can’t print from DYMO Label or there are other problems running it, then contact DYMO tech support. Usually you will be asked to provide installation/configuration information, this can be obtaining by running LWSupport utility from the “[Program Files]\DYMO\DYMO Label Software\Support” folder.

Restart (open/close) web browser

If you are using DYMO Label Framework JavaScript library and just installed DYMO Label software, you might need to restart the browser to have the Framework plugins loaded. Also, you might need to restart the browser if you have added a new DYMO printer.

Verify browser compatibility and the Framework installation status

If you are using DYMO Label Framework JavaScript library, open http://labelwriter.com/software/dls/sdk/samples/js/CheckEnvironment/CheckEnvironment.html and click on “Check” button. The installation information will be displayed.

Collect trace/log information

DYMO libraries can generate log/trace information is not visible to end-user. To grab it use DebugView on Windows and standard Console application on Mac. On Windows: start DebugView, start your application, print a label, collect all messages displayed in DebugView. On Mac: open Console application, clear current messages, start your application, print a label, collect all messages displayed. Send all the collected messages to the e-mail address below.

Contact SDK support line

If you have any questions regarding the SDK, e-mail us at [sdkreply at newellco  com]. Please note, this is SDK-only support e-mail. For questions regarding DYMO Label software itself, please contact DYMO tech support

Next Page »

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 61 other followers