Class PdfAnnotation
Represents the base class for annotation objects.
Inheritance
Implements
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.NET.dll
Syntax
public abstract class PdfAnnotation : Object, IPdfWrapper, INotifyPropertyChanged
Constructors
PdfAnnotation(RectangleF)
Creates new annotation object with the specified bounds.
Declaration
protected PdfAnnotation(RectangleF bounds)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | bounds | Bounds of the annotation. |
PdfAnnotation(PdfPageBase, String)
Creates new annotation object with the specified PDF page and text.
Declaration
protected PdfAnnotation(PdfPageBase page, string text)
Parameters
Type | Name | Description |
---|---|---|
PdfPageBase | page | The page where annotation to be added. |
System.String | text | The text. |
Properties
AnnotationFlags
Gets or sets the annotation flags.
Declaration
public virtual PdfAnnotationFlags AnnotationFlags { get; set; }
Property Value
Type |
---|
PdfAnnotationFlags |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"input.wav");
//Set the annotation flags to sound annotation.
soundAnnotation.AnnotationFlags = PdfAnnotationFlags.Print;
//Add this annotation to a new page.
page.Annotations.Add(soundAnnotation);
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle.
Dim rectangle As RectangleF = New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As PdfSoundAnnotation = New PdfSoundAnnotation(rectangle, "input.wav")
'Set the annotation flags to sound annotation.
soundAnnotation.AnnotationFlags = PdfAnnotationFlags.Print
'Add this annotation to a new page.
page.Annotations.Add(soundAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Author
Gets or Sets the Author of the annotation.
Declaration
public virtual string Author { get; set; }
Property Value
Type |
---|
System.String |
Border
Gets or sets annotation's border properties like width, horizontal radius etc.
Declaration
public virtual PdfAnnotationBorder Border { get; set; }
Property Value
Type |
---|
PdfAnnotationBorder |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create a new page.
PdfPage page = document.Pages.Add();
//Create a new rectangle.
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"input.wav");
//Assign the border to sound annotation.
soundAnnotation.Border = new PdfAnnotationBorder(5);
//Add this annotation to a new page.
page.Annotations.Add(soundAnnotation);
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Create a new page
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As RectangleF = New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As PdfSoundAnnotation = New PdfSoundAnnotation(rectangle, "input.wav")
'Assign the border to sound annotation.
soundAnnotation.Border = New PdfAnnotationBorder(5)
'Add this annotation to a new page.
page.Annotations.Add(soundAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Bounds
Gets or sets annotation's bounds in the PDF page.
Declaration
public virtual RectangleF Bounds { get; set; }
Property Value
Type |
---|
RectangleF |
Remarks
If this property is not set, the bounds are calculated automatically based on Location property and content of annotation.
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create a new page.
PdfPage page = document.Pages.Add();
//Create a new rectangle.
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"input.wav");
//Assign the bounds to sound annotation.
soundAnnotation.Bounds=new RectangleF(50, 100, 30, 30);
//Add this annotation to a new page.
page.Annotations.Add(soundAnnotation);
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle.
Dim rectangle As RectangleF = New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As PdfSoundAnnotation = New PdfSoundAnnotation(rectangle, "input.wav")
'Assign the bounds to sound annotation.
soundAnnotation.Bounds=New RectangleF(50, 100, 30, 30)
'Add this annotation to a new page.
page.Annotations.Add(soundAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Color
Gets or sets the annotation color.
Declaration
public virtual PdfColor Color { get; set; }
Property Value
Type | Description |
---|---|
PdfColor | The PdfColor which draws the outline of the annotation. |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create a new page
PdfPage page = document.Pages.Add();
//Create a new rectangle.
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"input.wav");
//Set the color.
soundAnnotation.Color = new PdfColor(Color.Red);
//Add this annotation to a new page.
page.Annotations.Add(soundAnnotation);
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a a new rectangle.
Dim rectangle As RectangleF = New RectangleF(10, 40, 30, 30);
'Create a new sound annotation.
Dim soundAnnotation As PdfSoundAnnotation = New PdfSoundAnnotation(rectangle, "input.wav")
'Set the color.
soundAnnotation.Color = New PdfColor(Color.Red)
'Add this annotation to a new page.
page.Annotations.Add(soundAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Flatten
Gets or sets the boolean flag to flatten the annotations.
Declaration
public bool Flatten { get; set; }
Property Value
Type |
---|
System.Boolean |
FlattenPopUps
Get or set flatten the Popups annotations
Declaration
public bool FlattenPopUps { get; set; }
Property Value
Type |
---|
System.Boolean |
InnerColor
Get or set the inner color of the annotation. Default color is transparent
Declaration
public virtual PdfColor InnerColor { get; set; }
Property Value
Type |
---|
PdfColor |
Layer
Get or set the PdfLayer to the annotation
Declaration
public PdfLayer Layer { get; set; }
Property Value
Type |
---|
PdfLayer |
Location
Gets or sets the location of the annotation.
Declaration
public virtual PointF Location { get; set; }
Property Value
Type |
---|
PointF |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create a new page.
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"input.wav");
//Assign the location to sound annotation.
soundAnnotation.Location=new PointF(50, 100);
//Add this annotation to a new page.
page.Annotations.Add(soundAnnotation);
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As RectangleF = New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As PdfSoundAnnotation = New PdfSoundAnnotation(rectangle, "input.wav")
'Assign the location to sound annotation.
soundAnnotation.Location=New PointF(50, 100)
'Add this annotation to a new page.
page.Annotations.Add(soundAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
ModifiedDate
Gets or Sets the ModifiedDate of the annotation.
Declaration
public virtual DateTime ModifiedDate { get; set; }
Property Value
Type |
---|
System.DateTime |
Name
Gets or sets the Name to the uniquely identifying annotations.
Declaration
public string Name { get; set; }
Property Value
Type |
---|
System.String |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create PDF font and PDF font style .
Font font = new Font("Calibri", 10, FontStyle.Bold);
PdfFont pdfFont = new PdfTrueTypeFont(font, false);
//Create a new pdf brush.
PdfBrush pdfBrush = new PdfSolidBrush(Color.Black);
//Draw text in the new page.
page.Graphics.DrawString("Text Markup Annotation Demo", pdfFont, pdfBrush, new PointF(150, 10));
string markupText = "Text Markup";
SizeF size = pdfFont.MeasureString(markupText);
RectangleF rectangle = new RectangleF(175, 40, size.Width, size.Height);
page.Graphics.DrawString(markupText, pdfFont, pdfBrush, rectangle);
//Create a pdf text markup annotation .
PdfTextMarkupAnnotation markupAnnotation = new PdfTextMarkupAnnotation("Markup annotation", "Markup annotation with highlight style", markupText, new PointF(175, 40), pdfFont);
markupAnnotation.TextMarkupColor = new PdfColor(Color.BlueViolet);
markupAnnotation.TextMarkupAnnotationType = PdfTextMarkupAnnotationType.Highlight;
markupAnnotation.Name = "d5daa6e7-4a7d-4e33-0168-4c4211e2c491";
//Add this annotation to a new page.
page.Annotations.Add(markupAnnotation);
//Save the document to disk.
document.Save("Output.pdf");
//close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create pdf font and pdf font style .
Dim font As New Font("Calibri", 10, FontStyle.Bold)
Dim pdfFont As PdfFont = New PdfTrueTypeFont(font, False)
'Create a new PDF brush.
Dim pdfBrush As PdfBrush = New PdfSolidBrush(Color.Black)
'Draw text in the new page.
page.Graphics.DrawString("Text Markup Annotation Demo", pdfFont, pdfBrush, New PointF(150, 10))
Dim markupText As String = "Text Markup"
Dim size As SizeF = pdfFont.MeasureString(markupText)
Dim rectangle As New RectangleF(175, 40, size.Width, size.Height)
page.Graphics.DrawString(markupText, pdfFont, pdfBrush, rectangle)
'Create a pdf text markup annotation .
Dim markupAnnotation As New PdfTextMarkupAnnotation("Markup annotation", "Markup annotation with highlight style", markupText, New PointF(175, 40), pdfFont)
markupAnnotation.TextMarkupColor = New PdfColor(Color.BlueViolet)
markupAnnotation.TextMarkupAnnotationType = PdfTextMarkupAnnotationType.Highlight
markupAnnotation.Name = "d5daa6e7-4a7d-4e33-0168-4c4211e2c491"
'Add this annotation to a new page.
page.Annotations.Add(markupAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'close the document
document.Close(True)
Opacity
Gets or Sets the Opacity of the annotation.
Declaration
public virtual float Opacity { get; set; }
Property Value
Type |
---|
System.Single |
Page
Gets a page of the annotation. Read-Only.
Declaration
public PdfPage Page { get; }
Property Value
Type |
---|
PdfPage |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"input.wav");
//Add this annotation to a new page.
page.Annotations.Add(soundAnnotation);
//Gets the page.
PdfPage pdfPage=soundAnnotation.Page;
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As RectangleF = New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As PdfSoundAnnotation = New PdfSoundAnnotation(rectangle, "input.wav")
'Add this annotation to a new page.
page.Annotations.Add(soundAnnotation)
'Gets the page.
Dim pdfPage As PdfPage =soundAnnotation.Page
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
PdfTag
Gets or sets the tag for annotation
Declaration
public PdfTag PdfTag { get; set; }
Property Value
Type |
---|
PdfTag |
Rotate
Gets or sets the rotation of PDF annotation
Declaration
public PdfAnnotationRotateAngle Rotate { get; set; }
Property Value
Type |
---|
PdfAnnotationRotateAngle |
Size
Gets or sets the size of the annotation.
Declaration
public virtual SizeF Size { get; set; }
Property Value
Type |
---|
SizeF |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create a new page.
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"input.wav");
//Assign the size to sound annotation.
soundAnnotation.Size=new SizeF(50, 50);
//Add this annotation to a new page.
page.Annotations.Add(soundAnnotation);
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Create a new page.
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As RectangleF = New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As PdfSoundAnnotation = New PdfSoundAnnotation(rectangle, "input.wav")
'Assign the size to sound annotation.
soundAnnotation.Size=New SizeF(50, 50)
'Add this annotation to a new page.
page.Annotations.Add(soundAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Subject
Gets or Sets the Subject of the annotation.
Declaration
public virtual string Subject { get; set; }
Property Value
Type |
---|
System.String |
Text
Gets or sets content of the annotation.
Declaration
public virtual string Text { get; set; }
Property Value
Type |
---|
System.String |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"input.wav");
//Set the text to sound annotation.
soundAnnotation.Text="Sound Annotation";
//Add this annotation to a new page.
page.Annotations.Add(soundAnnotation);
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
Dim rectangle As RectangleF = New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As PdfSoundAnnotation = New PdfSoundAnnotation(rectangle, "input.wav")
'Set the text to sound annotation.
soundAnnotation.Text="Sound Annotation"
'Add this annotation to a new page.
page.Annotations.Add(soundAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Methods
CalculateBounds(RectangleF, PdfPage, PdfLoadedPage)
returns annotation bounds.
Declaration
protected RectangleF CalculateBounds(RectangleF Bounds, PdfPage page, PdfLoadedPage loadedpage)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | Bounds | |
PdfPage | page | |
PdfLoadedPage | loadedpage |
Returns
Type |
---|
RectangleF |
CalculateTemplateBounds(RectangleF, PdfPageBase, PdfTemplate)
Declaration
protected PointF CalculateTemplateBounds(RectangleF Bounds, PdfPageBase page, PdfTemplate template)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | Bounds | |
PdfPageBase | page | |
PdfTemplate | template |
Returns
Type |
---|
PointF |
CalculateTemplateBounds(RectangleF, PdfPageBase, PdfTemplate, Boolean)
Returns the annotation appearance location to be draw in page
Declaration
protected RectangleF CalculateTemplateBounds(RectangleF bounds, PdfPageBase page, PdfTemplate template, bool isNormalMatrix)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | bounds | |
PdfPageBase | page | |
PdfTemplate | template | |
System.Boolean | isNormalMatrix |
Returns
Type |
---|
RectangleF |
CalculateTemplateBounds(RectangleF, PdfPageBase, PdfTemplate, Boolean, PdfGraphics)
Returns the annotation appearance location to be draw in page
Declaration
protected RectangleF CalculateTemplateBounds(RectangleF bounds, PdfPageBase page, PdfTemplate template, bool isNormalMatrix, PdfGraphics graphics)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | bounds | |
PdfPageBase | page | |
PdfTemplate | template | |
System.Boolean | isNormalMatrix | |
PdfGraphics | graphics |
Returns
Type |
---|
RectangleF |
CheckFlatten()
Obtain annotation need flatten
Declaration
protected void CheckFlatten()
Initialize()
Initializes annotation object.
Declaration
protected virtual void Initialize()
Save()
Saves an annotation.
Declaration
protected virtual void Save()
SetAppearance(Boolean)
Specifies whether to set the default appearance for the annotation or not.
Declaration
public void SetAppearance(bool appearance)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | appearance |
SetValues(String, String)
Set the values associated with the specified key.
Declaration
public void SetValues(string key, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | |
System.String | value |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create a new page.
PdfPage page = document.Pages.Add();
//To specify the line end points
int[] points = new int[] { 80, 420, 150, 420 };
//Create a new line annotation and set properties.
PdfLineAnnotation lineAnnotation = new PdfLineAnnotation(points);
lineAnnotation.Text = "Line Annotation";
//Create pdf line border
LineBorder lineBorder = new LineBorder();
lineBorder.BorderStyle = PdfBorderStyle.Solid;
lineBorder.BorderWidth = 1;
lineAnnotation.lineBorder = lineBorder;
lineAnnotation.LineIntent = PdfLineIntent.LineDimension;
lineAnnotation.Author = "LineAnnotaion";
lineAnnotation.ModifiedDate = DateTime.Now;
lineAnnotation.Subject = "LineAnnoataion";
lineAnnotation.SetValues("State", "CustomState");
lineAnnotation.SetValues("StateModel", "CustomStateModel");
page.Annotations.Add(lineAnnotation);
document.Save("Output.pdf");
document.Close(true);
Dim document As PdfDocument = New PdfDocument
Dim page As PdfPage = document.Pages.Add
Dim points() As Integer = New Integer() { 80, 420, 150, 420}
Dim lineAnnotation As PdfLineAnnotation = New PdfLineAnnotation(points)
lineAnnotation.Text = "Line Annotation"
Dim lineBorder As LineBorder = New LineBorder
lineBorder.BorderStyle = PdfBorderStyle.Solid
lineBorder.BorderWidth = 1
lineAnnotation.lineBorder = lineBorder
lineAnnotation.LineIntent = PdfLineIntent.LineDimension
lineAnnotation.Author = "LineAnnotaion"
lineAnnotation.ModifiedDate = DateTime.Now
lineAnnotation.Subject = "LineAnnoataion"
lineAnnotation.SetValues("State", "CustomState")
lineAnnotation.SetValues("StateModel", "CustomStateModel")
page.Annotations.Add(lineAnnotation)
document.Save("Output.pdf")
document.Close(true)
Events
PropertyChanged
The event will rise when the annotations properties have been changed.
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type |
---|
System.ComponentModel.PropertyChangedEventHandler |