简体   繁体   English

在 PrintDialog 中以编程方式选择打印机

[英]Programmatically select a printer in PrintDialog

I have a Web Browser control in Windows forms.我有一个 Windows 窗体中的 Web 浏览器控件。 It loads a HTML file.它加载一个 HTML 文件。 I want to be able to give an option to the user to Save this as PDF file.我希望能够为用户提供将其另存为 PDF 文件的选项。

If the user has "CutePDF Writer" installed then I thought I can just select it programmatically from Print Dialog and Save it as PDF.如果用户安装了“CutePDF Writer”,那么我想我可以从打印对话框中以编程方式选择它并将其另存为 PDF。 I am showing the PrintDialog using Web_browser_control.ShowPrintDialog().我正在使用 Web_browser_control.ShowPrintDialog() 显示 PrintDialog。 Is there a way to select a printer(CutePDF Writer in my case) programmatically in this Print Dialog without user intervention?有没有办法在这个打印对话框中以编程方式选择打印机(在我的例子中是CutePDF Writer)而无需用户干预?

You can do like, this,你可以像这样,

printDocument.PrinterSettings.PrinterName = "YOUR_PRINTER";

Refer, https://andres.jaimes.net/65/how-to-choose-a-printer-using-c-sharp/参考, https://andres.jaimes.net/65/how-to-choose-a-printer-using-c-sharp/

Not quite sure,but print dialog has printer settings related properties where you can define the default printer.不太确定,但打印对话框具有打印机设置相关的属性,您可以在其中定义默认打印机。

Here is somewhat similar question asked in SO, the only difference being it was asked for windows. 是在 SO 中提出的有些类似的问题,唯一的区别是它被要求用于 windows。 Neverthless, PrintDialog works in a similar fashion in web too.尽管如此,PrintDialog 在 Web 中也以类似的方式工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM