Skip to content

Commit d5af16c

Browse files
Merge pull request #1629 from syncfusion-content/260184-ug
260184-ug: Added content for the Annotation Intent in the PDF free Text Annotation
2 parents e1607d4 + 2a3c574 commit d5af16c

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

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

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5068,6 +5068,132 @@ 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+
5113+
{% endhighlight %}
5114+
5115+
{% highlight c# tabtitle="C# [Windows-specific]" %}
5116+
5117+
using Syncfusion.Drawing;
5118+
using Syncfusion.Pdf;
5119+
using Syncfusion.Pdf.Graphics;
5120+
using Syncfusion.Pdf.Interactive;
5121+
5122+
// Create a new PDF document
5123+
using (PdfDocument document = new PdfDocument())
5124+
{
5125+
// Add a page
5126+
PdfPage page = document.Pages.Add();
5127+
5128+
// Define the bounds for the annotation
5129+
RectangleF bounds = new RectangleF(100, 100, 200, 50);
5130+
5131+
// Create a FreeText annotation
5132+
PdfFreeTextAnnotation freeText = new PdfFreeTextAnnotation(bounds);
5133+
// Add content.
5134+
freeText.Text = "Add Free Text Annotation with Intent";
5135+
// Set the annotation intent to TypeWriter
5136+
freeText.AnnotationIntent = PdfAnnotationIntent.FreeTextTypeWriter;
5137+
5138+
// Customize appearance
5139+
freeText.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
5140+
freeText.TextMarkupColor = Color.Black;
5141+
freeText.BorderColor = Color.Gray;
5142+
freeText.Color = Color.LightYellow;
5143+
5144+
// Add the annotation to the page
5145+
page.Annotations.Add(freeText);
5146+
5147+
// Save the document
5148+
document.Save("Output.pdf");
5149+
}
5150+
5151+
{% endhighlight %}
5152+
5153+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
5154+
5155+
Imports Syncfusion.Drawing
5156+
Imports Syncfusion.Pdf
5157+
Imports Syncfusion.Pdf.Graphics
5158+
Imports Syncfusion.Pdf.Interactive
5159+
5160+
' Create a new PDF document
5161+
Using document As New PdfDocument()
5162+
5163+
' Add a page
5164+
Dim page As PdfPage = document.Pages.Add()
5165+
5166+
' Define the bounds for the annotation
5167+
Dim bounds As New RectangleF(100, 100, 200, 50)
5168+
5169+
' Create a FreeText annotation
5170+
Dim freeText As New PdfFreeTextAnnotation(bounds)
5171+
5172+
' Add content
5173+
freeText.Text = "Add Free Text Annotation with Intent"
5174+
5175+
' Set the annotation intent to TypeWriter
5176+
freeText.AnnotationIntent = PdfAnnotationIntent.FreeTextTypeWriter
5177+
5178+
' Customize appearance
5179+
freeText.Font = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
5180+
freeText.TextMarkupColor = Color.Black
5181+
freeText.BorderColor = Color.Gray
5182+
freeText.Color = Color.LightYellow
5183+
5184+
' Add the annotation to the page
5185+
page.Annotations.Add(freeText)
5186+
5187+
' Save the document
5188+
document.Save("Output.pdf")
5189+
End Using
5190+
5191+
{% endhighlight %}
5192+
5193+
{% endtabs %}
5194+
5195+
You can download a complete working sample from GitHub.
5196+
50715197
## Adding comments and review status to the PDF annotation
50725198

50735199
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)