//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Creates a new page
PdfPage page = document.Pages.Add();
//Getting page size
SizeF pageSize = page.GetClientSize();
//Setting annotation size
SizeF annotSize = new SizeF(100, 20);
//Setting the X position to align in center of page
float xPos = (pageSize.Width / 2) - (annotSize.Width / 2);
//Set margin as Y value
float yPos = 10;
RectangleF bounds = new RectangleF(new PointF(xPos, yPos), annotSize);
//Creates a new pdf rubber stamp annotation.
PdfRubberStampAnnotation rubberStampAnnotation = new PdfRubberStampAnnotation(bounds, " Text Rubber Stamp Annotation");
rubberStampAnnotation.Icon = PdfRubberStampAnnotationIcon.Experimental;
rubberStampAnnotation.Text = "Text Properties Rubber Stamp Annotation";
//Adds annotation to the page
page.Annotations.Add(rubberStampAnnotation);
//Saves the document to disk.
document.Save(DataPathOutput + "RubberStamp.pdf");
document.Close(true); |