Apr 302010

In the last blog, I started out with a simple label printing application using the DLS SDK. If you are planning on using the SDK, you’ll need to become familiar with two objects that will do the bulk of label printing work in your application. The first one the DymoAddin object, the other is the DymoLabels object. We will examine on the DymoAddin object in this post.


The DymoAddin object got its name from the time when DYMO needed to create addins for 3rd party applications. Instead of re-writing all the label printing code in a separate library, then using the library to implement the 3rd party addins (like the DLS MS Office Addins, DLS ACT! Addin, DLS QuickBooks Addin), we simply added a COM interface to the DLS application so we can leverage the label printing functionality from the DLS application. The first interface exposed was called the IDymoAddin interface, and the object that implemented the interface was called the DymoAddin object.

There are many methods exposed in the IDymoAddin interface, however, only a part of it is really intended for the SDK. The methods that don’t fall in this group are there because we (i.e. DYMO) needed it to implement some functionality for the addins we write for other applications. Call it lack of planning or oversight, these methods and properties that are really meant for internal DYMO use are lumped together in the same IDymoAddin interface that is used for SDK applications. For the most part, you should avoid using these methods and properties in your application. But as you sit down to understand the DLS SDK and design your own application, you’ll likely find that these methods and properties are too specialized and are not needed for your SDK application.

But what are these functions and methods that you shouldn’t use? Instead of listing them here, I will instead focus on the methods that are meant to be used by SDK applications.

Main Functionality

In the last blog, I outlined the three main concepts used in the DLS SDK. The first is the concept of a label file. The main functionality of the DymoAddin object is to implement the IDymoAddin interface, which provides operations you can perform on a label file, including opening, saving, and printing a label file. Because printing is part of the functionality, the IDymoAddin interface also provides methods to list and select DYMO printers for use in your SDK application. I will explore these methods and their usage (in C#) below.

File Operations

The Open(), Save(), and SaveAs() methods combined to give you the ability to open and save labels on your computer’s local file system. The same operations can be used on network storage if the storage location is addressable using UNC (i.e. Universal Naming Convention).

The following example shows how to open a label file and then save it with a different file name:

 1 private void FileOperatoinsExample()
 2 {
 3     DymoAddInClass _dymoAddin = new DymoAddInClass();
 5     // open a label file using absolute path, relative path
 6     // or UNC (for network accessible locations)
 7     if (_dymoAddin.Open(@"..LabelsSample.label"))
 8     {
 9         _dymoAddin.SaveAs(@"..LabelsSampleCopy.label");
10     }
12     if (_dymoAddin.Open(@"C:UsersckhsuLabelsSample.label"))
13     {
14         _dymoAddin.SaveAs(@"C:UsersckhsulabelsSampleCopy.label");
15     }
17     if (_dymoAddin.Open(@"\File ServerSharedLabelsSample.label"))
18     {
19         _dymoAddin.SaveAs(@"\File ServerSharedLabelsSampleCopy.label");
20     }
21 }

Web Applications

Sometimes the label file you need is located in the cloud and you need to access it using an URL. The OpenURL() method is created for this purpose.

Proxy Server and Proxy Bypass

The OpenURL() method is implemented using WinInet. This means that the user’s proxy settings in IE is used when calling the OpenURL(). But depending on your application, this might not be desirable. You can use the following methods and properties to control proxy settings used for the OpenURL() method. These settings are good for the lifetime of the DymoAddinObject, but are not persistent beyond that. So if you free and create another instance of the DymoAddinObject, you will need to setup the custom proxy settings again for the next OpenURL call.

  • ProxyBypass property – set to True to bypass all proxy servers. When this property is set to True, it overrides all other proxy settings.
  • SetupProxySettings() method – setup custom proxy settings.
  • ClearProxySettings() method – clear all proxy settings and revert back to using IE’s proxy settings.

The following example shows how to open a label file using an URL.

 1 private void URLFileOperatoinsExample()
 2 {
 3     DymoAddInClass _dymoAddin = new DymoAddInClass();
 5     // use custom proxy setup.
 6     // by default, the OpenURL() method uses the same proxy
 7     // settings as IE
 8     _dymoAddin.proxyBypass = false;
 9     _dymoAddin.SetupProxySettings("http", "dymo_proxy_server", 80, "*.internal.dymo.*", "", "");
11     // open a label file using URL
12     if (_dymoAddin.OpenURL("http://www.mylabelprinter.com/labels/shipping.lwl"))
13     {
14         _dymoAddin.SaveAs(@"LabelsSampleCopy.label");
15     }
16 }

Database Operations

If your application uses a database to store label files, you can use the OpenStream() and SaveStream() methods to open and save label files using memory buffers.

The following example shows how to open and save label files into memory buffers:

 1 private void OpenAndSaveStreamExample()
 2 {
 3     DymoAddInClass _dymoAddin = new DymoAddInClass();
 5     // this is the buffer that will hold an array of bytes
 6     object buf = null;
 8     if (_dymoAddin.Open(System.IO.Path.Combine(
 9                             System.IO.Directory.GetCurrentDirectory(),
10                             @"DatabaseLabel.label")))
11     {
12         // get an array of bytes from Save Stream
13         buf = _dymoAddin.SaveStream();
15         // at this point, you can store buf as a blob
16         // in your database
17         byte[] blob = (byte[])buf;
18     }
20     // to open a label file from a blob in your database
21     // first, read the blob into into an array of bytes
22     // then pass the array of bytes to OpenStream
23     System.IO.MemoryStream ms = new System.IO.MemoryStream();
25     // the following line is psuedo code aimed to illustrate how one
26     // might read a blob into an array of bytes
27     !!!Database.Table("Labels Table").Field("Shipping Label").SaveToStream(ms);
29     // at this point, you can read the bytes
30     _dymoAddin.OpenStream(ms.GetBuffer());
31 }

Printer Related Operations

The DLS SDK (and therefore your SDK applications) can only be used with LabelWriter printers. Because of this, we added printer listing and selection methods to filter out printers that are not compatible with the DLS SDK so your application will not need extra code to deal with printer compatibility and selection issues.

The following example shows how to get a list of LabelWriter printers installed on the computer, and selects a printer named “My LabelWriter” to print a label file:

 1 private void SelectPrinterAndPrintLabelExample()
 2 {
 3     DymoAddInClass _dymoAddin = new DymoAddInClass();
 5     string[] printers = _dymoAddin.GetDymoPrinters().Split(new char[] { '|' });
 6     foreach (var printer in printers)
 7     {
 8         // find the printer we want to print to
 9         if (printer == "My LabelWriter")
10         {
11             // select it first
12             _dymoAddin.SelectPrinter(printer);
14             // then print the currently open label
15             if (_dymoAddin.IsTwinTurboPrinter(printer))
16             {
17                 // print one copy of label to the left tray
18                 _dymoAddin.Print2(1, false, 0);
19             }
20             else
21             {
22                 // print one copy of label to the only tray
23                 _dymoAddin.Print(1, false);
24             }
25             break;
26         }
27     }
28 }

A new method worth mentioning is the IsPrinterOnline() method, which return the online/offline status of a printer.


Although the DymoAddin object’s name may not invoke any ideas of the functionality it provides, it is an important part of the because of the rich features it provides. I hope this blogs gives you a good idea of the DymoAddin object’s capabilities and how to best use the capabilities for your specific application.