问题
I´m trying to print a pdf file, there is no problem to print it with the default printer but when I want to do it with a secondary printer it still printing with the default one.
This is my code:
Dim MyProcess As New Process
MyProcess.StartInfo.CreateNoWindow = False
MyProcess.StartInfo.Verb = "print"
'HERE IS WHERE I WANT TO CHANGE THE PRINTER (BUT THIS COMMAND IS IGNORED)
MyProcess.StartInfo.Arguments = "Canon MG3500 series"
MyProcess.StartInfo.UseShellExecute = True
MyProcess.StartInfo.FileName = My.Application.Info.DirectoryPath & "\Copias digitales\Temp.pdf"
MyProcess.Start()
MyProcess.WaitForExit(10000)
MyProcess.CloseMainWindow()
MyProcess.Close()
How can I make it?
Thank you all.
回答1:
Use Printer Settings.Printername under the Namespace System.Drawing.Printing
then specify the name of your Printer ( "Canon MG3500 series")
The PrinterSettings control is used to configure how a document is printed by specifying the printer.source
This should do it.
note: This also allows you to use your applied settings on your printer (
i.e. Paper size
I use this everytime I need to use two printers
i.e one for the O.R. then another for a document
Here is a good example of using this along with a combobox
to choose any printer in the network.
回答2:
I found the solution replacing the bad line with:
Shell(String.Format("rundll32 printui.dll,PrintUIEntry /y /n ""{0}""", "Printer name"))
来源:https://stackoverflow.com/questions/37714760/how-to-print-pdf-with-not-default-printer-with-code-vb-net