C# 调用 codesoft2021 的Lppx2.tlb 打印很慢,慢5秒左右,求大神帮忙看看具体什么问题,只贴了部分代码
try
{
labApp = new LabelManager2.ApplicationClass();
labApp.Documents.Open(labFile, false); //调用设计好的label文件
doc = labApp.ActiveDocument;
if (xmlflag == "0")
{
for (int i = 1; i <= doc.Variables.Count; i++)
{
//Console.WriteLine("获取到的变量名为:" + doc.Variables.Item(i).Name.ToString());
varList.Add(doc.Variables.Item(i).Name.ToString());
for (int a = 0; a < Attributes_Name.Length; a++)
{
if (varList[i - 1].ToString() == Attributes_Name[a].ToString())
{
doc.Variables.FormVariables.Item(varList[i - 1].ToString()).Value = Attributes_Value[a];
}
if (varList[i - 1].ToString() == "Barcode")
{
doc.Variables.FormVariables.Item("Barcode").Value = Barcode;
}
}
}
/*****************************************************************************
//doc.Variables.FormVariables.Item("TPGN_Revision").Value = TPGN_Revision;
//doc.Variables.FormVariables.Item("Project").Value = Project;
doc.Variables.FormVariables.Item("Part_Number").Value = Attributes_Name[0];
doc.Variables.FormVariables.Item("PART_NAME").Value = PART_NAME;
doc.Variables.FormVariables.Item("TRACKING_NUMBER").Value = TRACKING_NUMBER;
doc.Variables.FormVariables.Item("JOYSON_PART_NUMBER").Value = JOYSON_PART_NUMBER;
/*****************************************************************************/
}
else
{
/*****************************************************************************/
doc.Variables.FormVariables.Item("TRACKING_NUMBER").Value = YYMMDD + TRACKIN;
doc.Variables.FormVariables.Item("Barcode").Value = Barcode;
doc.Variables.FormVariables.Item("PART_NAME").Value = PARTNAME;
doc.Variables.FormVariables.Item("Part_Number").Value = HKMCPARTNUMBER;
doc.Variables.FormVariables.Item("JOYSON_PART_NUMBER").Value = JOYSONPARTNUMBER;
/*****************************************************************************/
}
string printerName = this.cmbPrinter.Text;
doc.Printer.SwitchTo(printerName);
doc.PrintDocument(1);
doc.FormFeed();