1

我制作了一个用于打印 Dymo 标签的小应用程序,它可以按预期工作,但是当我在 Surface 平板电脑上运行它时,它会在我按下打印按钮后禁用缩放。如果重新打开,缩放是正确的,直到再次按下打印按钮。谁能告诉我为什么?

打印按钮仅运行具有以下代码的 LabelPrinter 类:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dymo;
using System.Windows.Forms;

namespace LabelPrinter
{
    class LabelPrinter
    {
        private DymoAddInClass dymoAddIn;
        private DymoLabelsClass dymoLabels;
        private string labelPath, classRoom;
        private int labelCount;

        public LabelPrinter(string labelPath, string classRoom, int labelCount)
        {
            dymoAddIn = new DymoAddInClass();
            dymoLabels = new DymoLabelsClass();

            this.labelPath = labelPath;
            this.classRoom = classRoom;
            this.labelCount = labelCount;
        }

        public void printLabels()
        {
            dymoAddIn.SelectPrinter(dymoAddIn.GetDymoPrinters().Split('|')[0]);
            if (dymoAddIn.Open(labelPath))
            {
                int firstNo = StaticMethods.getNextCodeEntryWithString(classRoom), lastNo = firstNo + labelCount;

                dymoAddIn.StartPrintJob();
                for (int i = firstNo; i < lastNo; i++)
                {
                    foreach (string objName in dymoLabels.GetObjectNames(true).Split('|'))
                    {
                        dymoLabels.SetField(objName, classRoom + "_" + i);
                    }

                    dymoAddIn.Print(1, false);
                }
                dymoAddIn.EndPrintJob();
            }
        }
    }
}
4

0 回答 0