Crystal Reports打印纵向而不是横向 [英] Crystal Reports prints portrait orientation instead of landscape

查看:166
本文介绍了Crystal Reports打印纵向而不是横向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SAP Crystal Reports 14.1.4.1327中创建了一个非常简单的测试报告(.rpt文件)。我在页面设置中将页面方向设置为横向。如果我从Crystal Reports Designer中打印文档,则可以横向正确打印。
我需要从C#应用程序中打印报告。我将SAP Crystal Reposrts运行时引擎用于.Net 13.0.6.1027

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.

=== EDIT ==

我也在另一台打印机(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.

=== EDIT ===

我注意到,如果正确设置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打印纵向而不是横向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