本文介绍了如何使用vb.net设置打印机属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 EDRAW 浏览Microsoft Word,并且可以Print , Preview , ETC...而且我计划为其添加一些功能.我正在为Print Short (8.5 by 11 inches)Print Long (8.5 by 13 inches)添加2个按钮,并且我有2个打印机,分别用于打印多头和空头.如何在每个按钮中设置打印机的属性?如果我单击按钮短",它将使用与按钮长相同的打印机1进行短时打印,但是它在打印机2中.

I am using EDRAW to browse a Microsoft Word and can be Print , Preview , ETC... And I am planning to add some features to it. I am adding 2 buttons for Print Short (8.5 by 11 inches) and Print Long (8.5 by 13 inches) and I have 2 printers for long and short. How to set the properties of the printers in each button?. If I click button short it will print short using printer 1 same as the button long but it is in printer 2.

我正在遵循上面提供的链接中的代码.

I am following the code in the Link provided above.

有人知道吗?任何建议都有帮助,也很容易被接受.谢谢..干杯..两天后,我将给予50英镑的悬赏金..

Anyone has an idea about it?. Any suggestion well help and well be accepted. Thanks.. Cheers.. I will give a 50 bounty to it after two days..

作为@Hadi请求的代码

这是我的打印按钮代码.

Here is my button code for print.

Private Sub btnPrint_Click(sender As System.Object, e As System.EventArgs) Handles btnPrint.Click
    AxEDOffice1.SetActivePrinter("Printer Name")
    AxEDOffice1.ActiveDocument.PageSetup.PaperSize = Microsoft.Office.Interop.Word.WdPaperSize.wdPaperA4
    AxEDOffice1.PrintDialog()
End Sub

并在AxEDOffice1.ActiveDocument.PageSetup.PaperSize = Microsoft.Office.Interop.Word.WdPaperSize.wdPaperA4

推荐答案

在检查了库之后,您要做的就是使用SetActivePrinter方法更改默认打印机,如下所示:

After Checking the library all you have to do is using SetActivePrinter Method to change your default printer like the following:

 AxEDOffice1.SetActivePrinter("Adobe PDF")

要更改PaperSize,您必须使用以下内容

And to change PaperSize you have to use the following

AxEDOffice1.ActiveDocument.PageSetup.PaperSize = Microsoft.Office.Interop.Word.WdPaperSize.wdPaperA4

AxEDOffice1.ActiveDocumentMicrosoft.Office.Interop.Word.WordDocumentClass

代码对其进行了测试,并且效果很好.

Code tested it and it works fine.

在此 MSDN文章有很多建议.

要直接打印文档而不显示PrintDialog,必须使用PrintOut功能.

To Print your document directly without showing PrintDialog you have to use PrintOut Function.

AxEDOffice1.PrintOut(EDOfficeLib.WdPrintOutRange.wdPrintAllDocument)

这篇关于如何使用vb.net设置打印机属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 07:00