Table of Contents

Class PdfAnnotation

Namespace
Syncfusion.Pdf.Interactive
Assembly
Syncfusion.Pdf.Portable.dll

Represents the base class for annotation objects.

public abstract class PdfAnnotation : INotifyPropertyChanged
Inheritance
PdfAnnotation
Implements
Derived
Inherited Members

Constructors

PdfAnnotation(RectangleF)

Creates new annotation object with the specified bounds.

protected PdfAnnotation(RectangleF bounds)

Parameters

bounds RectangleF

Bounds of the annotation.

See Also

PdfAnnotation(PdfPageBase, string)

Creates new annotation object with the specified PDF page and text.

protected PdfAnnotation(PdfPageBase page, string text)

Parameters

page PdfPageBase

The page where annotation to be added.

text string

The text.

See Also

Properties

AnnotationFlags

Gets or sets the annotation flags.

public virtual PdfAnnotationFlags AnnotationFlags { get; set; }

Property Value

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)
See Also

Author

Gets or Sets the Author of the annotation.

public virtual string Author { get; set; }

Property Value

string
See Also

Border

Gets or sets annotation's border properties like width, horizontal radius etc.

public virtual PdfAnnotationBorder Border { get; set; }

Property Value

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)
See Also

Bounds

Gets or sets annotation's bounds in the PDF page.

public virtual RectangleF Bounds { get; set; }

Property Value

RectangleF

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)

Remarks

If this property is not set, the bounds are calculated automatically based on Location property and content of annotation.

See Also

Color

Gets or sets the annotation color.

public virtual PdfColor Color { get; set; }

Property Value

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)
See Also

Flatten

Gets or sets the boolean flag to flatten the annotations.

public bool Flatten { get; set; }

Property Value

bool
See Also

FlattenPopUps

Get or set flatten the Popups annotations

public bool FlattenPopUps { get; set; }

Property Value

bool
See Also

InnerColor

Get or set the inner color of the annotation. Default color is transparent

public virtual PdfColor InnerColor { get; set; }

Property Value

PdfColor
See Also

Layer

Get or set the PdfLayer to the annotation

public PdfLayer Layer { get; set; }

Property Value

PdfLayer
See Also

Location

Gets or sets the location of the annotation.

public virtual PointF Location { get; set; }

Property Value

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)
See Also

ModifiedDate

Gets or Sets the ModifiedDate of the annotation.

public virtual DateTime ModifiedDate { get; set; }

Property Value

DateTime
See Also

Name

Gets or sets the Name to the uniquely identifying annotations.

public string Name { get; set; }

Property Value

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)
See Also

Opacity

Gets or Sets the Opacity of the annotation.

public virtual float Opacity { get; set; }

Property Value

float
See Also

Page

Gets a page of the annotation. Read-Only.

public PdfPage Page { get; }

Property Value

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)
See Also

PdfTag

Gets or sets the tag for annotation

public PdfTag PdfTag { get; set; }

Property Value

PdfTag
See Also

Rotate

Gets or sets the rotation of PDF annotation

public PdfAnnotationRotateAngle Rotate { get; set; }

Property Value

PdfAnnotationRotateAngle
See Also

Size

Gets or sets the size of the annotation.

public virtual SizeF Size { get; set; }

Property Value

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)
See Also

Subject

Gets or Sets the Subject of the annotation.

public virtual string Subject { get; set; }

Property Value

string
See Also

Text

Gets or sets content of the annotation.

public virtual string Text { get; set; }

Property Value

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)
See Also

Methods

CalculateBounds(RectangleF, PdfPage, PdfLoadedPage)

returns annotation bounds.

protected RectangleF CalculateBounds(RectangleF Bounds, PdfPage page, PdfLoadedPage loadedpage)

Parameters

Bounds RectangleF
page PdfPage
loadedpage PdfLoadedPage

Returns

RectangleF
See Also

CalculateTemplateBounds(RectangleF, PdfPageBase, PdfTemplate)

protected PointF CalculateTemplateBounds(RectangleF Bounds, PdfPageBase page, PdfTemplate template)

Parameters

Bounds RectangleF
page PdfPageBase
template PdfTemplate

Returns

PointF
See Also

CalculateTemplateBounds(RectangleF, PdfPageBase, PdfTemplate, bool)

Returns the annotation appearance location to be draw in page

protected RectangleF CalculateTemplateBounds(RectangleF bounds, PdfPageBase page, PdfTemplate template, bool isNormalMatrix)

Parameters

bounds RectangleF
page PdfPageBase
template PdfTemplate
isNormalMatrix bool

Returns

RectangleF
See Also

CalculateTemplateBounds(RectangleF, PdfPageBase, PdfTemplate, bool, PdfGraphics)

Returns the annotation appearance location to be draw in page

protected RectangleF CalculateTemplateBounds(RectangleF bounds, PdfPageBase page, PdfTemplate template, bool isNormalMatrix, PdfGraphics graphics)

Parameters

bounds RectangleF
page PdfPageBase
template PdfTemplate
isNormalMatrix bool
graphics PdfGraphics

Returns

RectangleF
See Also

CheckFlatten()

Obtain annotation need flatten

protected void CheckFlatten()
See Also

Initialize()

Initializes annotation object.

protected virtual void Initialize()
See Also

Save()

Saves an annotation.

protected virtual void Save()
See Also

SetAppearance(bool)

Specifies whether to set the default appearance for the annotation or not.

public void SetAppearance(bool appearance)

Parameters

appearance bool
See Also

SetValues(string, string)

Set the values associated with the specified key.

public void SetValues(string key, string value)

Parameters

key string
value string

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)
See Also

Events

PropertyChanged

The event will rise when the annotations properties have been changed.

public event PropertyChangedEventHandler PropertyChanged

Event Type

PropertyChangedEventHandler
See Also

See Also