I am trying to print XPS stream through System.Printing
namespace
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();
XpsPrinterUtils.ModifyPrintTicket from github
The code is not working and I am stuck with this.
Anyone has good idea or solution to this to print (Xps file stream obtained by pdftron) using system.printing namespace and change page source dynamically.
I did not test, but this would appear to be closer to the correct solution.
You might want to test the above out, by creating stream_sink as a stream to a file on disk, and verifying that stream_source.CopyTo(stream_sink) works as expected. If so, then any remaining issue would be with using the System.Printing API, and not something with PDFNet.