We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Place image behind or topfron of text using Aspose.PDF for .NET

Hi, Support:
Does the pdf.dll support place image behind or topfront of text?
If so ,how to get it?


You can add image stamp inside PDF by specifying whether you want to add it behind content (this way it will not be visible as it will be added under the main layer of the page) or above it. Please check following code snippet:

Document document = new Document();
var imageStream = new FileStream(dataDir + "testimage.png", FileMode.Open);

for (int pageNumber = 1; pageNumber <= document.Pages.Count; pageNumber++)
 //debug width height:
 var page = document.Pages[pageNumber];
 var b = new Bitmap(imageStream);
 var brandingImage = new ImageStamp(imageStream);
 // this will add the stamp in background
 brandingImage.Background = true;
 brandingImage.XIndent = 10;
 brandingImage.YIndent = 10;
 // you can specify the opacity to show the effect that image is behind the text with Background = false
 brandingImage.Opacity = 0.5;
 brandingImage.Height = b.Height;
 brandingImage.Width = b.Width;

 // Add stamp to particular page

document.Save(dataDir + "imagestamped.pdf");