【问题标题】:Crystal Report .NET font changingCrystal Report .NET 字体更改
【发布时间】:2010-07-14 21:22:29
【问题描述】:

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

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?

【问题讨论】:

  • 您的打印机驱动程序是最新的吗?
  • 是的,我确保驱动程序是最新的,并且可以从 Crystal 设计器中正常工作,而不是通过背后的 .NET 代码。

标签: crystal-reports fonts zebra-printers reportdocument


【解决方案1】:

我突然想到了这个想法:
与其直接将报告从 Crystal 发送到打印机,不如使用某种中间人,即先将 .rpt 导出为 .pdf,然后再打印 PDF,该怎么办?

(是的,这将是一种非常“木桌”的桌子方法,但如果它有效,它就有效。)

【讨论】:

  • 我在将它发送到 PDF 时遇到了同样的问题,就像我允许在 .NET 报告查看器中生成它时一样(我相信它会处理成 PDF 来显示)。它确实保留了正确的字体,但我添加到报告中的条形码没有得到正确处理。一个条码显示不正确,另外两个根本不显示。
【解决方案2】:

虽然我使用的特殊字体似乎已包含在每个可以想象的服务器上,但我始终无法通过 Web 界面让它工作。 我最终找到了一种最适合这个项目需求的标准 windows 字体,并放弃了试图解决这个问题。

【讨论】:

    【解决方案3】:

    您需要使用 RAS SDK API。 Crystal Reports for Visual Studio 2010 (v13) 包含此 API。 (此代码在 Crystal Reports for Visual Studio 2005 中不起作用...我没有其他版本的信息)

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

    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
    

    【讨论】:

      【解决方案4】:

      我试图根据报表上显示的数据更改 Crystal Report 字体。
      我使用 Formate 公式使用标志条件更改字体。

      if({?vIsRightToLeft}=true)then
      "Attari Font"
      Else
      "Arial"
      

      【讨论】:

      • 我正在回答这个问题
      猜你喜欢
      • 1970-01-01
      • 2016-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-14
      相关资源
      最近更新 更多