logo
small logo
  • Products
  • Buy
  • Support
  • About
  • Customer panel Support
    • en
    • de
    • JP
    • ZH
  • Home
  • /
  • Articles
  • /
  • How to export reports to PNG from FastReport VCL
  • How to make a PDF from Delphi / C++Builder / Lazarus

    May 14, 2020

    Quite often, you need to get a PDF document from a Pascal application - either

    read more
  • How to create a ZPL file in Delphi/ C++ Builder/Lazarus

    December 22, 2020

    What is a ZPL file? ZPL stands for Zebra Programming Language. It allows team to

    read more
  • How to combine multiple reports into PDF file in Delphi

    September 3, 2020

    It is often necessary to combine several documents into one (for example, PDF). It could

    read more
  • How to create CODE 39 and CODE 39 Extended barcodes

    October 23, 2020

    CODE 39 is the barcode developed by Intermec Corporation in 1975. Up to 43 characters

    read more
  • Creating an Open Documents Spreadsheet from Delphi / C++Builder / Lazarus

    August 3, 2020

    Summary of ODS and ODF ODS is an open format for spreadsheets made in accordance with

    read more

How to export reports to PNG from FastReport VCL

September 21, 2022

PNG

Earlier we reviewed BMP, JPEG, TIFF, and GIF in the article about various graphic image formats. It remains to discuss the last most common format - PNG. Currently, Portable Network Graphics (PNG) is one of the best-known and most commonly used file formats.

Why did it happen that this format is popular in the world? It’s simple. A wide range of colors, gamma correction, saving with or without a background. There are really many convenient options because PNG can save information without losing image quality. It is most often used for viewing, compressing pictures, and editing/creating graphics.

You can open PNG in almost every imaginable program, which is why in 1996 PNG became a great alternative to GIF (Graphics Interchange Format) and, to some extent, it replaced much more complicated TIFF (Tagged Image File Format).

Initially, it was called PBF (Portable Bitmap Format), but after improvements, the W3C consortium reviewed the specification and approved it as the optimal network format.

PNG supports three types of bitmaps:

- grayscale image (color depth 16 bits);
- color indexed image (color depth 24 bits);
- full-color image (color depth 48 bits).

The format has many advantages over the GIF format. I will give a few examples.

1)    It can store graphic information in a compressed form, no matter how many times you save it or leave it in intermediate editing. Your work is guaranteed to remain the same quality.

2)    It allows you to include metadata or save copyright information.

3)    PNG has a very small image size.

4)    It uses the open, non-proprietary Deflate compression algorithm.

Fast Report software products for macOS, Linux, and Windows can convert, create, save, and export images of this resolution. In the report generator for Delphi, you can save a document even in PNG format.

Export the report from the preview

Let's say that you have already created your report and launched the preview. Select the PNG format from the export window. A window will appear with the export settings. For example, you can save all pages, the current page, or specify pages.

Export to PNG format  Export to PNG format

A detailed description of PNG export settings.

Monochrome - images in shades of black;
Crop pages - cropping pages;
JPEG quality - setting the quality of a graphic object (will not be available due to the specifics of the format);
Resolution (dpi) - resolution in dots per inch;
Open after the export - automatic opening of the document immediately after saving.

It is also possible to save the file to the computer's memory, upload it to the cloud, and send it by e-mail or FTP.

How to save to PNG from Delphi/C++Builder/Lazarus code?

procedure TForm1.Button1Click(Sender: TObject);
begin
 {We generate a report. The report must be generated before exporting}
 frxReport1.PrepareReport();
{Set the range of exported pages. All pages of the generated report are exported by default}
 frxGIFExport1.PageNumbers := '2-3';
 {Set whether to export each page to a separate file.}
 {The file name will be appended with .N, where N is the page number}
 frxGIFExport1.SeparateFiles := True;
{Set whether to export to black and white image}
 frxGIFExport1.Monochrome := False;
{Set whether empty edges should be cropped}
 frxGIFExport1.CropImages := False;
{Set resolution, dpi}
 frxGIFExport1.Resolution := 96;
 {Set whether to open the resulting file after export}
 frxGIFExport1.OpenAfterExport := False;
 {Set whether to display export progress (show which page is currently being exported)}
 frxGIFExport1.ShowProgress := False;
{Set whether to display a dialog box with export filter settings}
 frxGIFExport1.ShowDialog := False;
{Set the name of the resulting file.}
{Note that if you don't set the filename and disable the display of the export filter dialog,}
{it will still show the filename selection dialog}
 frxGIFExport1.FileName := 'C:\Output\test.png';
{Export the report}
 frxReport1.Export(frxPNGExport1);
end;

Comparison of PNG sizes with other formats

Example of a report with graphic images

Let's make a small comparison of the weight of the final files when exporting the report. We worked with a small report with various measuring scales.

PNG - 26,7 KB; BMP - 6,80 MB; JPEG - 78,0 KB; TIFF - 2,55 MB; GIF - 20,9 KB.

You may notice that the PNG format is larger than the GIF when exported. This happened because the original resolution was kept, and the GIF lost some quality when saving to PNG.

Thus, the PNG format is best used when working with graphic images, and GIF is used for animations.

The other formats are great for other purposes. For example:

-       BMP is most efficient when saving only raster images;

-       JPEG is used to save photos, email graphics, and large images such as advertising banners;

-       TIFF is used in scanning and OCR. Often, these format files are used in faxing.

Let's sum up. It is very easy and convenient to export any created, opened, or edited object from FastReport VCL to Portable Network Graphics (PNG). This format is perfect for many purposes, whether it is creating drawings of embroidery patterns or drawings for turning parts. Fast Reports products will help you to implement all of this.

about product buy
avatar
Angelina Pushkareva
Design and Marketing
Fast Reports Team: Angelina Pushkareva - Design and Marketing at Fast Reports
VCL Export Lazarus FastReport Delphi

Add comment
logo
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314
  • Buy
  • Download
  • Documentation
  • Testimonials
  • How to uninstall
  • FAQ
  • Tutorial Video
  • Forum
  • Support SLA
  • Articles
  • Our News
  • Press about us
  • Resellers
  • Extended licensing
  • Contact us

© 1998-2023 by Fast Reports Inc.

  • Privacy Policy

Trustpilot