我正在尝试通过System.Printing
命名空间打印 XPS 流
Stream stm = pdftron.PDF.Convert.ToXps(pdfdoc);
LocalPrintServer localPrintServer = new LocalPrintServer();
PrintQueueCollection pqc = localPrintServer.GetPrintQueues();
PrintQueue defaultPrintQueue = localPrintServer.GetPrintQueue(_PrinterName);
MemoryStream ms = defaultPrintQueue.GetPrintCapabilitiesAsXml();
// Call AddJob
System.Printing.PrintTicket printTicket = defaultPrintQueue.DefaultPrintTicket;
PrintSystemJobInfo myPrintJob = defaultPrintQueue.AddJob();
Stream myStream = myPrintJob.JobStream;//may be this line is wrong, can you suggest alternative?
myStream = stm;//may be this line is wrong, can you suggest alternative?
myStream.Close();//may be this line is wrong, can you suggest alternative?
var inp= defaultPrintQueue.GetPrintCapabilities().InputBinCapability;
System.Printing.PrintTicket newprintTicket = XpsPrinterUtils.ModifyPrintTicket(printTicket, "psk:JobInputBin", "NS0000:" + _PaperSource);
System.Printing.ValidationResult vr = defaultPrintQueue.MergeAndValidatePrintTicket(printTicket, newprintTicket);// this line giving exception while changing page source merge and validate
myPrintJob.Commit();
来自 github 的 XpsPrinterUtils.ModifyPrintTicket
代码不工作,我坚持这一点。
任何人对此都有很好的想法或解决方案,可以使用 system.printing 命名空间打印(pdftron 获得的 Xps 文件流)并动态更改页面源。