I Am using Aspose PDF for dotnet and I use WatermarkArtifact class to apply watermark by following this link Add watermark to PDF using C#|Aspose.PDF for .NET.
I have applied watermark scopes like rotation, opacity, stroking color. But all these scopes are applied only to the first page. Second page in PDF does not maintain the same rotation or
opacity.
Below is the code
private void InsertWatermarkText(Aspose.Pdf.Document document)
{
WatermarkArtifact artifact = new WatermarkArtifact();
artifact.SetTextAndState(
"Preview Only",
new TextState()
{
FontSize = 72,
ForegroundColor = Color.FromRgb(System.Drawing.Color.Green),
Font = FontRepository.FindFont("Arial"),
StrokingColor = Color.FromRgb(System.Drawing.Color.Green)
});
artifact.IsBackground = false;
artifact.Rotation = 45;
artifact.Opacity = 0.5;
// Place the watermark in the page center.
artifact.ArtifactHorizontalAlignment = HorizontalAlignment.Center;
artifact.ArtifactVerticalAlignment = VerticalAlignment.Center;
////document.Pages[2].Artifacts.Add(artifact);
////document.Pages[1].Artifacts.Add(artifact);
for (int i = 1; i < document.Pages.Count + 1; i++)
{
document.Pages[i].Artifacts.Add(artifact);
}
}
Resultant PDF
Page 1
image.png (34.2 KB)
Page 2
image.png (38.5 KB)