在网络打印机上打印双面 [英] Print duplex on network printer

查看:386
本文介绍了在网络打印机上打印双面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,如果所选打印机支持双面打印,我需要让用户能够打印双面打印。 许多打印机选项在我的应用程序中没有多大意义,并且常见打印机对话框中的许多设置会对我的打印过程产生负面影响。 要处理我的应用程序强加的严格打印限制,我不想显示常见的打印对话框。 我希望能够在代码中更改设置。 我在PrinterSettings对象中使用duplex属性遇到了一个问题。 在此页面上, http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawingprintingduplexclasstopic.asp ,它指出双工属性指定打印机的双工设置。 这似乎只有在打印机安装为本地打印机时才有效。 我不确定这是否相关,但我发现这篇文章说明了在网络打印机上打印双面打印的问题。 http://support.microsoft.com/kb / q230743 / < span style ="FONT-SIZE:10pt; COLOR:blue; FONT-FAMILY:'Courier New'"> 我将网络打印机安装为本地打印机,如文章中所述。  我在下面提供的代码确实打印了双面打印。 我不想说我的应用程序只支持本地打印机。 如果使用网络打印机并显示打印对话框并导航到打印机属性对话框并将双面打印设置更改为双面打印,则应用程序确实打印双面打印。 我可以理解,如果用户在网络打印机上打印无法访问打印双面打印,并且打印命令会抛出某种类型的访问被拒绝错误。 如果我尝试使用API​​打开打印机,如果我使用设置双工属性所需的访问级别,我会收到拒绝访问错误。 令我困惑的是,如果我显示打印对话框,则双工属性的更改有效。 有没有办法从代码中重现相同的行为? 还有一种方法可以检测双工属性的设置是否也能在代码中工作? <?xml:namespace prefix = o ns ="urn: schemas-microsoft-com:office:office"/>

In my application I need to give the user the ability to print duplex if the selected printer supports duplex printing.  Many of the printer options do not make much sense in my application, and many of the settings in the common printer dialog would have a negative impact on my printing process.  To handle this strict printing constraint on which my application imposes I do not want to show the common print dialog.  I want to be able to change the settings from within code.  I have run across one problem using the duplex property off the PrinterSettings object.  On this page, http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawingprintingduplexclasstopic.asp, it states that the duplex property specifies the printer’s duplex setting.  This seems to only work if the printer is installed as a local printer.  I am not sure if this is related or not, but I found this article stating a problem in printing duplex on a network printer for Word automation. http://support.microsoft.com/kb/q230743/.  I installed my network printer as a local printer as the article stated for testing purposes.  The code I provided below did in fact print duplex.  I don’t wish to have to say that my application only supports local printers.  If a network printer is used and I show the print dialog and I navigate to the printer properties dialog and change the duplex setting to duplex, the application does indeed print duplex as well.  I can understand if the user printing on a network printer doesn’t have access to print duplex and the print command throws some type of access denied error.  Which if I try to open the printer using API’s I do get an access denied error if I use the level of access required to set the duplex property.  What confuses me is if I show the print dialog, the changing of the duplex property works.  Is there a way to reproduce that same behavior from within code?  Also is there a way to detect whether or not the setting of the duplex property worked from within code as well?

朋友 WithEvents pctPrintDocument As System.Drawing.Printing.PrintDocument

Friend WithEvents pctPrintDocument As System.Drawing.Printing.PrintDocument

朋友 WithEvents pctPrintDialog 作为 System.Windows.Forms.PrintDialog

Friend WithEvents pctPrintDialog As System.Windows.Forms.PrintDialog

......
如果 optDuplexDouble.Checked 然后
 
pctPrintDialog.Document = 。pctPrintDocument
  pctPrintDocument.PrinterSettings.Duplex = Duplex.Vertical
  pctPrintDocument.DefaultPageSettings.PrinterSettings.Duplex = Duplex.Vertical
  pctPrintDialog.PrinterSettings.Duplex = Duplex.Vertical
Else
 我
。pctPrintDocument.PrinterSettings.Duplex = Duplex.Simplex
结束 如果
......

......
If optDuplexDouble.Checked Then
 
pctPrintDialog.Document = Me.pctPrintDocument
  pctPrintDocument.PrinterSettings.Duplex = Duplex.Vertical
  pctPrintDocument.DefaultPageSettings.PrinterSettings.Duplex = Duplex.Vertical
  pctPrintDialog.PrinterSettings.Duplex = Duplex.Vertical
Else
  Me
.pctPrintDocument.PrinterSettings.Duplex = Duplex.Simplex
End If
......

 

 

 

推荐答案

嗨Tommy,

Hi Tommy,

您是否可以让您的程序使用网络打印机?

Were you able to get your program to work with a network printer?

谢谢


这篇关于在网络打印机上打印双面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