Add PDF Watermark using C# - Watermark is not same on each page

Dear Team,

Watermark on each pdf page is not same. Expected watermark is only applying on first page and from second page onward it looks like taking default behavior. Please find the attached pdf files for your reference.

Code used:
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(inputPath);
Aspose.Pdf.WatermarkArtifact artifact = new Aspose.Pdf.WatermarkArtifact();
artifact.SetTextAndState(
“WATERMARK”,
new Aspose.Pdf.Text.TextState()
{
FontSize = 72,
ForegroundColor = Aspose.Pdf.Color.Blue,
Font = FontRepository.FindFont(“Courier”)
});
artifact.ArtifactHorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
artifact.ArtifactVerticalAlignment = Aspose.Pdf.VerticalAlignment.Center;
artifact.Rotation = 45;
artifact.Opacity = 0.5;
artifact.IsBackground = true;
foreach (Aspose.Pdf.Page pdfPage in pdfDocument.Pages)
{
pdfPage.Artifacts.Add(artifact);
pageCount++;
}

pdfDocument.Save(outputPDF);

Thanks,
SaurabhAspose.pdf (266.9 KB)
Aspose_AfterWatermark.pdf (273.4 KB)

@sranjan50

We were able to reproduce the issue in our environment while using 22.1 version of the API and have logged it as PDFNET-51220 in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

As an alternative, you can please use TextStamp to add watermark mark in PDF:

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(dataDir + "Aspose.pdf");

TextStamp stamp = new TextStamp("WATERMARK");
stamp.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
stamp.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Center;
stamp.RotateAngle = 45;
stamp.Opacity = 0.5;
stamp.Background = true;
stamp.TextState.FontSize = 72;
stamp.TextState.ForegroundColor = Color.Blue;
stamp.TextState.Font = FontRepository.FindFont("Courier");

foreach (Aspose.Pdf.Page pdfPage in pdfDocument.Pages)
{
 pdfPage.AddStamp(stamp);
}

pdfDocument.Save(dataDir + "Aspose_watermark.pdf");

Aspose_watermark.pdf (268.9 KB)

The issues you have found earlier (filed as PDFNET-51220) have been fixed in Aspose.PDF for .NET 24.3.