Skip to content

Commit 1760798

Browse files
committed
260184-ug: Added content for the Annotation Intent in the PDF freeText Annotation
1 parent b9d6dbe commit 1760798

File tree

1 file changed

+135
-0
lines changed

1 file changed

+135
-0
lines changed

Document-Processing/PDF/PDF-Library/NET/Working-with-Annotations.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5068,6 +5068,141 @@ document.Close(True)
50685068

50695069
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Annotation/Adding-transparency-for-annotations/.NET).
50705070

5071+
## Setting Annotation Intent in PdfFreeTextAnnotation
5072+
5073+
The [PdfAnnotationIntent.FreeTextTypeWriter](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Interactive.PdfAnnotationIntent.html#fields) value specifies that a `free text annotation` in a PDF should behave like a `typewriter-style input field`. This intent is especially useful for simulating manual typing on forms or documents, enabling users to add clear, typed comments or responses.
5074+
5075+
{% tabs %}
5076+
5077+
{% highlight c# tabtitle="C# [Cross-platform]" %}
5078+
5079+
using Syncfusion.Drawing;
5080+
using Syncfusion.Pdf;
5081+
using Syncfusion.Pdf.Graphics;
5082+
using Syncfusion.Pdf.Interactive;
5083+
5084+
// Create a new PDF document
5085+
using (PdfDocument document = new PdfDocument())
5086+
{
5087+
// Add a page
5088+
PdfPage page = document.Pages.Add();
5089+
5090+
// Define the bounds for the annotation
5091+
RectangleF bounds = new RectangleF(100, 100, 200, 50);
5092+
5093+
// Create a FreeText annotation
5094+
PdfFreeTextAnnotation freeText = new PdfFreeTextAnnotation(bounds);
5095+
// Add content.
5096+
freeText.Text = "Add Free Text Annotation with Intent";
5097+
// Set the annotation intent to TypeWriter
5098+
freeText.AnnotationIntent = PdfAnnotationIntent.FreeTextTypeWriter;
5099+
5100+
// Customize appearance
5101+
freeText.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
5102+
freeText.TextMarkupColor = Color.Black;
5103+
freeText.BorderColor = Color.Gray;
5104+
freeText.Color = Color.LightYellow;
5105+
5106+
// Add the annotation to the page
5107+
page.Annotations.Add(freeText);
5108+
5109+
// Save the document
5110+
document.Save("Output.pdf");
5111+
5112+
// Close the document
5113+
document.Close(true);
5114+
}
5115+
5116+
{% endhighlight %}
5117+
5118+
{% highlight c# tabtitle="C# [Windows-specific]" %}
5119+
5120+
using Syncfusion.Drawing;
5121+
using Syncfusion.Pdf;
5122+
using Syncfusion.Pdf.Graphics;
5123+
using Syncfusion.Pdf.Interactive;
5124+
5125+
// Create a new PDF document
5126+
using (PdfDocument document = new PdfDocument())
5127+
{
5128+
// Add a page
5129+
PdfPage page = document.Pages.Add();
5130+
5131+
// Define the bounds for the annotation
5132+
RectangleF bounds = new RectangleF(100, 100, 200, 50);
5133+
5134+
// Create a FreeText annotation
5135+
PdfFreeTextAnnotation freeText = new PdfFreeTextAnnotation(bounds);
5136+
// Add content.
5137+
freeText.Text = "Add Free Text Annotation with Intent";
5138+
// Set the annotation intent to TypeWriter
5139+
freeText.AnnotationIntent = PdfAnnotationIntent.FreeTextTypeWriter;
5140+
5141+
// Customize appearance
5142+
freeText.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
5143+
freeText.TextMarkupColor = Color.Black;
5144+
freeText.BorderColor = Color.Gray;
5145+
freeText.Color = Color.LightYellow;
5146+
5147+
// Add the annotation to the page
5148+
page.Annotations.Add(freeText);
5149+
5150+
// Save the document
5151+
document.Save("Output.pdf");
5152+
5153+
// Close the document
5154+
document.Close(true);
5155+
}
5156+
5157+
{% endhighlight %}
5158+
5159+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
5160+
5161+
Imports Syncfusion.Drawing
5162+
Imports Syncfusion.Pdf
5163+
Imports Syncfusion.Pdf.Graphics
5164+
Imports Syncfusion.Pdf.Interactive
5165+
5166+
' Create a new PDF document
5167+
Using document As New PdfDocument()
5168+
5169+
' Add a page
5170+
Dim page As PdfPage = document.Pages.Add()
5171+
5172+
' Define the bounds for the annotation
5173+
Dim bounds As New RectangleF(100, 100, 200, 50)
5174+
5175+
' Create a FreeText annotation
5176+
Dim freeText As New PdfFreeTextAnnotation(bounds)
5177+
5178+
' Add content
5179+
freeText.Text = "Add Free Text Annotation with Intent"
5180+
5181+
' Set the annotation intent to TypeWriter
5182+
freeText.AnnotationIntent = PdfAnnotationIntent.FreeTextTypeWriter
5183+
5184+
' Customize appearance
5185+
freeText.Font = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
5186+
freeText.TextMarkupColor = Color.Black
5187+
freeText.BorderColor = Color.Gray
5188+
freeText.Color = Color.LightYellow
5189+
5190+
' Add the annotation to the page
5191+
page.Annotations.Add(freeText)
5192+
5193+
' Save the document
5194+
document.Save("Output.pdf")
5195+
5196+
' Close the document
5197+
document.Close(True)
5198+
End Using
5199+
5200+
{% endhighlight %}
5201+
5202+
{% endtabs %}
5203+
5204+
You can download a complete working sample from GitHub.
5205+
50715206
## Adding comments and review status to the PDF annotation
50725207

50735208
The PDF annotations may have an author-specific state associated with them. The state is not specified in the annotation itself, but it represents a separate text annotation ([Popup Annotation](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Interactive.PdfPopupAnnotation.html)).

0 commit comments

Comments
 (0)