Dec 262012
 

Hello everyone!

As promised, this is the second post in the FAQ series. Today, we will be getting a bit more technical and diving into some questions regarding SDK code. Let’s get started!

1. I am trying to create a label with several objects but this seems difficult to do using the SDK APIs. I feel like I am creating my label the wrong way. How should I be creating my label using the SDK?

Although it is possible to layout a label entirely using our APIs, we recommend that you first create your label using DLS and then load this label with our API. For most SDK applications this approach should work well as it will reduce the amount of code for creating the label as well as allow you to edit the data on the label based on any user inputs. For instance, let’s say your were making an application that would create name badges for a conference your company was hosting. You could create a label in DLS with two text fields: one for name and one for company. Then, as attendees arrived at your conference registration table, you could simply type in the name and company of the attendee and your application would update the data on the label using our APIs and print out the name badge. See the code samples below to learn how to load the label and update the label data using both the older SDK and newer Framework. For the purpose of these examples, assume your label was named “NameBadge.label” and your name and company text objects were named “NameTxt” and “CompanyTxt”, respectively.

DYMO SDK

DYMO Label Framework

 DymoAddInClass _dymoAddin = new DymoAddInClass();
 DymoLabelsClass _dymoLabel = new DymoLabelsClass();
 _dymoAddin.Open("NameBadge.label");
 _dymoLabel.SetField("NameTxt", "John Smith");
 _dymoLabel.SetField("CompanyTxt", "Newell Rubbermaid");
 _dymoAddin.Print(1, false);
 var label = DYMO.Label.Framework.Label.Open("NameBadge.label");
 label.SetObjectText("NameTxt", "John Smith");
 label.SetObjectText("CompanyTxt", "Newell Rubbermaid");
 label.Print("DYMO LabelWriter 450 Turbo");

2. Every time I print to my Twin Turbo the label prints from the left tray. How can I print to the right tray?

Changing to the right (or second) tray is relatively simple in both the SDK and the Framework. However, it may be difficult to find this setting without knowing where to look. In the SDK, you simply specify a tray number (an integer) to indicate which tray to print to. You will use the Print2() method instead of Print(). In the Framework, there is an enum you use in conjunction with the LabelWriterPrintParams class. See the examples below.

DYMO SDK

DYMO Label Framework

 _dymoAddin.Print2(1, false, 1);

 The third parameter in the line above indicates 
 the tray number to use.
 LabelWriterPrintParams p = new LabelWriterPrintParams();
 p.RollSelection = RollSelection.Right;
 label.Print("DYMO LabelWriter 450 Turbo", p);

3. How can I create a tape (continuous) label using your SDK?

To create a continuous label, you must use the DYMO Label Framework. The older DYMO SDK does not support continuous labels. The layout mechanism of a continuous label is quite different than that of a die-cut. A continuous label uses a cell layout system instead of the fixed location system of a die-cut label. For example, if you were using a die-cut label and wanted to place three text objects side-by-side-by-side, you would manually set the location (x,y coordinates) of the three objects on the label.

DieCutExample

However, for a continuous label, you would need to add three subcells to the root cell of the label and then insert each of your text objects into one of the cells.

ContExample

Continuous labels are the simplest way to create a label on the fly. Continuous labels automatically size to their content (unless otherwise specified) and provide an organized layout system. Below is some sample code illustrating how to create the label displayed above using the DYMO Label Framework and continuous labels.

            ContinuousLabel label = new ContinuousLabel("Tape9mm", PaperOrientation.Landscape, ContinuousLabelLengthMode.Auto, 0);
            label.RootCell.Subcells.Add(new ContinuousLabelCell());
            label.RootCell.Subcells.Add(new ContinuousLabelCell());
            label.RootCell.Subcells.Add(new ContinuousLabelCell());

            label.RootCell.Subcells[0].LabelObject = new TextObject("Txt0");
            label.RootCell.Subcells[1].LabelObject = new TextObject("Txt1");
            label.RootCell.Subcells[2].LabelObject = new TextObject("Txt2");

            label.SetObjectText("Txt0", "This");
            label.SetObjectText("Txt1", "is a");
            label.SetObjectText("Txt2", "test.");

4. I would like my application to interface with a DYMO scale. Is there a DYMO scales SDK?

We do not provide an SDK for DYMO scales. Our scales conform to the HID standard and can be accessed this way. The HID standard for scales is documented in section 4 of this document. Jan Axelson has a useful page on HID development with plenty of examples. Nicholas Piasecki and Mike O’Brien also provide some useful resources on HID scale development.

