首页 文章

如何通过代码设置Crystal报表的确切长度?

提问于
浏览
2

我有一个设计在Crystal Rerports 12x8.5英寸的报告 . 我将OKI 3320打印机驱动程序设置为此大小 . 现在,当我使用我的C#代码打印报告时, the page length is half inch short of the tear off position. I have to roll up paper to tear it off. 是否有任何设置我们可以通过代码更改以准确到达撕下位置?

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);

1 回答

  • 1

    在您使用自定义页面大小时,您需要专门指定页面设置 . 根据这个link,你可以通过设置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是我的System.Drawing.PageSettings,它指定了正确的PaperSize

相关问题