I am trying to print to a network printer from the code, but the status of the network printer in the print dialog says Access denied, unable to connect , and the print button is disabled. But I can print on this printer very well if I print from another application. And, if you select "Print to PDF" in the print dialog box, this also works great. I just can't print on a network printer. Do I have any permissions?
if (File.Exists(previewDocument)) File.Delete(previewDocument); PrintDialog printD = new PrintDialog(); printD.PageRangeSelection = PageRangeSelection.AllPages; printD.UserPageRangeEnabled = true; if (printD.ShowDialog() ?? false) { XpsDocument xpsDoc = new XpsDocument(previewDocument, FileAccess.ReadWrite); XpsDocumentWriter xpsWriter = XpsDocument.CreateXpsDocumentWriter(xpsDoc); xpsWriter.Write(((IDocumentPaginatorSource)messageFlow).DocumentPaginator); FixedDocumentSequence fixedDocSeq = xpsDoc.GetFixedDocumentSequence(); printD.PrintDocument(fixedDocSeq.DocumentPaginator, "Hello!"); }
c # printing wpf
Arm0geddon
source share