1. Home
  2. Foxit Quick PDF Library
  3. Programmatically add a watermark or stamp to a PDF

Programmatically add a watermark or stamp to a PDF

Adding an image as a watermark or a stamp on a PDF requires only a few lines of code using Foxit Quick PDF Library. Here’s some C# sample code:

/* Add an image watermark or stamp to an existing PDF document */
 
// Load a sample file from disk. We'll place the image
// onto this file.
 
DPL.LoadFromFile("filename.pdf", "");
 
// Select page 1 to watermark
 
DPL.SelectPage(1);
 
// Load your image into memory
 
DPL.AddImageFromFile("myImage.png", 0);
 
// Get width and height of the image
 
int lWidth = DPL.ImageWidth();
int lHeight = DPL.ImageHeight(); 
 
// Draw the image onto the page using the specified width/height
 
DPL.DrawImage(250, 450, lWidth, lHeight);  
 
// Save the updated file to the output folder
 
DPL.SaveToFile("filename_watermarked.pdf");
Updated on April 9, 2017

Was this article helpful?

Related Articles

Ready to try Foxit PDF SDK?
Click the link below to download your trial
Free Trial