I want to print PDF files on a network printer placed on my print server. I written the code below, and it works for local printers only. When I use a network printer name, it doesn't not work.
Dim ProcessoImp As New Process
Dim VerToUse As String
VerToUse = "PrintTo"
ProcessoImp.StartInfo.CreateNoWindow = False
ProcessoImp.StartInfo.Verb = VerToUse
ProcessoImp.StartInfo.FileName = PrintFileList(i)
ProcessoImp.StartInfo.Arguments = "\\PrintServerMachine\samsung laser"
ProcessoImp.Start()
ProcessoImp.WaitForExit(10000)
ProcessoImp.CloseMainWindow()
ProcessoImp.Close()
Remember that if I use a local printer, it works perfectly, but if it's a network printer, it does not work!
What can I do to solve this problem?
More than likely, you do not have sufficient rights to print to that network printer via Visual Studio. You may try to impersonate another user or elevate current user access levels to allow printing on that network printer.
Alternatively, you should try using the printing.PrintDocument Class.
This is a duplicate question to this: Printing from ASP.NET to a network printer