2016-06-08 281 views
-1

我试图打印PDF文件,使用默认打印机打印时没有问题,但是当我想使用辅助打印机进行打印时,仍然使用默认打印。如何使用不带打印机的默认打印机(VB Net)打印PDF

这是我的代码:

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() 

我怎么能做到吗?

谢谢大家。

回答

0

使用Printer Settings.Printername命名空间下 System.Drawing.Printing

然后指定你的打印机(“佳能MG3500系列”)的名称

PrinterSettings控制用于配置如何将文档通过指定印刷打印机。 source

这应该这样做。

注:这也可以让你用你的应用在打印机上设置(

i.e. Paper size 

我用这个,每次我需要使用两台打印机

i.e one for the O.R. then another for a document

使用Here is a good example这与一个combobox一起选择网络中的任何打印机。

+0

由于MYK但我发现溶液更换坏线为:壳牌(的String.Format(“RUNDLL32 printui.dll,PrintUIEntry/Y/N ”“ {0}“”“,”打印机名称“)) –

+0

很高兴您可以解决该错误。它在[这里的例子]之一(http://vbcity.com/forums/p/68137/273274.aspx#273274) –

0

我发现溶液替换坏线:

Shell(String.Format("rundll32 printui.dll,PrintUIEntry /y /n ""{0}""", "Printer name")) 
相关问题