Print of pdf file to network printer fails
-
Hello all, Heard some great stuff about the code project so I decided to join the community and hope to be able to help others in the future as well. Not yet there though since i'm fairly new to vb.net Anyway: I need to print PDF files that are on disk to a network printer. I searched for some printing code on the net and found several similar approaches. However printing only seems to work to local printers, not network printers. Even on local printers it sometimes fails. I used the following code: Dim PD As New System.Drawing.Printing.PrintDocument Dim DefPrint As String = PD.DefaultPageSettings.PrinterSettings.PrinterName PD.DefaultPageSettings.PrinterSettings.PrinterName = .PrinterNaam Dim NP As New Process() NP.StartInfo.FileName = "c:\test.pdf" NP.StartInfo.WindowStyle = ProcessWindowStyle.Hidden NP.StartInfo.Verb = "Print" NP.Start() NP.WaitForExit(9000) If Not NP.HasExited Then NP.Kill() End If PD.DefaultPageSettings.PrinterSettings.PrinterName = DefPrint any way to improve this piece of code ? it launches the print command to acrobat, but maybe there is a better trick to do the printing. How comes this doesn't work for network printers ? Thanks in advance, Nick