FastReport中国社区FastReport联系电话 联系电话:023-68661681

可视化报告生成器FastReport VCL功能指南:从Delphi / C ++ Builder / Lazarus制作PDF

来源:   发布时间:2020-05-26   浏览:2490次

报表生成器FastReport VCL是用于在您的软件中集成商务智能的现代解决方案。它提供了可视化模板设计器,可以访问最受欢迎的数据源,报告引擎,预览,将过滤器导出为30多种格式,并可以部署到云,Web,电子邮件和打印中。

近日,FastReport VCL升级到v6.6版,在此版本中,所有面板隐藏在“Data Tree”数据树,添加了新的线性条形码类型:Pharmacode,改进了预览窗口中的搜索,感兴趣的朋友可点击下方按钮下载最新版。

点击下载最新版FastReport VCL

通常建议使用专门的解决方案,PDF转换器(例如itext,Synopse PDF Engine,PowerPDF,HotPDF,PDF Creator Pilot,PDFtoolkit VCL,Debenu Quick PDF库等)。

在Delphi中创建一个新的VCL应用程序

将FastReport选项卡中的TfrxReport,TfrxPDFExport和TButton组件添加到窗体。

可视化报告生成器FastReport VCL功能指南:从Delphi / C ++ Builder / Lazarus制作PDF

双击TfrxReport,输入FR设计器。创建一个新报告(文件->新建报告)。将TfrxMemoView和文本“ Test text”添加到MasterData1。

可视化报告生成器FastReport VCL功能指南:从Delphi / C ++ Builder / Lazarus制作PDF

设置MasterData1.RowCount = 200,退出设计器并为Button1编写OnClick处理程序:

procedure TForm1.Button1Click(Sender: TObject);
begin
 {Generate a report. The report must be generated before exporting}
 if frxReport1.PrepareReport then
 frxReport1.ShowPreparedReport; 
 {and show preview window}
end;

实际上,此代码足以进行全面的工作,生成报告并导出为PDF。现在,在设计时创建一个任何复杂的文档(您可以连接任何数据源并从那里获取信息)–表格,列表,插图,地图,QR码–为此,请确保首先将适当的组件添加到项目中(否则它们将在运行时中不存在),带有锚点,内联链接和目录的复合和多页文档-您需要的任何大小的文档-一页收据,一页目录,年度报告工厂员工动静数千页。并且不要忘记将PDF导出组件放到我们的项目中!启动并单击表单上的唯一按钮。

可视化报告生成器FastReport VCL功能指南:从Delphi / C ++ Builder / Lazarus制作PDF

从Delphi应用程序中保存PDF

点击按钮–在下面的预览中调用导出,将展示如何通过代码执行所有操作,只需点击链接即可– 从代码发送到PDF)。随即,我们看到出现的PDF设置对话框。

可视化报告生成器FastReport VCL功能指南:从Delphi / C ++ Builder / Lazarus制作PDF

如您所见,任何专业的PDF转换器都会羡慕这种选择!我们可以选择将文档的哪些页面发送到PDF,使用哪个版本的PDF,压缩可以减少生成的文件的大小,嵌入字体可以保存任何第三方设备的文档外观。我们可以选择是否将背景附加到PDF文档。

我们的PDF也可以针对打印进行优化(图像质量会更好,但是尺寸会更大)或仅针对屏幕显示。我们可以设置生成的PDF是否将包含原始目录中的外部目录(在我的示例中没有,因此无法选择),透明度,位图图像的压缩率。

另一个功能–所有文本(包括RTF)在保存为PDF时都会进行矢量化处理,即在保留从PDF复制一部分文本的能力的同时,质量不会丧失(除非您禁止在下面提到的适当选项)。

可视化报告生成器FastReport VCL功能指南:从Delphi / C ++ Builder / Lazarus制作PDF

保存到:我们将确切发送PDF(本地文件或电子邮件或云)的位置。导出后打开-默认情况下,分配给操作系统的PDF查看器将在导出后立即打开结果文件(例如,Adobe Acrobat Reader)。

我们可以将生成的文档导出为存档格式,例如PDF / A-1a,PDF / A-1b,PDF / A-2a,PDF / A-2b,PDF / A-3a,PDF / A-3b。设计用于以电子形式保持文档不变。例如,在此标准中,文档中存在的字体,图像,第三方对象会自动嵌入到文档中。这些标准之一经常在大型组织中用于电子文档管理。

可视化报告生成器FastReport VCL功能指南:从Delphi / C ++ Builder / Lazarus制作PDF

非存档PDF格式也有多个版本。

可视化报告生成器FastReport VCL功能指南:从Delphi / C ++ Builder / Lazarus制作PDF

服务信息,也将转至PDF文件:标题,作者,主题,关键字(您可以将PDF上传到网络,它将被完美索引),PDF创作工具,文档制作者。

