Watermarking existing pdf not working as expected

Hi there…

I am evaluating Aspose.Pdf 18.6… and trying to add watermark (,png) to existing pdf file using codes below…
but it does not work as expected!

I can’t see the watermark at all!..

====
ImageStamp waterMark = new ImageStamp(@waterMarkFile);
waterMark.BottomMargin = 10;
waterMark.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Right;
waterMark.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
waterMark.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Center;
waterMark.Opacity = 0.5;
waterMark.Background = true;

           using (Document mainPdf = new Document(mainFileName))
            {
                //delete all attachments
                mainPdf.EmbeddedFiles.Delete();

                for (int ipage = 1; ipage <= mainPdf.Pages.Count; ipage++)
                {
                        mainPdf.Pages[ipage].AddStamp(waterMark);
                }

   mainPdf.Save(@mainFileName);

}

is it bug? or did I miss something?

@calistasoft,

Please access the link Adding Image Stamp in PDF File for details on how you can add an image as watermark in a PDF file. This link also contains code snippet. Please use the code snippet along with latest version of the API. In case you face any issue, feel free to contact us along with details of the issue, sample PDF file and sample watermark image. We will look into it and update you about our findings.

Hi…
I use the latest version of Aspose.Pdf and I use the codes, still facing same problem…
If I set background property to true then the watermark would not showing!.. but if I set background property to false then the watermark would show in front the contents…

sampleWatermakImage.png (6.1 KB)
sampePDF.pdf (573.2 KB)

please help …

@calistasoft,

The color of the Watermark image is quite dim and difficult to view in the output PDF with the background property set to true. However, we can view with the background property set to false. Please create PDF document with the false and true background property and share with us. This is the ZIP of our output PDF documents: PdfFiles.zip (1.2 MB)

backGroundFalse.pdf (574.5 KB)
backGroundTrue.pdf (573.4 KB)

sampleTestWatermarkImage2.png (18.2 KB)

I try to use brighter ones … but still no luck :frowning:

@calistasoft,

An investigation has been logged under the ticket ID PDFNET-45041 in our issue tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.

Hi Imran…

do you have any update regarding to this issue?

Thanks

@calistasoft

Thanks for your inquiry.

We have again tested the scenario with Aspose.PDF for .NET 18.6, and noticed that watermark was visible in generated output PDF. We have tested the scenario by adding your both images (i.e. sampleWatermakImage.png, sampleTestWatermarkImage2.png) in PDF as watermark and used following complete code snippet:

ImageStamp waterMark = new ImageStamp(dataDir + "sampleTestWatermarkImage2.png");
waterMark.BottomMargin = 10;
waterMark.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Right;
waterMark.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
waterMark.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Center;
waterMark.Opacity = 0.5;
waterMark.Background = false;

using (Document mainPdf = new Document(dataDir + "sampePDF.pdf"))
{
  //delete all attachments
  mainPdf.EmbeddedFiles.Delete();

  for (int ipage = 1; ipage <= mainPdf.Pages.Count; ipage++)
  {
    mainPdf.Pages[ipage].AddStamp(waterMark);
  }

  mainPdf.Save(dataDir + "sampePDFHighBrightness_out.pdf");
}

sampePDFHighBrightness_out.pdf (589.9 KB)
sampePDFLightBrightness_out.pdf (613.3 KB)

Only difference between two outputs was, we removed opacity settings while adding image with light brightness. However, in both cases the watermark was visible inside PDF pages Watermark.png (79.3 KB). Could you please share some more details, in case these outputs are not as per your actual requirements. We will again review the scenario and update the information of logged tickets.

Hi…
are you sure to use waterMark.Background = false?
for watermark … it should be true right?

@calistasoft

Thanks for your inquiry.

If you set Background property as true, the content/image will be rendered under the main layer of content inside PDF - in which case, it will not be visible. Thus, you need to set Background as false with an appropriate opacity setting. This way, image will be added to PDF document with a transparency effect and give an impression of watermark in background.

asposepdf.PNG (184.8 KB)

from the pdf you sent

is it bug? …

@calistasoft

This is expected behavior, as the image is being added with transparency. So it will be visible on foreground and due to opacity settings, the content under the image will also be visible.

I’m not agree with you…
since watermark image normally should be in the background of the contents… it’s not running as expected…

please confirm if this is a bug!.. so I can confirm to our client… they keep ask us for this

@calistasoft

We have logged your concerns with the ticket generated earlier. We will again review the logged investigation ticket and share our feedback with you, as soon as we have some results. Please spare us little time.

We are sorry for the inconvenience.

please keep me posted!.. I have to inform our client regarding to this issue…
thanks

@calistasoft,

We will share the feedback with you as soon as the issue will be fixed.

@calistasoft

We have further investigated the logged ticket and found this issue can be resolved but, it requires additional investigations for a reasonable ETA. As queue of pending issues in free support model is quite long, we are afraid that your issue may take months to get resolved. We will start work to investigate it further and resolve it if you upgrade to paid support and escalate the issue to high priority but, we are afraid that we would not be able to resolve it immediately.

We will keep informing you in case of further updates regarding issue resolution.