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

Free Support Forum - aspose.cloud

Exception when adding FreeTextAnnotation


I am executing the following code to add FreeTextAnnotation to PDF document using Aspose.PDF Cloud SDK for .NET 23.4.0 but its producing an exception message.

Exception message

System.IO.InvalidDataException: Rect is a required property for FreeTextAnnotation and cannot be null
at Aspose.Pdf.Cloud.Sdk.Model.FreeTextAnnotation…ctor(List1 Links, Color Color, String Contents, String Modified, String Id, List1 Flags, String Name, Rectangle Rect, Nullable1 PageIndex, Nullable1 ZIndex, HorizontalAlignment HorizontalAlignment, VerticalAlignment VerticalAlignment, String CreationDate, String Subject, String Title, String RichText, Justification Justification, FreeTextIntent Intent, Rotation Rotate, TextStyle TextStyle)

Code snippet
`PdfApi api = new PdfApi(clientSecret, clientID);
List annotations = new List
new FreeTextAnnotation()
Contents = “Confidential !”,
Color = new Aspose.Pdf.Cloud.Sdk.Model.Color(0, 0, 0, 0),
Modified = “03/05/2023 16:00:00.000 PM”,
Rotate = Rotation.On90,
Id = “id1”,
Name = “Test Free Text”,
Rect = new Rectangle(100, 800, 350, 830),
TextStyle = new TextStyle(FontSize: 26, Font: “Arial”, ForegroundColor: new Aspose.Pdf.Cloud.Sdk.Model.Color(0xFF, 0, 0xFF, 0), BackgroundColor: new Aspose.Pdf.Cloud.Sdk.Model.Color(0xFF, 0xFF, 0, 0)),

 Flags = new List<AnnotationFlags> { AnnotationFlags.Default},
 HorizontalAlignment = HorizontalAlignment.Center,
 Intent = FreeTextIntent.FreeTextTypeWriter,
 RichText = "Rich Text",
 Subject = "Text Box Subj",
 ZIndex = 1,
 Justification = Justification.Center,
 Title = "Title",
 PageIndex = 1,
 CreationDate = "03/05/2023 16:00:00.000 PM"                

var response = api. PostPageFreeTextAnnotations(“Binder1.pdf”, 1, annotations);

Sample PDF used can be downloaded from this link.

However, please note that the API works fine when we access the API using SwaggerUI.


Please check the sample working code in the following post. Hopefully, it will help you accomplish the task.

Thanks @tilal.ahmad. Once I have defined the Rect values within FreeTextAnnotation(…) object creation, it works but not in the approach as I have listed above.

One more query, the Rotate property does not work. No matter what value is use from Rotation enumeration (On90, On270 or On180). See attached **Binder1-Annotated.pdf (618.9 KB)
** resultant file generated with above code snippet.


I also noticed that the rotation property is not working as expected with FreeTextAnnotation. We are investigating the issue(PDFCLOUD-3557) and will share our findings with you as soon as possible.