C#如何恢复从重定向到另一台打印机的打印机中暂停作业?是否可以



我试图从离线打印机中恢复我的printjobs,以打印在另一台打印机中。我觉得我快到了,但是我不确定AddJob()是否是最好的方法,或者我只是不适合我所拥有的代码。

因此,我目前拥有的是以下内容。我从旧打印机中收集工作,也知道如何取消它们。但是我似乎找不到从旧队列中检索信息并转移到新打印机和简历的方法。

// Create the printer server and print queue objects
        LocalPrintServer localPrintServer = new LocalPrintServer();
        PrintQueue defaultPrintQueue = LocalPrintServer.GetDefaultPrintQueue();
        //Set the correct printer
        pname = this.listBox1.SelectedItem.ToString();
        //Gather print jobs from the offline printer
        GetPrintJobsCollection(defaultprinter);
        //Note sure how to use this
        foreach (string file in printJobCollection)
        {              
            // Call AddJob
            PrintSystemJobInfo myPrintJob = defaultPrintQueue.AddJob(file);
            // Write a Byte buffer to the JobStream and close the stream
            Stream myStream = myPrintJob.JobStream;
            Byte[] myByteBuffer = UnicodeEncoding.Unicode.GetBytes("This is a test string for the print job stream.");
            myStream.Write(myByteBuffer, 0, myByteBuffer.Length);
            myStream.Close();
        }
        //Cancel old jobs on the old printer
        CancelPrintJob(defaultprinter);
prntJob.InvokeMethod("Resume", null);

最新更新