Reputation: 1
I was using dymo.label
from nuget, then I changed to the dymoSDK
and now it doesn't work anymore. I got an application programed with C# with windows forms
The old code was
DymoAddIn.Open("c:\\username\\files\\output\\artikel.label");
DymoLabels.SetField("pieces", "store: " + some + " " + some2);
DymoAddIn.StartPrintJob();
DymoAddIn.Print2(1, false, 2);
DymoAddIn.EndPrintJob();
How do I get it to start printing? How di I change my label?
I'm using
using DymoSDK.Implementations;
using DymoSDK.Interfaces;
Upvotes: -1
Views: 346
Reputation: 11
if you are using dymoSDKLabel you are probably running with the connect version of the software, not the legacy Dymo Label Creator, which uses the DymoAddin
I've been working with both and here's how im putting in my code c#:
//Beginning of code, necessary
try
{
DymoSDK.App.Init();
}
catch (ReflectionTypeLoadException ex)
{
LogHelper.WriteException(ex);
}
//initialize label variable
dymoSDKLabel = DymoLabel.Instance;
//set selected printers into DymoPrinter Instance
try
{
Printers = await DymoPrinter.Instance.GetPrinters();
}
catch(Exception ex)
{
LogHelper.WriteException(ex);
}
// Load in selected dymo format in a .label file from db:
string dymoSDKLabelToUse = Path.Combine(labelPath, selectedKeyAsString);
// Validation for Dymo XML format in .label file
try
{
var dymoXmlLabel = XDocument.Load(dymoSDKLabelToUse);
var DymoXmlLabel = dymoXmlLabel.ToString();
dymoSDKLabel.LoadLabelFromXML(DymoXmlLabel);
}
catch (Exception ex)
{}
LabelObjects = dymoSDKLabel.GetLabelObjects().ToList();
// Update Dymo Objects after Label has been created
var ItemDescription = LabelObjects.FirstOrDefault(obj => obj.Name == "ItemDescription");
var ItemBarcode = LabelObjects.FirstOrDefault(obj => obj.Name == "ItemBarcode");
//update label objects with variable data
dymoSDKLabel.UpdateLabelObject(ItemDescription, ProductName);
dymoSDKLabel.UpdateLabelObject(ItemBarcode, latestPluNumber);
//print function:
var dymoPrinters = Printers.FirstOrDefault(printer => printer.Name == SelectedPrinter.Value);
await DymoPrinter.Instance.PrintLabel(dymoSDKLabel, dymoPrinters.Name, Qty);
As long as the nuget package for the sdk and the supporting dependencies are in there, it should work. I'm skipping a lot of code that has nothing to do with dymo in here, but that's the general idea
Upvotes: 1