That wraps up this second FAQ post. Hopefully all of you developers found these posts useful and continue to use our SDK and our printers.  I hope everyone enjoys the rest of this holiday season and has a happy New Year!

  17 Responses to “DYMO SDK FAQ part 2”

  1. Great FAQ, I have been utilizing the JS framework for sometime now. The only issue I am running into is that printing using the JS library locks up the web browser to the point that it believes it has crashed especially on the first print job. Is there any way to use the JS library to ensure a smooth UI experience?

    • Hi Brian,
      Are you loading your printer objects the first time the user presses print? The call to GetPrinters() will be a blocking call as this is loading several assemblies and iterating through your installed printers. You could move this code to when your page loads to prevent the slowness when the user presses the print button. However, your page will take longer to load. This might be a better trade-off for you.

  2. Is it possible to create a continuous label using the javascript library and a labelwriter 450? I want to use non-adhesive continuous roll. However, with the labelwriter plugged in, there is no option to select a “continuous, non-adhesive” label in the label list??? Also, when I tried to load a sample continuous .label file I found on a Google search, DLS says no compatible printer is installed.

    Very frustrating! However I think the framework is really great and I am enjoying trying to incorporate it into a web project I have.

    I am using DLS 8.4.2.9.

    • Hi Jon,

      Since the LabelWriter 450 does not support our continuous tapes, you will not be able load one of our continuous papers in conjunction with the 450. You could, however, load one of our die cut labels and print to the 450 even if it contains a continuous roll.

      • Thanks for clarifying – I can stop wasting time wondering whether it was me doing something wrong! I’ve loaded up a lever arch label 59mmx190mm (similar width to continuous roll and largest length I could find) and will start working with that as a template. Thanks again.

  3. @dribdymo: I will have to give that a try, I have been struggling with this issue for awhile but haven’t found a good way of dealing with it. I had originally wanted and attempted to move the printing into a web worker but due to functions requiring the DOM object would not work.

  4. Dymo Label Buddy is the efficient way of organizing things. I mostly used this to differentiate the stuff of my two sons.  

  5. I’m trying to accomplish one of 2 things (if possible).
    Either improve the print quality of printing a pdf from the browser (printer properties didn’t helped).
    Or get working example of a script to select a .label file (or variable encoded like that), and select the dymo printer, and print…
    Can someone help me pls?
    The rest i would try to code myself…

  6. Is there a place to ask support questions about the Dymo SDK? I’m having trouble running the .net3.5 app targeting a x86 machine.

  7. Very soon my company is going to implement new internal security measures that will not allow me to print by specifying a printer name, they say I’ll have to specify the printer’s IP address instead. Is that possible? If not, any suggestions for getting around it?

    My current code:

    var label;
    var labelTxt = 'Label text…';

    $.get('LabelFile.xml',
    function(labelXml) {
    label = dymo.label.framework.openLabelXml(labelXml);
    label.setObjectText('text', labelTxt);

    var numLabels = numCards.getValue();
    label.print('printerName', dymo.label.framework.createLabelWriterPrintParamsXml({copies:numLabels}));
    },
    'text'
    );

    • Hi Stephen,

      Unfortunately, our printers are not network printers. They are not actually assigned IP addresses. They are designed to be attached to a PC via USB or shared from another location via the OS. Keeping these things in mind, the API can only use the name of the printer to send print jobs to.

      Also, with the above information, will the new security rules actually effect local non network printers?

  8. Hi,
    I’m using this code in my aspx page to print a label from a browser:

    var label = DYMO.Label.Framework.Label.Open(“NameLabele.label”);
    label.SetObjectText(“NameTxt”, “John Smith”);
    label.SetObjectText(“CompanyTxt”, “Newell Rubbermaid”);
    label.Print(“DYMO LabelWriter 400”);

    It prints,but not at same place as when I do it through DLS although I use the same xml label model.
    How can I change the top margin of the printing programatically ?
    Thanks

  9. Hi,

    is there a way to identify if a printer has two trays?

    LabelWriterPrintParams p = new LabelWriterPrintParams();
    p.RollSelection = RollSelection.Right;
    label.Print(“DYMO LabelWriter 450 Turbo”, p);

    This only works for the two tray printers, so I want to show the user a tray selector if the printer that is selected supports two trays.
    Thanks in advance
    Julian

  10. Can pdf files be loaded in this SDK. Which other APIs can be used to achieve this?

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)