C# 如何通过代码设置水晶报表的精确长度?

C# 如何通过代码设置水晶报表的精确长度?,c#,printing,crystal-reports,C#,Printing,Crystal Reports,我有一份用Crystal ReReports 12x8.5英寸设计的报告。我的OKI 3320打印机驱动程序正好设置为这个大小。 现在,当我使用我的C代码打印报告时,页面长度比撕下位置短半英寸。我必须卷起纸张才能将其撕下。我们是否可以通过代码更改任何设置,以准确到达撕下位置 ReportDocument oReportDocument = new ReportDocument(); oReportDocument.Load(reportPath + "

我有一份用Crystal ReReports 12x8.5英寸设计的报告。我的OKI 3320打印机驱动程序正好设置为这个大小。 现在,当我使用我的C代码打印报告时,页面长度比撕下位置短半英寸。我必须卷起纸张才能将其撕下。我们是否可以通过代码更改任何设置,以准确到达撕下位置

          ReportDocument oReportDocument = new ReportDocument();
            oReportDocument.Load(reportPath + "\\OutDkt.rpt");

            List<TblOutDocket> lstDockets = new List<TblOutDocket>();
            lstDockets.Add(oTblOutDocket);
            oReportDocument.SetDataSource(lstDockets);

            oReportDocument.PrintOptions.PrinterName = LocalPrintServer.GetDefaultPrintQueue().FullName;
            oReportDocument.PrintToPrinter(1, false, 0, 0);
ReportDocument或ReportDocument=新的ReportDocument();
oReportDocument.Load(reportPath+“\\OutDkt.rpt”);
List LSTOCKTS=新列表();
添加(oTblOutDocket);
oReportDocument.SetDataSource(lstDockets);
oReportDocument.PrintOptions.PrinterName=LocalPrintServer.GetDefaultPrintQueue().FullName;
oReportDocument.PrintTopPrinter(1,false,0,0);

使用自定义页面大小时,似乎需要专门指定页面设置。根据这一点,您可以通过设置PageSettings命名空间来实现这一点

如果要使用id大于118的纸张尺寸(Windows 编码纸张尺寸)您必须将纸张尺寸的id提供给 PrintOptions.PaperSource。很明显,你需要把它投给 CrystalDecisions.Shared.PaperSource我这样做:

ReportDocument.PrintOptions.PaperSource= (CrystalDecisions.Shared.PaperSource)m_PageSettings.PaperSource.RawKind

ReportDocument.PrintOptions.PaperSize= (CrystalDecisions.Shared.PaperSize)m_PageSettings.PaperSize.RawKind

其中m_PageSettings是指定 合适的纸张尺寸