Crystal Report .NET 字体更改
我设计了一个水晶报告,它将通过网络界面发送到特定的(条形码)打印机。允许在标准水晶报表查看器中生成报表会导致问题,因此我现在使用隐藏代码将报表直接发送到打印机。
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?
I've designed a crystal report that will be sent to a specific (barcode) printer through a web interface. Allowing the report to be generated in the standard crystal report viewer was causing issues, so I am now using the code-behind to send the report directly to the printer.
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();
When printed from the designer (CRXI) everything works fine but when the web interface sends the job to a printer (any printer) it changes the font to Times New Roman which messes up all of the field sizes. If I use the standard .NET report viewer it uses the correct font, so I'm pretty sure the change is being caused by creating/using the ReportDocument.
How can I send the report directly to a print without it defaulting the fonts back to Times New Roman?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我想到了这个想法:
如果您不直接将报告从 Crystal 发送到打印机,而是使用某种中间人,即先将 .rpt 导出为 .pdf,然后打印 PDF,会怎么样?
(是的,这将是一种非常“木桌”的方法,但如果它有效,它就有效。)
This idea occured to me:
Instead of sending the report straight from Crystal to the printer, what if you use some kind of middleman, i.e. export the .rpt to .pdf first, then print the PDF?
(Yes, it would be a very "wooden tables" tables approach, but if it works, it works.)
虽然我使用的特殊字体似乎已经包含在每台可以想象到的服务器上,但我始终无法让它通过网络界面运行。
我最终找到了一种最适合该项目需求的标准 Windows 字体,并放弃了尝试解决这个问题。
While it seemed like the special font I was using had been included on every server imaginable, I was never able to get it to work through the web interface.
I ended up finding a standard windows font that mostly suited the needs of this project and have given up on trying to beat this problem.
您需要使用 RAS SDK API。 Visual Studio 2010 (v13) 的 Crystal Reports 包含此 api。 (此代码在 Visual Studio 2005 的 Crystal Reports 中不起作用...我没有有关其他版本的信息)
将此引用添加到您现有的代码中:
并使用此代码(VB...抱歉)
You need use RAS SDK API. Crystal Reports for Visual Studio 2010 (v13) include this api. (This code don't work in Crystal Reports for Visual Studio 2005... I don't have info about other versions)
Add this references to your existing code:
And use this code (VB... sorry)
我试图根据报告上显示的数据更改 Crystal Report 字体。
我使用 Formate Formula 使用标志 Condition 来更改字体。
I was trying to change Crystal Report Font according to data that will be shown on the report.
I use Formate Formula to change the font using flags Condition.