首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PrintDialog选定的纸张来源

PrintDialog选定的纸张来源
EN

Stack Overflow用户
提问于 2012-11-20 05:07:42
回答 1查看 3.2K关注 0票数 1

在从PrintDialog类中选择打印选项后,我尝试将多个文档直接发送到打印机。

我需要检索所选的papersource。不幸的是,我只能找到打印机中的所有纸张来源,而不是选定的纸张来源。

下面是我的代码示例(简化版):

代码语言:javascript
复制
CrystalDecisions.CrystalReports.Engine.ReportDocument document;

//...

PrintDialog pDialog = new PrintDialog();
pDialog.ShowDialog();

document.PrintOptions.PrinterName = pDialog.PrinterSettings.PrinterName;   //OK

//Here I need to set the papersource
//document.PrintOptions.PaperSource = ???

document.printToPrinter(pDialog.PrinterSettings.Copies, false, 0, 0)

我是不是在用good对象来做这件事?

注意:由于我使用的是Windows7,PageSetupDialog没有提供打印机选项。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-20 22:31:01

我在Hans Passant的评论中找到了我问题的答案。多亏了他。

为了从PrintDialog中获取PaperSource,我必须给它设置一个假的PrintDocument

PrintDialog不会直接保留纸张来源。相反,它设置PrintDialog.Document.DefaultPageSettings.PaperSource

下面是它看起来的样子:

代码语言:javascript
复制
CrystalDecisions.CrystalReports.Engine.ReportDocument document;

PrintDialog pDialog = new PrintDialog();
pDialog.Document = new System.Drawing.Printing.PrintDocument();
pDialog.ShowDialog();

document.PrintOptions.PrinterName = pDialog.PrinterSettings.PrinterName;
document.PrintOptions.CustomPaperSource = pDialog.Document.DefaultPageSettings.PaperSource;

document.printToPrinter(pDialog.PrinterSettings.Copies, false, 0, 0);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13462255

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档