我正在尝试从脱机打印机恢复我的打印作业,以便在另一台打印机上打印。我觉得自己快到了,但是我不确定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);
答案 0 :(得分:-2)
prntJob.InvokeMethod("Resume", null);