Print multiple labels
How to print multiple labels with different values from the same template in one print job in c#.
The values that we want to print are dynamic.
I will be happy if you can help us.
My code (We don't want to use a loop, we need to use print function only once to print all labels with different values):
Engine btEngine = null;
LabelFormatDocument btFormat = btEngine.Documents.Open(FormatFile, PrinterName);
Messages btMessages = null;
btFormat.PrintSetup.EnablePrompting = false;
btFormat.PrintSetup.IdenticalCopiesOfLabel = 1;
foreach (string serial in serialNumbers)
{
if (serial == "") {
continue;
}
// Set the serial number to the label
btFormat.SubStrings.SetSubString("fld_KitSn", serial);
Result nResult = btFormat.Print(LabelName + PrinterName + pcbSn, out btMessages);
}
errMsg += "";
foreach (Message m in btMessages)
{
errMsg += "Message: ";
errMsg += ", Category = " + m.Category;
errMsg += " , Category = " + m.Category;
errMsg += " , ID = " + m.ID;
errMsg += ", Severity = " + m.Severity;
errMsg += ", Text = " + m.Text;
errMsg += ", Message End. ";
}
Console.WriteLine(" btMessages= " + errMsg);
// Close the current format without saving.
btFormat.Close(SaveOptions.DoNotSaveChanges);
-
Have you thought about outputting the numbers to a Text file with a set name and either use Integration Builder to print the labels automatically or link the label to the text file as if it were a database and then run the print command so that it prints all the records?
0 -
I transfer the values of serials to the function, I don't need to use a text file.
Is there a way to print multiple labels with different values from the same template in one print job.Please tell me how I can change code from here in c# :
foreach (string serial in serialNumbers)
{
if (serial == "") {
continue;
}
// Set the serial number to the label
btFormat.SubStrings.SetSubString("fld_KitSn", serial);
Result nResult = btFormat.Print(LabelName + PrinterName + pcbSn, out btMessages);
}0 -
Not as a single print command as far as I am aware, you would need to run a different print command for each or else configure as above
0
請登入寫評論。
評論
3 條評論