Q: Is it possible to make my image annotations blend with the
background display? We have an image of a signature we'd like to
overlay but would like the background to show through.
A: You can apply transparency effect to an existing image (or text or
vector art) is several different ways. For example, to set the
constant opacity for the entire image use
element.GetGState.SetFillOpacity(). For example:
// In C# (VB.NET, Java, C++ is essentially the same).
// For relevant sample code please see to AddImage and ElementBuilder
Image image = Image.Create(doc, "my.jpg");
Element element = f.CreateImage(image, new
Matrix2D(image.GetImageWidth(), 0, 0, image.GetImageHeight(), 10,
element.GetGState().SetFillOpacity(0.5); // opacity is a number is the
To alter the current blend mode use
element.GetGState().SetBlendMode(...) prior to writing the image
element to the page.
It is also possible to apply an image mask (monochrome) or a soft mask
(grayscale) to an existing image using image.SetSoftMask(smask) or
image.SetImageMask(imask) methods. In this case the alpha channel of
the base image will correspond to the values from the mask image.
Another way to apply transparency effect to images or to any content
on the page is by setting the SoftMask property in the extended
graphics state (element.GetGState().SetSoftMask(msk)). This is the
most powerful way to control transparency in PDF, but is also the most