1

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?

user229044
  • 232,980
  • 40
  • 330
  • 338
Diego Oliveira
  • 63
  • 1
  • 3
  • 8

1 Answers1

0

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

Community
  • 1
  • 1
PeonProgrammer
  • 1,445
  • 2
  • 15
  • 27
  • 1
    Hello, I've solved this problem doing this: I removed the line: ProcessoImp.StartInfo.Arguments = "\\PrintServerMachine\samsung laser" And then, added the line: Shell(String.Format("rundll32 printui.dll,PrintUIEntry /y /n ""{0}""", "\\printermachine\samsung laser")) to set this printer as default on windows, and it works perfectly! – Diego Oliveira Jan 03 '14 at 12:53