Table of Contents

Class PdfSquareAnnotation

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

Represents a PDF square annotation

public class PdfSquareAnnotation : PdfAnnotation, INotifyPropertyChanged
Inheritance
PdfSquareAnnotation
Implements
Derived
Inherited Members

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Creates a new page 
PdfPage page = document.Pages.Add();
document.PageSettings.SetMargins(0);
//Set the font
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 10f);
PdfBrush brush = new PdfSolidBrush(System.Drawing.Color.Black);
//Creates a new Square annotation.
PdfSquareAnnotation squareannotation = new PdfSquareAnnotation(new RectangleF(0, 30, 80, 80));
squareannotation.Text = "SquareAnnotation";
squareannotation.InnerColor = new PdfColor(Color.Red);
squareannotation.Color = new PdfColor(Color.Yellow);
page.Graphics.DrawString("Square Annotation", font, brush, new PointF(0, 0));
//Add the annotation to the page.
page.Annotations.Add(squareannotation);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Creates a new page 
Dim page As PdfPage = document.Pages.Add()
document.PageSettings.SetMargins(0)
'Set the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 10.0F)
Dim brush As PdfBrush = New PdfSolidBrush(System.Drawing.Color.Black)
'Creates a new Square annotation.
Dim squareannotation As PdfSquareAnnotation = New PdfSquareAnnotation(New RectangleF(0, 30, 80, 80))
squareannotation.Text = "SquareAnnotation"
squareannotation.InnerColor = New PdfColor(Color.Red)
squareannotation.Color = New PdfColor(Color.Yellow)
page.Graphics.DrawString("Square Annotation", font, brush, New PointF(0, 0))
'Add annotation to the page.
page.Annotations.Add(squareannotation)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)

Constructors

PdfSquareAnnotation(RectangleF)

Initialise the new instance of the square annotation with bounds.

public PdfSquareAnnotation(RectangleF rectangle)

Parameters

rectangle RectangleF

Used to represent the bounds of the annotation

Examples

 //Creates a new PDF document.
 PdfDocument document = new PdfDocument();
 //Creates a new page 
 PdfPage page = document.Pages.Add();
 document.PageSettings.SetMargins(0);
 //Set the font
 PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 10f);
 PdfBrush brush = new PdfSolidBrush(System.Drawing.Color.Black);
 //Creates a new Square annotation.
 PdfSquareAnnotation squareannotation = new PdfSquareAnnotation(new RectangleF(0, 30, 80, 80));
 squareannotation.Text = "SquareAnnotation";
 squareannotation.InnerColor = new PdfColor(Color.Red);
 LineBorder border = new LineBorder();
 border.BorderStyle = PdfBorderStyle.Solid;
 border.BorderWidth = 2;
 squareannotation.Border = border;
 squareannotation.Color = new PdfColor(Color.Yellow);
 page.Graphics.DrawString("Square Annotation", font, brush, new PointF(0, 0));
 //Add the annotation to the page.
page.Annotations.Add(squareannotation);
 //Save the document.
 document.Save("Output.pdf");
 //Close the document.
 document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Creates a new page 
Dim page As PdfPage = document.Pages.Add()
document.PageSettings.SetMargins(0)
'Set the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 10.0F)
Dim brush As PdfBrush = New PdfSolidBrush(System.Drawing.Color.Black)
'Creates a new Square annotation.
Dim squareannotation As PdfSquareAnnotation = New PdfSquareAnnotation(New RectangleF(0, 30, 80, 80))
squareannotation.Text = "SquareAnnotation"
squareannotation.InnerColor = New PdfColor(Color.Red)
 Dim border As LineBorder = New LineBorder()
border.BorderStyle = PdfBorderStyle.Solid
border.BorderWidth = 2
squareannotation.Border = border
squareannotation.Color = New PdfColor(Color.Yellow)
page.Graphics.DrawString("Square Annotation", font, brush, New PointF(0, 0))
'Add annotation to the page.
page.Annotations.Add(squareannotation)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
See Also

PdfSquareAnnotation(RectangleF, string)

Initialise the new instance of the square annotation with bounds and text.

public PdfSquareAnnotation(RectangleF rectangle, string text)

Parameters

rectangle RectangleF

Used to represent the bounds of the annotation

text string

Used to represents the text of the annotation

Examples

 //Creates a new PDF document.
 PdfDocument document = new PdfDocument();
 //Creates a new page 
 PdfPage page = document.Pages.Add();
 document.PageSettings.SetMargins(0);
 //Set the font
 PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 10f);
 PdfBrush brush = new PdfSolidBrush(System.Drawing.Color.Black);
 //Creates a new Square annotation.
 PdfSquareAnnotation squareannotation = new PdfSquareAnnotation(new RectangleF(0, 30, 80, 80),"SquareAnnotation");
 squareannotation.InnerColor = new PdfColor(Color.Red);
 squareannotation.Color = new PdfColor(Color.Yellow);
 page.Graphics.DrawString("Square Annotation", font, brush, new PointF(0, 0));
 //Add the annotation to the page.
