Add Water mark image to PDF using iTextsharp, C# and VB.Net in ASP.Net

Last Reply on Sep 21, 2017 06:26 AM By AnandM

Posted on Sep 21, 2017 04:56 AM

Hi All , 

 

I Have Create one Merge Pdf File, within that file i would like to add stamp to all pages, i have tried lots, but nver got the solution, 

 

please help me.

 

Please check the Below Code for your reference.

 

Regards, 

Sandip Patil

 private void PdfStamp(string FileLocation, string sourceFilePath)
        {
            string watermarkImagePath = @"D:/Projects/MaterialDetails/MaterialDetails/img/Stamp.png";

            var pdfReader = new PdfReader(sourceFilePath);
            var pdfStamper = new PdfStamper(pdfReader, new FileStream(FileLocation, FileMode.Create));
            var image = iTextSharp.text.Image.GetInstance(watermarkImagePath);
            image.SetAbsolutePosition(200, 400);

            for (var i = 0; i < pdfReader.NumberOfPages; i++)
            {
                var content = pdfStamper.GetUnderContent(i + 1);
                content.AddImage(image);
            }

            pdfStamper.Close();
        }

 

This question does not have replies that have been liked.