How do you add a watermark to a PDF that is stored in a MemoryStream?


Env: .Net

Please provide some sample code on how to add a a water mark to a PDF when the PDF is held in a MemoryStream.




Dear Damian,

Thanks for considering Aspose.Pdf.Kit.

The kit supports the MemoryStream well, you can test with following code,

String imgFile = path + "butterfly.jpg";
FileStream img = new FileStream(imgFile,FileMode.Open);
FileStream outStream = new FileStream(path + "out.pdf",FileMode.Create);
PdfFileStamp stamper = new PdfFileStamp(inStream,outStream);//initializes with MemoryStream
stamper.AddWatermark(img,100,100);//specifies correct position