page.Annotations.Add(squareannotation);
 //Save the document.
 document.Save("Output.pdf");
 //Close the document.
 document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Creates a new page 
Dim page As PdfPage = document.Pages.Add()
document.PageSettings.SetMargins(0)
'Set the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 10.0F)
Dim brush As PdfBrush = New PdfSolidBrush(System.Drawing.Color.Black)
'Creates a new Square annotation.
Dim squareannotation As PdfSquareAnnotation = New PdfSquareAnnotation(New RectangleF(0, 30, 80, 80),"SquareAnnotation")
squareannotation.InnerColor = New PdfColor(Color.Red)
squareannotation.Color = New PdfColor(Color.Yellow)
page.Graphics.DrawString("Square Annotation", font, brush, New PointF(0, 0))
'Add annotation to the page.
page.Annotations.Add(squareannotation)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
See Also

Properties

Border

Get or set the border style of the square annotation.

public LineBorder Border { get; set; }

Property Value

LineBorder

Examples

 //Creates a new PDF document.
 PdfDocument document = new PdfDocument();
 //Creates a new page 
 PdfPage page = document.Pages.Add();
 document.PageSettings.SetMargins(0);
 //Set the font
 PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 10f);
 PdfBrush brush = new PdfSolidBrush(System.Drawing.Color.Black);
 //Creates a new Square annotation.
 PdfSquareAnnotation squareannotation = new PdfSquareAnnotation(new RectangleF(0, 30, 80, 80));
 squareannotation.Text = "SquareAnnotation";
 squareannotation.InnerColor = new PdfColor(Color.Red);
 LineBorder border = new LineBorder();
 border.BorderStyle = PdfBorderStyle.Solid;
 border.BorderWidth = 2;
 squareannotation.Border = border;
 squareannotation.Color = new PdfColor(Color.Yellow);
 page.Graphics.DrawString("Square Annotation", font, brush, new PointF(0, 0));
 //Add the annotation to the page.
page.Annotations.Add(squareannotation);
 //Save the document.
 document.Save("Output.pdf");
 //Close the document.
 document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Creates a new page 
Dim page As PdfPage = document.Pages.Add()
document.PageSettings.SetMargins(0)
'Set the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 10.0F)
Dim brush As PdfBrush = New PdfSolidBrush(System.Drawing.Color.Black)
'Creates a new Square annotation.
Dim squareannotation As PdfSquareAnnotation = New PdfSquareAnnotation(New RectangleF(0, 30, 80, 80))
squareannotation.Text = "SquareAnnotation"
squareannotation.InnerColor = New PdfColor(Color.Red)
 Dim border As LineBorder = New LineBorder()
border.BorderStyle = PdfBorderStyle.Solid
border.BorderWidth = 2
squareannotation.Border = border
squareannotation.Color = New PdfColor(Color.Yellow)
page.Graphics.DrawString("Square Annotation", font, brush, New PointF(0, 0))
'Add annotation to the page.
page.Annotations.Add(squareannotation)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
See Also

BorderEffect

Get or set the border effect of the square annotation.

public PdfBorderEffect BorderEffect { get; set; }

Property Value

PdfBorderEffect

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Creates a new page 
PdfPage page = document.Pages.Add();
document.PageSettings.SetMargins(0);
//Set the font
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 10f);
PdfBrush brush = new PdfSolidBrush(System.Drawing.Color.Black);
//Creates a new square annotation.
PdfSquareAnnotation squareannotation = new PdfSquareAnnotation(new RectangleF(0, 30, 80, 80));
squareannotation.Text = "SquareAnnotation";
squareannotation.InnerColor = new PdfColor(Color.Red);
PdfBorderEffect borderEffect = new PdfBorderEffect();
borderEffect.Intensity=2;
borderEffect.Style = PdfBorderEffectStyle.Cloudy;
squareannotation.BorderEffect = borderEffect;
squareannotation.Color = new PdfColor(Color.Yellow);
page.Graphics.DrawString("Square Annotation", font, brush, new PointF(0, 0));
//Add the annotation to the page.
page.Annotations.Add(squareannotation);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Creates a new page 
Dim page As PdfPage = document.Pages.Add()
document.PageSettings.SetMargins(0)
'Set the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 10.0F)
Dim brush As PdfBrush = New PdfSolidBrush(System.Drawing.Color.Black)
'Creates a new square annotation.
Dim squareannotation As PdfSquareAnnotation = New PdfSquareAnnotation(New RectangleF(0, 30, 80, 80))
squareannotation.Text = "SquareAnnotation"
squareannotation.InnerColor = New PdfColor(Color.Red)
 Dim borderEffect As PdfBorderEffect()
borderEffect.Intensity=2;
borderEffect.Style = PdfBorderEffectStyle.Cloudy
squareannotation.BorderEffect = borderEffect
squareannotation.Color = New PdfColor(Color.Yellow)
page.Graphics.DrawString("Square Annotation", font, brush, New PointF(0, 0))
'Add annotation to the page.
page.Annotations.Add(squareannotation)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
See Also

