I tried using the code on some PCs.
using (var lps = new LocalPrintServer()) using(var pqueue = lps.GetPrintQueue("PRINTER-NAME")) { pqueue.AddJob("job-name", @"C:\example.xps", false, pticket); }
It didn’t work on just one PC. The application froze with the AddJob method. It never ended even after a long wait. There are no exceptions.
The PC where this problem occurred is Windows10 and the application CreatorsUpdate. Other PCs: Windows7, Windows8.1 and Windows10 use AnniversaryUpdate.
Is this problem a CreatorsUpdate error?
Addition:
A PC that has CreatorsUpdate can print an xps file using this code.
using (var lps = new LocalPrintServer()) using(var pqueue = lps.GetPrintQueue("PRINTER-NAME")) using (var doc = new XpsDocument(@"C:\example.xps", System.IO.FileAccess.Read)) { var writer = PrintQueue.CreateXpsDocumentWriter(pqueue); var docSeq = doc.GetFixedDocumentSequence(); writer.Write(doc, pticket); }
blz
source share