@@ -287,7 +287,59 @@ The [TextStyle](https://reference.aspose.com/pdf/net/aspose.pdf.annotations/text
287287
288288The following code snippet shows how to add a FreeTextAnnotation with specific text formatting.
289289
290- {{< gist "aspose-pdf" "7e1330795d76012fcb04248bb81d45b3" "Examples-CSharp-AsposePDF-Annotations-SetFreeTextAnnotationFormatting-SetFreeTextAnnotationFormatting.cs" >}}
290+ {{< tabs tabID="1" tabTotal="2" tabName1=".NET Core 3.1" tabName2=".NET 8" >}}
291+ {{< tab tabNum="1" >}}
292+ csharp
293+ private static void AddFreeAnnotation()
294+ {
295+ // The path to the documents directory
296+ string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();
297+
298+ // Open document
299+ using (var document = new Aspose.Pdf.Document(dataDir + "SetFreeTextAnnotationFormatting.pdf"))
300+ {
301+ // Instantiate DefaultAppearance object
302+ var defaultAppearance = new Aspose.Pdf.Annotations.DefaultAppearance("Arial", 28, System.Drawing.Color.Red);
303+ // Create annotation
304+ var freetext = new Aspose.Pdf.Annotations.FreeTextAnnotation(document.Pages[1], new Aspose.Pdf.Rectangle(200, 400, 400, 600), defaultAppearance);
305+ // Specify the contents of annotation
306+ freetext.Contents = "Free Text";
307+ // Add anootation to annotations collection of page
308+ document.Pages[1].Annotations.Add(freetext);
309+ // Save the updated document
310+ document.Save(dataDir + "SetFreeTextAnnotationFormatting_out.pdf");
311+ }
312+ }
313+ {{< /tab >}}
314+
315+ {{< tab tabNum="2" >}}
316+ csharp
317+ private static void AddFreeAnnotation(string fontName = "Arial", float fontSize = 28)
318+ {
319+ // The path to the documents directory.
320+ string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();
321+ using var document = new Aspose.Pdf.Document($"{dataDir}SetFreeTextAnnotationFormatting.pdf");
322+ // Set default values
323+ var textColor = System.Drawing.Color.Red;
324+ var position = new Aspose.Pdf.Rectangle(200, 400, 400, 600);
325+
326+ // Instantiate DefaultAppearance object
327+ Aspose.Pdf.Annotations.DefaultAppearance defaultAppearance = new(fontName, fontSize, textColor);
328+ // Create annotation
329+ var freetext = new Aspose.Pdf.Annotations.FreeTextAnnotation(document.Pages[1], position, defaultAppearance)
330+ {
331+ // Specify the contents of annotation
332+ Contents = "Free Text"
333+ };
334+ // Add anootation to annotations collection of page
335+ document.Pages[1].Annotations.Add(freetext);
336+
337+ // Save the updated document
338+ document.Save($"{dataDir}SetFreeTextAnnotationFormatting_out.pdf");
339+ }
340+
341+ {{< /tab >}}
342+ {{< /tabs >}}
291343
292344{{% alert color="primary" %}}
293345
0 commit comments