首页 文章

Crystal Report .NET字体更改

提问于
浏览
1

我设计了一个水晶报告,通过网络界面发送到特定的(条形码)打印机 . 允许在标准水晶报表查看器中生成报表会导致问题,因此我现在使用代码隐藏将报表直接发送到打印机 .

ReportDocument Report = new ReportDocument();                      
ParameterDiscreteValue Order = new ParameterDiscreteValue();

Order.Value = Convert.ToInt32(txtOrder);
Report.Load(reportPath);
Report.SetParameterValue("OrderNo", Order);

PageMargins margins;
margins = Report.PrintOptions.PageMargins;
margins.bottomMargin = 0;
margins.leftMargin = 0;
margins.rightMargin = 0;
margins.topMargin = 0;

Report.PrintOptions.ApplyPageMargins(margins);
Report.PrintOptions.PrinterName = "\\\\printserver\\Zebra  Z6M Plus (300dpi)";                
Report.PrintToPrinter(1, false, PageNum, PageNum);

Report.Close();

当从设计师(CRXI)打印时,一切正常,但是当Web界面将作业发送到打印机(任何打印机)时,它将字体更改为Times New Roman,这会混乱所有字段大小 . 如果我使用标准的.NET报表查看器,它使用正确的字体,所以我很确定更改是由创建/使用ReportDocument引起的 .

如何将报告直接发送到打印件而不将字体默认为Times New Roman?

3 回答

  • 0

    这个想法发生在我身上:
    如果您使用某种中间人,即首先将.rpt导出到.pdf,然后打印PDF,那么如何将报告直接从Crystal发送到打印机呢?

    (是的,这将是一个非常“木桌”表的方法,但如果它的工作,它的工作原理 . )

  • 0

    虽然看起来我使用的特殊字体已被包含在每个可以想象的服务器上,但我从未能通过Web界面使用它 . 我最终找到了一个标准的Windows字体,它最适合这个项目的需要,并放弃了试图击败这个问题 .

  • 0

    您需要使用RAS SDK API . Crystal Reports for Visual Studio 2010 (v13)包括这个api . (此代码请't work in Crystal Reports for Visual Studio 2005... I don't有关于其他版本的信息)

    将此引用添加到现有代码中:

    CrystalDecisions.ReportAppServer.ClientDoc
    CrystalDecisions.ReportAppServer.Controllers
    CrystalDecisions.ReportAppServer.ReportDefModel
    

    并使用此代码(VB ...对不起)

    Using rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
        rpt.Load(file, CrystalDecisions.[Shared].OpenReportMethod.OpenReportByTempCopy)
        rpt.SetDataSource(_ReportSource)
        Dim options As New CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions
        options.Collated = _Collate
        options.NumberOfCopies = _Copies
        ' TODO: Implement_startPageN and _endPageN
        Dim optPrint As CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions
        optPrint = rpt.ReportClientDocument.PrintOutputController.GetPrintOptions
        optPrint.PrinterName = _PrinterName                                                    rpt.ReportClientDocument.PrintOutputController.ModifyPrintOptions(optPrint)
        rpt.ReportClientDocument.PrintOutputController.PrintReport(options)
        rpt.Close()
    End Using
    

相关问题