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:
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();
report.Load("@/../../Transparency.frx");
PDFExport export = new PDFExport();
export.TransparentImages = false;
report.Prepare();
report.Export(export, "result.pdf");
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.
Export Image
The original image in png format does not have a background:
Now add the Picture object to the band and load this picture into it.
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.
RichText Export
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:
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: