找回密码
 立即注册

QQ登录

只需一步,快速开始

enson100

论坛元老

4

主题

28

帖子

1万

积分

论坛元老

积分
16026

活字格认证

最新发帖
enson100
论坛元老   /  发表于:2012-10-10 12:33  /   查看:7410  /  回复:6
生成PDF报表的时候会报出异常,信息如下:
GrapeCity.ActiveReports.ReportException: Printer does not support Letter papersize. Please use PaperKind.Custom in your PageSettings or specify a papersize supported by the current printer。


报表模板调用代码如下:
DailyOrMonthlyReport dailyReport = new DailyOrMonthlyReport();
dailyReport.DataSource = ds;
dailyReport.DataMember = "AccountInfo";
dailyReport.Run();

GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport pdfExport = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();


请给出解决方案,谢谢。

6 个回复

倒序浏览
enson100
论坛元老   /  发表于:2012-10-10 12:37:00
沙发
系统环境为Windows server R2 英文企业版。
默认打印机为系统自带打印机:Microsoft XPS Document Writer

两台服务器配置一样,同样的程序运行,其中一台可以正常生成PDF报表,但另一台就报出上述错误。

AR控件为V7.0 专业版。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-10-10 17:39:00
板凳
回复 2楼enson100的帖子

你好,根据当前信息无法确认问题所在。
需要设置 PrinterName 为空(为空时选择虚拟打印机)请尝试以下代码:

  1.         private void Form1_Load(object sender, EventArgs e)
  2.         {
  3.             DataSet ds = new DataSet();
  4.             DataTable dt = new DataTable("AccountInfo");
  5.             DataColumn col1 = new DataColumn("username");
  6.             dt.Columns.Add(col1);
  7.             dt.Rows.Add("iceman");
  8.             dt.Rows.Add("luca");

  9.             ds.Tables.Add(dt);
  10.             DailyOrMonthlyReport dailyReport = new DailyOrMonthlyReport();
  11.             dailyReport.DataSource = ds;
  12.             dailyReport.DataMember = "AccountInfo";
  13.             dailyReport.Run();

  14.             this.viewer1.Document.Printer.PrinterName = "";
  15.             this.viewer1.Document = dailyReport.Document;
  16.         }

  17.         private void printPDFToolStripMenuItem_Click(object sender, EventArgs e)
  18.         {

  19.             GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport pdfExport = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
  20.             pdfExport.Export(this.viewer1.Document, @"E:\111.pdf");
  21.         }
复制代码
回复 使用道具 举报
enson100
论坛元老   /  发表于:2012-10-11 09:33:00
地板
回复 3楼iceman的帖子

我这边不需要预览,直接生成pdf,这样的话如何设置打印机名称为空?
就是说我这边没有this.viewer1 这个东西,是不是可以将
this.viewer1.Document.Printer.PrinterName = "";
替换成 dailyReport.Document.Printer.PrinterName = "";


我按照如上所述的修改了代码,但是还是报相同的错误。我认为跟打印机名称设置为空没有关系。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-10-11 10:52:00
5#
回复 4楼enson100的帖子

enson100 你好,
你的设置方式是正确的。
能否请你提供 Demo 用于调查?
回复 使用道具 举报
enson100
论坛元老   /  发表于:2012-10-11 13:32:00
6#
回复 5楼iceman的帖子

我觉得很有可能跟系统权限有关系,我们还在测试中。
如果有问题我再向你们询问吧。谢谢
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-10-11 14:19:00
7#
回复 6楼enson100的帖子

好的,感谢你的反馈
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部