We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose PDF WatermarkArtifact is not consistent for multiple pages

I Am using Aspose PDF for dotnet and I use WatermarkArtifact class to apply watermark by following this link https://docs.aspose.com/pdf/net/add-watermarks/#programming-samples-how-to-add-watermark-on-pdf-files.

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)

@mjjagan

Could you please attach your input PDF here for testing? We will investigate the issue and provide you more information on it.

Input PDF
Employee Detail.pdf (26.4 KB)

Output (generated) PDF
3726adbe-160c-4caf-bae3-bf19e2a04c50.pdf (51.5 KB)

@mjjagan

We have logged this problem in our issue tracking system as PDFNET-51812. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.