We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to align the Pdf Rubber stamp to the page as well as set its margins?

Thread ID:





142764 Feb 18,2019 08:54 PM UTC Feb 19,2019 11:23 AM UTC ASP.NET MVC - EJ 2 1
Tags: PDF
Asked On February 18, 2019 08:54 PM UTC

I'm trying to add graphic stamps to my pdf file and I want to position them in a certain way. Reading the documentation for this class, there was any mention of an alignment or margin property, however, there is property called page that gives me direct access to the current settings that the page has though I'm not certain I should be  modifying that when all I want to do is modify the margin and alignment property of my stamp.

Ideally I would like to do this(Pseudocode).

          var imageStamp = new PdfRubberStampAnnotation();
          imageStamp.TopMargin = 10;
          imageStamp.HorizontalAlignment = HorizontalAlignment.Center;
          imageStamp.VerticalAlignment = VerticalAlignment.Top;

How would I roughly be able to achieve this?

Prakash Viswanathan [Syncfusion]
Replied On February 19, 2019 11:23 AM UTC

Hi Luis, 
Thanks for contacting Syncfusion support.  
The PdfRubberStampAnnotation does not have properties to set the horizontal and vertical alignment. However, we can achieve your requirement by calculating the X and Y position of the annotation based on page size and size of the annotation. Kindly refer below code snippet to add the annotation with particular postion.  
//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 
//Saves the document to disk. 
document.Save(DataPathOutput + "RubberStamp.pdf"); 
A simple sample for achieving the same can be found in the below link: 
Please let us know if you need any further assistance on this.  
Prakash V 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon