Please note that IsBackground Property when set to true, causes stamp to render in the background of original content inside PDF Page. In other words, the stamp will be rendered beneath the main layer of content. You may please set this property as false and specify opacity for stamp to render it properly. In case of further assistance, please feel free to let us know.
In case you need to upload files with post for further query, you may upload it using button shown in screenshot. Upload_Files.png (8.9 KB)
Here are the test files:
stamp.png -> the image used as stamp
test1.pdf -> first pdf test file
test2.pdf -> second pdf test file
Then:
placing the stamp on first pdf test file (IsBackground = true) => the stamp is not visible
placing the stamp on second pdf test file (IsBackground = true) => the stamp is visible
I would expect the same behaviour on both files, but it’s different.
Moreover, if I am forced to specify IsBackground = false, when it makes sense to use IsBackground = true?
We have tested the scenario in our environment while using following DOM based code snippet.
Document pdfDocument = new Document(dataDir + "test1.pdf");
ImageStamp imageStamp = new ImageStamp(dataDir + "stamp.png");
imageStamp.Background = true;
imageStamp.Opacity = 0.5;
imageStamp.HorizontalAlignment = HorizontalAlignment.Center;
imageStamp.VerticalAlignment = VerticalAlignment.Center;
for (int i = 1; i <= pdfDocument.Pages.Count; i++)
{
pdfDocument.Pages[i].AddStamp(imageStamp);
}
pdfDocument.Save(dataDir + "ImageStamp_out1true.pdf");
The stamp is not visible when IsBackground is set to true in test1.pdf because other images are present inside the PDF and due to background property, the stamp is layed at the bottom of images (Stamp.jpg). In case of test2.pdf, there are no images/resources/annotations except plain text so stamp remains visible despite its IsBackground property is set to true.
It is suggested to set IsBackground property as false or leave it unspecified as its default value is also false. Doing this, Stamp would be rendered at the top of content and stay visible in every PDF page. We hope our suggestions are helpful. In case you still face any issue, please feel free to contact us.