Crystal Reports 打印纵向而不是横向

Crystal Reports prints portrait orientation instead of landscape(Crystal Reports 打印纵向而不是横向)
本文介绍了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 打印纵向而不是横向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)