Images with transparency are often called images with an alpha channel. What does this mean? The alpha channel contains information about partial or full transparency of the image. It is mainly used in computer animation. RGB images can have up to 24 alpha channels. Each of them contains information about the transparency of a part of the image. Managing these channels can make parts of the image transparent at the right time. This creates an animation effect.
The most common raster formats of images with support for transparency:
- PSD - the native format of Adobe Photoshop. Supports full and partial transparency;
- TIFF - most often used to store scanned images, because it allows you to store information about the great depth of color. This quality has made the format of tiff popular in printing. Supports partial and full transparency;
- GIF - this format is most popular in the Web graphics, because the file has a very small size. Allows you to store information about full transparency only. That is, you can not make a semi-transparent image;
- PNG is also common in Web graphics, but the file is larger and supports translucency.
In this article, we'll look at how to turn off the support for translucency when exporting the FastReport.Net report to PDF. This can be done from the application code:
Report report = new Report();
PDFExport export = new PDFExport();
export.TransparentImages = false;
As you can see from the code, PDF export has a TransparentImages property that allows you to disable (false) or enable (true) transparency support.
Three report objects are represented as a picture when exporting to PDF: Picture, RichText and Chart. The TransparentImages property works for all of them.
And now I propose to see how these objects will look like with the TransparentImages property turned on and off.
The original image in png format does not have a background:
A colored background is set for the band.
As you can see, the red tint is noticeable on the background of the image, it means the picture has a transparent background.
Let's see how the export of this report to the PDF format will look like with the value of the TransparentImages = ture property:
Just like in the designer.
And now, install TransparentImages = false:
The transparent background of the picture is now painted in white.
Let's see how RichText looks like with a transparent background:
Although the object has a transparent background, but you cannot get rid of the white substrate for the text.
Set the property TransparentImages = false:
The background is painted white. Given that the white substrate text cannot be removed, for RichText the TransparentImages property is not very useful.
Export Chart object
The Chart object has many background settings. To get a transparent background of the object, you need to set the following settings in the object properties:
- BackColor = Transparent;
- BorderSkin(SkinStyle) = None;
- BorderLineColor = Transparent;
- Open the Legends collection, select the legend and set TitleBackColor = Transparent for the title.
- Open the ChartAreas collection, select an entry, and set the value of Transparent to BackColor.
Here's a chart:
When exporting to PDF with the value of the property TransparentImages = true, the chart looks the same as in the picture above.
And if you set TransparentImages = false, you get a white background: