How to optimize the size of a report file in PDF

2017-10-16

In this article we are going to talk about PDF export in FastReport.Net. That is, the size of a file of an exported report. The size of the final file is affected by many factors: image quality, embedded fonts, fonts in "curves", background image, etc.

Let us take a close look at the export settings window:

 

First of all, you can set the PDF standard, and this affects the final size because PDF / A and PDF-X standards necessarily include embedded fonts.

The option "Embedded fonts" allows you to include fonts used in the report into the final document. This slightly increases the size of the final file, but ensures that the text is displayed in the same form as in the report. If the font style is not important, then you can skip this option in order to reduce the size of the file.

Option "Background" includes the background of the report in a PDF document. It also increases the size of your document.

The option "Text in curves" enables a mode for drawing characters using vector primitives (TrueTypeFonts). This ensures that the view and the aspect ratio of the characters are preserved when scaling. However, this option significantly affects the size of a PDF document. Using this option is justified when printing a document in large formats, for example, on plotter.

Now let us consider the options, that are related to graphics.

Color space: RGB or CMYK. There are two types of color formation. The first type is used in television, the second one - in printing. Using the CMYK scheme, it increases the file size. If it is important for you to keep the correct colors when printing, you should use this option.

Option "Original Resolution". This option allows to save images in the original resolution. Based on the principle of "originality", an image in a report cannot be rotated, only scaling is allowed. This option is suitable if you want to transfer original images, using a PDF document. It can be used in printing. Depending on the resolution of the original image, this option can significantly increase the size of the final PDF document.

Option “Print Optimized”. Fast Report uses images from reports, when creating a PDF document. In addition to bitmap, there are some objects that are converted to images during exporting to PDF. This includes barcodes, maps, charts and some other objects. By default, all these objects are rendered in the screen resolution.

This leads to decrease in detail, when your document is zoomed in, and it is also noticeable when printing on paper.

In addition, this can lead to poor legibility of barcodes by scanners.

To avoid this problem, the " Print Optimized" option is used. When you turn it on, the above objects are drawn on the canvas, which is several times larger than a normal screen. Then these images are placed in a PDF document.

This solves the problem of legibility of barcodes and the appearance of diagrams and maps.

Images are formed at a higher resolution, so they have a margin for visualization when scaling.

The disadvantage of this method of rendering images is their large size, which increases the size of your PDF file.

The "Jpeg Compression" option. This option, unlike all the others, is designed to reduce the size of the resulting document due to deterioration in the quality of images. And you can set the percentage of image quality, unlike the original one. This option can be used if the original quality of images in the document is redundant for you. It is no use storing, for example, a high-quality photograph in a document, if it occupies, for instance, a quarter of a page. You can greatly reduce the size of the document due to the images.

I am going to display the results of measuring file sizes with different PDF standards and options. For this, a demo report Simple list from the delivery of FastReport.Net has been used. Each measurement was carried out with one option enabled, no combinations. Let us take a close look at the sizes of PDF files in kilobytes:

Standard

Without options

Embedded fonts

Background

Text in curves

RGB

CMYK

Original resolution

For print

Jpeg compression 95

Background, color and texture

PDF 1.5

424

550

425

1652

424

438

627

4332

112

437

PDF/A

-

558

558

-

558

944

760

4465

245

570

PDF-X

-

551

551

1652

551

952

756

4450

238

564

As it was mentioned above, PDF / A and PDF-X have the default fonts already implemented, so they are not in the first column. If you compare all three standards with embedded fonts, then you will see, that the largest size is a PDF / A.

As you might have noticed, the enabled Background option did not affect the size at all, as the Simple List report does not have a background. Some separate measurements have been made, changing the background in the report and getting excellent numbers (last column).

The next option "Text in curves" is not available for PDF / A, this is due to the standard. For PDF1.5 and PDF-X, the file size is identical and exceeds the number of the previous columns by three times. Here it is worthwhile to think whether this option is necessary to you.

The RGB color space is selected by default, so the size is the same as the size of the first (second) column. And for CMYK, the file size is larger, especially for PDF / A and PDF-X. This is due to the use of the ICC color profiles.

Now the "Original Resolution" option. A PDF document contains original drawings from the report. Among three indicators in this column, the smallest one is PDF 1.5. But this is only because the other two have embedded fonts. So, the values of all the columns are approximately the same.

This applies to the other parameters. The PDF file 1.5 is less than exactly the amount of embedded fonts.

Now look at the "For printing" column. The file size is 8 times larger than the initial file (without options)! We already know that this is due to the high resolution of the images in a document.

It was written above, that the Jpeg compression can significantly reduce the file size. For PDF 1.5 this is 112 kilobytes against the initial 424. Almost 4 times less! And if our report contained only pictures, this indicator would be even greater.

From the table above, it is clear which of the options should be used with caution. For example, the options "For printing" and "Text in curves" are not included without special need. Using embedded fonts does not greatly affect the size of the document, but it is useful for preserving the intended type of a document. In reports that does not require quality graphics, as it is more appropriate to apply the Jpeg compression. And the color scheme CMYK is appropriate to be used if your report is intended to be printed and it contains photographic drawings.

August 12, 2024

How to build and install the Postgres plugin in FastReport .NET

This article describes how to connect to the database using the FastReport .NET plugin for the report designer from Visual Studio via the NuGet server.
August 08, 2024

How to install FastReport .NET and its components on Windows

Step-by-step instructions for online and manual installation via the FastReport registration code.NET and its components in Windows.
July 26, 2024

Updating HTMLObject as a plugin for FastReport .NET

Detailed instructions for using the new HTMLObject plugin, which uses splitting DOM HTML into FastReport report objects.
Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314

© 1998-2024 Fast Reports Inc.