可視化報告生成器FastReport VCL功能指南:從Delphi / C ++ Builder / Lazarus保存SVG圖像
報表生成器FastReport VCL是用于在軟件中集成商務智能的現代解決方案。它提供了可視化模板設計器,可以訪問最受歡迎的數據源,報告引擎,預覽,將過濾器導出為30多種格式,并可以部署到云,Web,電子郵件和打印中。
近日,FastReport VCL更新至v6.7,在新版本中,添加了對最新版本IDE的支持,簡化了用于付款標準的條形碼的創建,新增從預覽窗口直接編輯RichView的功能,同時修復了多個Bug問題。歡迎下載體驗。(點擊下方按鈕下載)
SVG文件是基于XML格式的文檔的二維矢量圖像。SVG格式不僅用于描述二維矢量圖形,而且還用于混合矢量光柵圖像。span>
讓我們看看SVG格式有哪些優點:
SVG
- 正如前面在上一篇文章中提到的,矢量圖形縮放后不會失去質量(放大后,圖像不會變成立體主義藝術)。
- SVG與web技術完全兼容,因此將成為任何web站點的有機組成部分。
- 將Javascript添加到對象中,我們可以使圖像具有交互性,也就是說,用給定的答案來響應特定的用戶操作——與圖像及其形式相關。
- SVG文件被認為是文本,所以可以通過直接向圖像代碼添加關鍵字來優化文件,而不需要外部meta標記。
讓我們看看SVG格式有哪些缺陷:
- 文件大小將迅速增加,就像雪崩時增加圖像的細節。但是,對于包含大量細節的圖像,最好使用PNG或JPG格式。因此,遺憾的是,SVG完全不適合用于真實的高分辨率照片和該地區的詳細地圖。
- 較老的瀏覽器(Internet Explorer 8或更老的瀏覽器)不支持SVG。
- 由于安全問題,默認情況下(例如WordPress)不允許你上傳SVG文件。WordPress認為這個擴展是惡意的,因此阻止了它。
- SVG適合于創建簡單的對象,這些對象可以通過簡單的圖形或其部件進行描述。
- 社交網絡,比如Facebook和Twitter,不支持SVG格式。如果使用SVG文件作為縮略圖,將不得不使用插件和設置PNG或JPG的元標簽。
如何使用Delphi或Lazarus保存SVG文件?
創建報告。在我們創建了所需的東西之后,啟動它并查看。調用預覽并選擇我們需要的格式。

現在,我們看到一個具有許多不同設置的窗口。設置我們需要的一切,然后單擊“確定”!

使用Delphi / C ++ Builder / Lazarus代碼保存SVG文件
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} frxSVGExport1.PageNumbers := '2-3'; {Set whether to export styles of the objects} frxSVGExport1.EmbeddedCSS := True; {Set whether to convert all images in accordance with PictureFormat:} {if the image in the report is in BMP format and the PictureFormat is PNG, then BMP will be saved in PNG format} frxSVGExport1.UnifiedPictures := True; {Set whether to format the source text of SVG (increases the size of the resulting file)} frxSVGExport1.Formatted := False; {Set whether to export pictures} frxSVGExport1.EmbeddedPictures := True; {Set whether to export each page to a separate SVG file} frxSVGExport1.Multipage := False; {Set whether to add navigation buttons to the resulting SVG file} frxSVGExport1.Navigation := False; {Set in which format to export pictures} //uses frxExportHelpers; // TfrxPictureFormat = (pfPNG, {$IFNDEF FPC}pfEMF,{$ENDIF} pfBMP, pfJPG);) frxSVGExport1.PictureFormat := pfPNG; {Set whether to open the resulting file after export} frxSVGExport1.OpenAfterExport := False; {Set whether to display export progress (show which page is currently being exported)} frxSVGExport1.ShowProgress := False; {Set whether to display the export filter dialog box} frxSVGExport1.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} frxSVGExport1.FileName := 'C:\Output\test.svg'; {Export the report} frxReport1.Export(frxSVGExport1); end;
讓我們比較一下導出柵格和矢量對象的結果!將在下面提供JPEG和SVG示例。
JPEG格式

SVG格式

還想要更多嗎?您可以點擊閱讀【FastReport 報表2020最新資源盤點】,查找需要的教程資源。如果您有任何疑問或需求,請隨時加入FastReport技術交流群(783996712),我們很高興為您提供查詢和咨詢。