Quantcast
Channel: JPHellemons
Viewing all articles
Browse latest Browse all 132

Working with the Dymo label sdk on Windows 2012 server

$
0
0

Dymo has some great label printing hardware and has a nice .Net SDK. It seems that they are moving away from the .Net SDK and more towards the JavaScript SDK. In my situation I wanted to host a small Rest service on a Windows 2012 server so that I can make an Ajax call with jQuery to it to print a label from my web application. So it is a kind of printing proxy with REST. We had previously only Internet explorer support in our web application, so using the Active X component was easy for us. Though it required a client installation and the client to configure the network shared printer.

The strange thing is that this code looks good at first sight. Also if you compare it with the Dymo label code. It even works great on my machine, but when I put it live on our production server it failed. No exception or whatsoever, but it simply said that there is no label writer.

StringBuilder sb = new StringBuilder
var label = DYMO.Label.Framework.Label.Open(System.Web.HttpContext.Current.Server.MapPath(@"~/Content/thelabel.label")); // mvc webapplication
label.SetObjectText("Address", sb.ToString());
label.Print(ConfigurationManager.AppSettings.Get("printername"));
// printername = \\pcname\dymo

Even when I list the label printer, it does not show up in the list. Printing with the default label printing software from dymo (version 8.x) works great on my machine and the server, but not by code.

StringBuilder sbPrinters = new StringBuilder();
DYMO.Label.Framework.Printers p = new DYMO.Label.Framework.Printers();
foreach(var printer in p.ToList())
{
    sbPrinters.AppendLine(printer.Name);
    sbPrinters.AppendLine(printer.ModelName);
    sbPrinters.AppendLine(printer.IsConnected.ToString());
    sbPrinters.AppendLine(printer.IsLocal.ToString());
    sbPrinters.AppendLine("-==========-");
}
return sbPrinters.ToString(); // empty...

I have tried an Asp.Net web application 4.5 with WebApi on Windows 2012 and a 4.0 Webforms application on Windows 2003. Both did not work. So what is wrong? I used the build in Visual Studio development server and on both windows servers (2003 and 2012) I used IIS. So that might be the problem. I have heard about Katana and OWIN and started a small test project with this guide. Somehow it works when you are not using IIS! I also tried Asp.Net impersonation in the web.config. Maybe running in full trust works, but I prefer a tiny Windows Service with Owin. So go check out the project page of Katana on codeplex or simply pull down this Nuget package of Microsoft Owin. This Channel9 video of 43 minutes is also a great online source to learn more about the Katana project, OWIN for Asp.Net.

Good luck with the Dymo .Net SDK!


Viewing all articles
Browse latest Browse all 132

Trending Articles