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

Free Support Forum - aspose.com

StampAnnotation Documentation

Can I get some clarity in the documentation and usage for the StampAnnotation. In the documentation (https://reference.aspose.com/net/pdf/aspose.pdf.annotations/stampannotation) the constructors are either a Document or a Page+Rectangle:

Constructors:

Public method StampAnnotation(Document)

Public method StampAnnotation(Page, Rectangle)
Creates new Stamp annotation on the specified page.

But in the examples there are demonstrations of passing in a StampIcon or an Image as constructors:

Document document = new Document(inFile);
StampAnnotation stamp1 = new StampAnnotation(StampIcon.NotForPublicRelease);
stamp1.Rect = new Rectangle(100, 100, 120, 120)
document.Pages[1].Annotations.Add(stamp1);
StampAnnotation stamp2 = new StampAnnotation(new FileStream(“rubber.jpg”, FileMode.Open));
stamp2.Rect = new Rectangle(200, 200, 220, 220)
document.Pages[1].Annotations.Add(stamp2);
document.Save(outFile);

What is the correct usage of this? Thanks.

@serradjs

Thanks for contacting support.

In the latest version of the API (i.e Aspose.Pdf for .NET 17.8), the StampAnnotation Class has two constructors overloads (i.e Document, Page and Rectangle). However, there have been multiple changes in each upcoming version of the API, including addition of new classes as well as removal of some features and methods. Which is why we always try to update our API documentation accordingly, so that our customers may get updated and enhanced information regarding API features.

It is possible that some older version of the API supported StampIcon or an Image as constructors of the StampAnnotation but in the latest version it has been changed to what you have noticed in API references. Currently, you may set StampIcon or Image like in following code snippet and it is recommended to use it following way as well. :slight_smile:

StampAnnotation stamp = new StampAnnotation(doc);
stamp.Icon = StampIcon.NotForPublicRelease;

Would you please point us to the link of documentation, where you have found above code snippet. We will definitely update it according to recommended and latest approach.

We are sorry for the confusion faced.