Crystal Reports prints portrait orientation instead of landscape(Crystal Reports 打印纵向而不是横向)
问题描述
我在 SAP Crystal Reports 14.1.4.1327 中创建了一个非常简单的测试报告(.rpt 文件).我在页面设置中将页面方向设置为横向.如果我从 Crystal Reports Designer 打印我的文档,它会以横向正确打印.我需要从 C# 应用程序打印报告.我为 .Net 13.0.6.1027 使用 SAP Crystal Reposrts 运行时引擎
I created a very simple test report (.rpt file) in SAP Crystal Reports 14.1.4.1327. I set page orientation to landscape in Page Setup. If I print my document from Crystal Reports Designer it is printed properly in landscape. I require to print report from C# application. I uses SAP Crystal Reposrts runtime engine for .Net 13.0.6.1027
ReportDocument rp = new ReportDocument();
rp.Load(path_to_my_report_file);
rp.PrintOptions.PrinterName = printerName;
rp.PrintOptions.PaperOrientation = PaperOrientation.Landscape;
rp.PrintToPrinter(0, false, 0, 2);
它始终以纵向打印.我不知道为什么它不起作用.
It prints always in portrait orientation. I don't know why it does not work.
我也尝试了 PrintToPrinter(PrinterSettings printerSettings, PageSettings pageSettings, bool reformatReportPageSettings)
方法并设置了
I also tried PrintToPrinter(PrinterSettings printerSettings, PageSettings pageSettings, bool reformatReportPageSettings)
method and I set
...
System.Drawing.Printing.PrinterSettings printersettings = new System.Drawing.Printing.PrinterSettings();
printersettings.DefaultPageSettings.Landscape = true
...
rp.PrintToPrinter(printersettings, pageSettings, false);
但它也不起作用.
如何横向打印报告?我无法修改打印机驱动程序配置,因此解决方案必须基于 C# 或 .rpt 文件.
How to print report in landscape? I can't modify printer driver configuration so solution must be based on C# or .rpt file.
===编辑===
我还在另一台打印机 (RICOCH) 上测试了我的机箱,它可以横向打印.我使用 ZEBRA ZTC S4M-200dpi ZPL,它打印的是纵向而不是横向.所以可能 Zebra 驱动程序与 .Net 不完全兼容.
I tested my case also on another printer (RICOCH) and it prints properly in landscape. I uses ZEBRA ZTC S4M-200dpi ZPL and it prints portait instead of landscape. So maybe Zebra driver is not full compatible with .Net.
===编辑===
我注意到如果 PaperSize 设置正确,Zebra 会正确打印报告.所以以下代码有效:
I noticed that Zebra prints report properly if PaperSize is set properly. So following code works:
...
System.Drawing.Printing.PrinterSettings printersettings = new System.Drawing.Printing.PrinterSettings();
printersettings.DefaultPageSettings.Landscape = true
System.Drawing.Printing.PageSettings pageSettings = new System.Drawing.Printing.PageSettings();
...
pageSettings.PaperSize = new System.Drawing.Printing.PaperSize("name", 400, 600);
rp.PrintToPrinter(printersettings, pageSettings, false);
其中 400 是宽度,600 是纵向高度,以百分之一英寸为单位.因此 C# 应用程序需要从报表中检索页面宽度、页面高度和页面方向.我不知道如何检索这些参数.我问一下这里
Where 400 is width, 600 is high in portrait orientation in hundredths of an inch. So C# application needs to retrieve page width, page high and page orientation from report. I don't know how to retrieve these parameters. I ask about it here
推荐答案
这对我有用:
cryRpt.PrintOptions.PaperSource = PaperSource.Auto;
cryRpt.PrintOptions.PaperSize = PaperSize.DefaultPaperSize;
cryRpt.PrintOptions.PaperOrientation = PaperOrientation.Landscape;
这篇关于Crystal Reports 打印纵向而不是横向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Crystal Reports 打印纵向而不是横向
基础教程推荐
- MS Visual Studio .NET 的替代品 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 将 XML 转换为通用列表 2022-01-01