This successfully applies the DRAFT watermark on all pages:
using (var pdfDocument = new Aspose.Pdf.Document(sourceStream))
{
using (var watermarkStream = await watermarkBlobClient.OpenReadAsync())
{
var fileStamp = new PdfFileStamp();
fileStamp.BindPdf(pdfDocument);
// Create stamp
var stamp = new Stamp();
stamp.BindImage(watermarkStream);
stamp.SetOrigin(-180, -50);
stamp.Rotation = 45.0F;
stamp.IsBackground = false;
// Add stamp to PDF file
fileStamp.AddStamp(stamp);
using (var writeStream = await reportDocBlobClient.OpenWriteAsync(true))
{
fileStamp.Save(writeStream);
}
fileStamp.Close();
}
}
This makes the PDF not editable, but removes the watermark stamp:
using (var pdfDocument = new Aspose.Pdf.Document(sourceStream))
{
//Forbid all privileges on the document
var privilege = DocumentPrivilege.ForbidAll;
privilege.AllowPrint = true;
privilege.AllowCopy = true;
var fileSecurity = new PdfFileSecurity();
fileSecurity.BindPdf(pdfDocument);
fileSecurity.SetPrivilege(privilege);
using (var writeStream = await reportDocBlobClient.OpenWriteAsync(true))
{
pdfDocument.Save(writeStream);
}
}