Watermark not showing properly

Hi,

I am trying to insert a watermark in a document having text and images embeded. Pages which contains only text the watermark is displayed properly but in the page which has image in it the watermark is displayed behined the image. Can you please look into this.

  string pdfFile = @"C:\\Fig4.pdf";
  
  using (Document pdfDocument = new Document(pdfFile))
  {
    foreach (Page pdfPage in pdfDocument.Pages)
    {
      using (WatermarkArtifact artifact = new WatermarkArtifact())
      {
        artifact.SetTextAndState(
            "ACCELERATED ARTICLE PREVIEW",
            new TextState()
            {
              FontSize = 48,
              ForegroundColor = Color.LightGray,
              Font = FontRepository.OpenFont("Arial")
            });
        artifact.ArtifactHorizontalAlignment = HorizontalAlignment.Center;
        artifact.ArtifactVerticalAlignment = VerticalAlignment.Bottom;
        artifact.Rotation = 47;
        artifact.Opacity = 1;
        artifact.LeftMargin = 300;
        artifact.BottomMargin = 50;
        artifact.IsBackground = true;
        pdfPage.Artifacts.Add(artifact);
        pdfPage.Dispose();
      }
    }
    pdfDocument.Save(pdfFile, SaveFormat.Pdf);
  }

Version - Aspose.PDF.Drawing (23.10.1)

Fig4.zip (1.1 MB)

@amolm

You should remove this line

Hi @sergei.shibanov

Thanks for your reply,
I have removed IsBackground = true, But that was not an expected output. Watermark is displayed over images. Watermark should be behind of images. I have attached expected output watermark please check.

Thanks,

Fig4_After_IsBackground_Remove.zip (1.2 MB)

@amolm
I can’t understand what you want to get.
If we compare the documents from the archive attached in the last message, then in both documents (both the result and the desired one) there is a watermark on top of the image.
BothDocuments.jpg (240.7 KB)
Although the text of message says about a watermark behind the images.
If you need such an effect (so that the images hide the watermark), then this is done by the code fragment you originally provided. (And such a document was attached by you).

Hi @sergei.shibanov
The result and the desired one having difference, Please check attachment
BothDocuments.jpg (228.9 KB)

In the result pdf after adding watermark, The text on the image is not visible due to watermark. But in the desired one you can see text (as mark in screenshot).

@amolm
Thanks for the clarification, now I understand your question.
The document you have attached contains text only at the bottom of the document.
WatermarkDocStructure.png (178.5 KB)

The rest of the image is there and the text you point to is part of the image. Those. in fact, this is not text, but part of an image, and this part of the image also overlaps.

Hi @sergei.shibanov

Due to watermark the text that was pointed by me (red box) is not visible, the watermark is overlap. Is there any way to show that text?

Thanks,

@amolm
Since you want the watermark to be on top of the image, and the text is part of the image, I only see the option of adding separate text on top of the image and watermark. However, it will not be possible to make it completely repeat the text in the picture.