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

Free Support Forum - aspose.com

How to Set FreeTextAnnotation Font Attributes

When creating an InteractiveFeatures.Annotations.FreeTextAnnotation, how do you set the font name, font size, color, etc? I see there is a DefaultAppearance string and an Appearance object, but don’t see how to set this attributes. Thanks.

Hi Joseph,

for using our products.

have tested the scenario and have observed that in current release version of Aspose.Pdf for .NET, the data type of DefaultAppearance is not correct so its not allowing us to set the appearance attributes for text object. For the
sake of correction, I have logged it in our issue tracking system as PDFNEWNET-34471. We
will investigate this issue in details and will keep you updated on the status
of a correction.

apologize for your inconvenience.

PS, Currently we are investigating on providing the support for font name, font size, foreground color information. In case you need to set some other attributes, please explicitly mention those.

Thank you for your reply. When will there be an update or patch that fixes this problem?

Hi Joseph,

As we just have noticed this issue, so development team requires little time to investigate and rectify this problem. Please be patient and spare us little time.

Your patience and comprehension is greatly appreciated in this regard.

I have a project due for a client in one week. If this is fixed, I can buy Aspose.PDF for this project. So, will there be a fix available within one week? Thanks.

Hi Joseph,

I have inquired the updated/current status from development team and I have also informed them about your urgency. As soon as I have some updates from them, I will be pleased to update you with the status of correction. Please be patient and spare us little time.

We really appreciate your patience and comprehension in this regard.

Has a date been set yet to release a fix for this problem? I have an urgent need (this week) for this fix as stated before. Thank you for your help.

Hi Joseph,

I am afraid we have not been able to resolve this issue, but I have again sent an intimation to share some information if this problem can be fixed in near future. I will get back to you soon, with the updated information.

We are sorry for this inconvenience.

PS, In fact its is not just fixing a bug but providing a new feature that is why currently its little difficult to estimate the timelines by which it will be implemented.

Hi Joseph,

Thanks for your patience.

I am pleased to share that the issue reported earlier has been resolved. Now you can set the default appearance of FreeTextAnnotation using DefaultAppearance object or even you can directly specify the formatting information using TextStyle property.

TextStyle class is implemented to support working with default style entry. This class allows to set color, font size and font name.
  • property string FontName // gets or sets font name;
  • property double FontSize // gets or sets default size of text
  • property System.Drawing.Color Color (//gets or sets color of the text)
  • property TextAligment Alignment (// gets or sets text alignment in the annotation.)

Document doc1 = new

//set font size and color of the annotation:

(doc1.Pages[1].Annotations[1] as FreeTextAnnotation).TextStyle.FontSize = 18;

(doc1.Pages[1].Annotations[1] as FreeTextAnnotation).TextStyle.Color = System.Drawing.Color.Green;


//open document

Document pdfDocument = new Document("c:/pdftest/TestReport.pdf");

// instantiate DefaultAppearance object

Aspose.Pdf.InteractiveFeatures.DefaultAppearance default_appearance = new DefaultAppearance("Arial", 28, System.Drawing.Color.Red);

//create annotation

FreeTextAnnotation freetext = new FreeTextAnnotation(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(200, 400, 400, 600), default_appearance);

// specify the contents of annotation

freetext.Contents = "Free Text";

// add anootation to annotations collection of page


// save the updated document


PS, When Contents or TextStyle of the free text annotation is changed, annotation appearance is regenerated to reflect changes.