How to add drop a shadow effect to an image in .NET using GcPDF


The ability to show blurred drop shadows is a bitmap effect, This is why GcPDF does not expose as a direct method/approach for implementing the shadow effect to image while generating a PDF.

Therefore, this article shows how to add blurred/drop shadow effects with image using GcPDF.


GcPDF allows specifying opacity while rendering image through the DrawImage method. This feature can be used to show shadow effects with image.

To add the shadow effect to the image, in addition to the original image, render another instance of same image with location offset and specify the opacity of this image to get a shadow effect.

Here is a code snippet showing this:

// Render image
var image = GrapeCity.Documents.Drawing.Image.FromFile(Path.Combine("Resources", "Images", "C1.png"));
var imageRc = new RectangleF(150.6F, 160.7F, 40.8F, 100.9F);
g.DrawImage(image, imageRc, null, ImageAlign.CenterImage);
imageRc.Offset(6, 6);
g.DrawImage(image, imageRc, null, ImageAlign.CenterImage, 0.2f);

Here is the image showing the shadow effect has been applied:


Ruchir Agarwal