可视化报告生成器FastReport VCL功能指南:从Delphi / C ++ Builder / Lazarus制作PDF

安全性–使用密码(使用RC4加密)保护文档免于打开。禁止打印和修改文档,复制文本和图形,添加或修改文本注释的功能。

可视化报告生成器FastReport VCL功能指南:从Delphi / C ++ Builder / Lazarus制作PDF

打开文档时设置PDF查看器:隐藏工具栏,隐藏菜单栏,隐藏窗口用户界面,适合窗口,中心窗口,打印比例。通常,在导出时,我使用默认设置的参数,但是这次我检查了所有参数。

从Delphi或Lazarus代码发送到PDF

procedure TForm1.Button1Click(Sender: TObject);
begin
{Generate a report. The report must be generated before exporting}
frxReport1.PrepareReport();
{Set the range of pages to export. By default, all pages of the generated report are exported.}
frxPDFExport1.PageNumbers := '2-3';
{Set the PDF standard
 TPDFStandard = (psNone, psPDFA_1a, psPDFA_1b, psPDFA_2a, psPDFA_2b, psPDFA_3a, psPDFA_3b);
It is required to add the frxExportPDFHelpers module to the uses list:
uses frxExportPDFHelpers;}
frxPDFExport1.PDFStandard := psNone;
{You can set the PDF standard version for PDFStandard = psNone
TPDFVersion = (pv14, pv15, pv16, pv17);
It is required to add the frxExportPDFHelpers module to the uses list:
uses frxExportPDFHelpers;}
frxPDFExport1.PDFVersion := pv17;
{To get smaller file size, you can set the compression}
frxPDFExport1.Compressed := True;
{Set whether to embed fonts in the resulting document.
 Embedding fonts significantly increases the size of the resulting document}
frxPDFExport1.EmbeddedFonts := False;
{Set whether we need to export the background image}
frxPDFExport1.Background := True;
{Disable export of objects with optimization for printing. With option enabled images will be high-quality but 9 times larger in volume}
frxPDFExport1.PrintOptimized := False;
{Set whether the resulting PDF will contain an external table of contents, as in the original report}
frxPDFExport1.Outline := False;
{Set whether to export images with transparency}
frxPDFExport1.Transparency := True;
{You can set the desired DPI of images. Enabling this option disables SaveOriginalImages option, which allows you to save images in their 
original form}
 frxPDFExport1.PictureDPI := 150;
 {Set the compression ratio of bitmap images}
 frxPDFExport1.Quality := 95;
 {Set whether to open the resulting file after export}
 frxPDFExport1.OpenAfterExport := False;
 {Set whether to display export progress
  (show which page is currently being exported)}
 frxPDFExport1.ShowProgress := False;
 {Set whether to display a dialog box with export filter settings}
 frxPDFExport1.ShowDialog := False;
{Set the name of the resulting file. Please note that if you do not set the file name and disable the export filter dialog box, the file name selection dialog will still be displayed}
frxPDFExport1.FileName := 'C:\Output\test.pdf';
{Fill in the corresponding fields of the Information tab}
frxPDFExport1.Title := 'Your Title';
frxPDFExport1.Author := 'Your Name';
 frxPDFExport1.Subject := 'Your Subject';
 frxPDFExport1.Keywords := 'Your Keywords';
 frxPDFExport1.Creator := 'Creator Name';
 frxPDFExport1.Producer := 'Producer Name';
 { Fill in the corresponding fields of the Security tab }
 frxPDFExport1.UserPassword := 'User Password';
 frxPDFExport1.OwnerPassword := 'Owner Password';
 frxPDFExport1.ProtectionFlags := [ePrint, eModify, eCopy, eAnnot];
 {Set the Viewer settings (Viewer tab)}
 frxPDFExport1.HideToolbar := False;
 frxPDFExport1.HideMenubar := False;
 frxPDFExport1.HideWindowUI := False;
 frxPDFExport1.FitWindow := False;
 frxPDFExport1.CenterWindow := False;
 frxPDFExport1.PrintScaling := False;
 {Export the report}
 frxReport1.Export(frxPDFExport1);
end;

Fastreport在线购买价更低!赶紧加入购物清单吧!

还想要更多吗?您可以点击阅读【FastReport 报表2019最新资源盘点】,查找需要的教程资源。如果您有任何疑问或需求,请随时加入FastReport技术交流群(783996712),我们很高兴为您提供查询和咨询。

本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:FastReport控件中文网 [https://www.fastreportcn.com/]
本文地址:https://www.fastreportcn.com/post/2794.html

相关产品: FastCube VCL,


联系我们
  • 重庆总部 023-68661681
购买
  • sales@evget.com
合作
  • business@evget.com


在线
客服
微信
QQ 电话
023-68661681
返回
顶部