Comments

Gets the annotation comments

public PdfPopupAnnotationCollection Comments { get; }

Property Value

PdfPopupAnnotationCollection

Examples

PdfDocument document = new PdfDocument();
//Creates a new page 
PdfPage page = document.Pages.Add();
document.PageSettings.SetMargins(0);
//Set the font
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 10f);
PdfBrush brush = new PdfSolidBrush(System.Drawing.Color.Black);
//Creates a new Square annotation.
PdfSquareAnnotation squareannotation = new PdfSquareAnnotation(new RectangleF(0, 30, 80, 80));
squareannotation.Text = "SquareAnnotation";
squareannotation.InnerColor = new PdfColor(Color.Red);
squareannotation.Color = new PdfColor(Color.Yellow);
page.Graphics.DrawString("Square Annotation", font, brush, new PointF(0, 0));
PdfPopupAnnotation popupComments = new PdfPopupAnnotation();
popupComments.Author = "TestAuthor";
popupComments.Text = "Test Text";
squareannotation.Comments.Add(popupComments);
//Get annotation comments
PdfPopupAnnotationCollection commentsCollection = squareannotation.Comments;
//Saves the document to disk.
document.Save("Output.pdf");
document.Close(true);
Dim document As PdfDocument = New PdfDocument
Dim page As PdfPage = document.Pages.Add
document.PageSettings.SetMargins(0)
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 10!)
Dim brush As PdfBrush = New PdfSolidBrush(System.Drawing.Color.Black)
Dim squareannotation As PdfSquareAnnotation = New PdfSquareAnnotation(New RectangleF(0, 30, 80, 80))
squareannotation.Text = "SquareAnnotation"
squareannotation.InnerColor = New PdfColor(Color.Red)
squareannotation.Color = New PdfColor(Color.Yellow)
page.Graphics.DrawString("Square Annotation", font, brush, New PointF(0, 0))
Dim popupComments As PdfPopupAnnotation = New PdfPopupAnnotation
popupComments.Author = "TestAuthor"
popupComments.Text = "Test Text"
squareannotation.Comments.Add(popupComments)
Dim commentsCollection As PdfPopupAnnotationCollection = squareannotation.Comments
'Saves the document to disk.
document.Save("Output.pdf")
document.Close(true)
See Also

ReviewHistory

Gets the annotation reviews

public PdfPopupAnnotationCollection ReviewHistory { get; }

Property Value

PdfPopupAnnotationCollection

Examples

PdfDocument document = new PdfDocument();
//Creates a new page 
PdfPage page = document.Pages.Add();
document.PageSettings.SetMargins(0);
//Set the font
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 10f);
PdfBrush brush = new PdfSolidBrush(System.Drawing.Color.Black);
//Creates a new Square annotation.
PdfSquareAnnotation squareannotation = new PdfSquareAnnotation(new RectangleF(0, 30, 80, 80));
squareannotation.Text = "SquareAnnotation";
squareannotation.InnerColor = new PdfColor(Color.Red);
squareannotation.Color = new PdfColor(Color.Yellow);
page.Graphics.DrawString("Square Annotation", font, brush, new PointF(0, 0));
//Add review state
PdfPopupAnnotation popup = new PdfPopupAnnotation();
popup.State = PdfAnnotationState.Accepted;
popup.StateModel = PdfAnnotationStateModel.Review;
popup.Text = "Hello PDF Comments";
squareannotation.ReviewHistory.Add(popup);
//Get Review history
PdfPopupAnnotationCollection reviewCollection = squareannotation.ReviewHistory;
//Saves the document to disk.
document.Save("Output.pdf");
document.Close(true);
Dim document As PdfDocument = New PdfDocument
Dim page As PdfPage = document.Pages.Add
document.PageSettings.SetMargins(0)
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 10!)
Dim brush As PdfBrush = New PdfSolidBrush(System.Drawing.Color.Black)
Dim squareannotation As PdfSquareAnnotation = New PdfSquareAnnotation(New RectangleF(0, 30, 80, 80))
squareannotation.Text = "SquareAnnotation"
squareannotation.InnerColor = New PdfColor(Color.Red)
squareannotation.Color = New PdfColor(Color.Yellow)
page.Graphics.DrawString("Square Annotation", font, brush, New PointF(0, 0))
Dim popup As PdfPopupAnnotation = New PdfPopupAnnotation
popup.State = PdfAnnotationState.Accepted
popup.StateModel = PdfAnnotationStateModel.Review
popup.Text = "Hello PDF Comments"
squareannotation.ReviewHistory.Add(popup)
Dim reviewCollection As PdfPopupAnnotationCollection = squareannotation.ReviewHistory
'Saves the document to disk.
document.Save("Output.pdf")
document.Close(true)
See Also

Methods

Initialize()

Initializes annotation object.

protected override void Initialize()
See Also

Save()

Saves an annotation.

protected override void Save()
See Also

See Also