menu

UWP

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class PdfRectangleAnnotation - UWP API Reference | Syncfusion

    Show / Hide Table of Contents

    Class PdfRectangleAnnotation

    Represents a PDF rectangle annotation

    Inheritance
    System.Object
    PdfAnnotation
    PdfSquareAnnotation
    PdfRectangleAnnotation
    Implements
    IPdfWrapper
    System.ComponentModel.INotifyPropertyChanged
    Inherited Members
    PdfAnnotation.AnnotationFlags
    PdfAnnotation.Author
    PdfAnnotation.Bounds
    PdfAnnotation.CalculateBounds(RectangleF, PdfPage, PdfLoadedPage)
    PdfAnnotation.CalculateTemplateBounds(RectangleF, PdfPageBase, PdfTemplate)
    PdfAnnotation.CalculateTemplateBounds(RectangleF, PdfPageBase, PdfTemplate, Boolean)
    PdfAnnotation.CalculateTemplateBounds(RectangleF, PdfPageBase, PdfTemplate, Boolean, PdfGraphics)
    PdfAnnotation.CheckFlatten()
    PdfAnnotation.Color
    PdfAnnotation.Flatten
    PdfAnnotation.FlattenPopUps
    PdfAnnotation.InnerColor
    PdfAnnotation.IPdfWrapper.Element
    PdfAnnotation.Layer
    PdfAnnotation.Location
    PdfAnnotation.ModifiedDate
    PdfAnnotation.Name
    PdfAnnotation.Opacity
    PdfAnnotation.Page
    PdfAnnotation.PdfTag
    PdfAnnotation.PropertyChanged
    PdfAnnotation.Rotate
    PdfAnnotation.SetAppearance(Boolean)
    PdfAnnotation.SetValues(String, String)
    PdfAnnotation.Size
    PdfAnnotation.Subject
    PdfAnnotation.Text
    PdfSquareAnnotation.Border
    PdfSquareAnnotation.BorderEffect
    Namespace: Syncfusion.Pdf.Interactive
    Assembly: Syncfusion.Pdf.UWP.dll
    Syntax
    public class PdfRectangleAnnotation : PdfSquareAnnotation, IPdfWrapper, INotifyPropertyChanged
    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 Rectangle annotation.
    RectangleF rectannot = new RectangleF(0, 30, 100, 50);
    PdfRectangleAnnotation rectangleannotation = new PdfRectangleAnnotation(rectannot, "RectangleAnnotation");
    rectangleannotation.InnerColor = new PdfColor(Color.Red);
    rectangleannotation.Color = new PdfColor(Color.Yellow);
    page.Graphics.DrawString("Rectangle Annotation", font, brush, new PointF(0, 0));
    //Add the annotation to the page
    page.Annotations.Add(rectangleannotation);
    //Save the documnet.
    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 Rectangle annotation.
    Dim rectannot As RectangleF = New RectangleF(0, 30, 100, 50)
    Dim rectangleannotation As PdfRectangleAnnotation = New PdfRectangleAnnotation(rectannot, "RectangleAnnotation")
    rectangleannotation.InnerColor = New PdfColor(Color.Red)
    rectangleannotation.Color = New PdfColor(Color.Yellow)
    page.Graphics.DrawString("Rectangle Annotation", font, brush, New PointF(0, 0))
    'Add the annotation to the page
    page.Annotations.Add(rectangleannotation)
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)

    Constructors

    PdfRectangleAnnotation(RectangleF, String)

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

    Declaration
    public PdfRectangleAnnotation(RectangleF rectangle, string text)
    Parameters
    Type Name Description
    System.Drawing.RectangleF rectangle

    Used to represent the bounds of the annotation

    System.String text

    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 Rectangle annotation.
    RectangleF rectannot = new RectangleF(0, 30, 100, 50);
    PdfRectangleAnnotation rectangleannotation = new PdfRectangleAnnotation(rectannot, "RectangleAnnotation");
    rectangleannotation.InnerColor = new PdfColor(Color.Red);
    rectangleannotation.Color = new PdfColor(Color.Yellow);
    page.Graphics.DrawString("Rectangle Annotation", font, brush, new PointF(0, 0));
    //Add the annotation to the page
    page.Annotations.Add(rectangleannotation);
    //Save the documnet.
    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 Rectangle annotation.
    Dim rectannot As RectangleF = New RectangleF(0, 30, 100, 50)
    Dim rectangleannotation As PdfRectangleAnnotation = New PdfRectangleAnnotation(rectannot, "RectangleAnnotation")
    rectangleannotation.InnerColor = New PdfColor(Color.Red)
    rectangleannotation.Color = New PdfColor(Color.Yellow)
    page.Graphics.DrawString("Rectangle Annotation", font, brush, New PointF(0, 0))
    'Add the annotation to the page
    page.Annotations.Add(rectangleannotation)
    'Save the document.
    document.Save("Output.pdf")
    'Close the document.
    document.Close(True)
    See Also
    PdfDocument
    PdfPage
    PdfFont

    Properties

    Comments

    Gets the annotation comments

    Declaration
    public PdfPopupAnnotationCollection Comments { get; }
    Property Value
    Type
    PdfPopupAnnotationCollection
    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 Rectangle annotation.
    RectangleF rectannot = new RectangleF(0, 30, 100, 50);
    PdfRectangleAnnotation rectangleannotation = new PdfRectangleAnnotation(rectannot, "RectangleAnnotation");
    rectangleannotation.InnerColor = new PdfColor(Color.Red);
    rectangleannotation.Color = new PdfColor(Color.Yellow);
    page.Graphics.DrawString("Rectangle Annotation", font, brush, new PointF(0, 0));
    //Add the annotation to the page
    PdfPopupAnnotation popupComments = new PdfPopupAnnotation();
    popupComments.Author = "TestAuthor";
    popupComments.Text = "Test Text";
    rectangleannotation.Comments.Add(popupComments);
    //Get annotation comments
    PdfPopupAnnotationCollection commentsCollection = rectangleannotation.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 rectannot As RectangleF = New RectangleF(0, 30, 100, 50)
    Dim rectangleannotation As PdfRectangleAnnotation = New PdfRectangleAnnotation(rectannot, "RectangleAnnotation")
    rectangleannotation.InnerColor = New PdfColor(Color.Red)
    rectangleannotation.Color = New PdfColor(Color.Yellow)
    page.Graphics.DrawString("Rectangle Annotation", font, brush, New PointF(0, 0))
    Dim popupComments As PdfPopupAnnotation = New PdfPopupAnnotation
    popupComments.Author = "TestAuthor"
    popupComments.Text = "Test Text"
    rectangleannotation.Comments.Add(popupComments)
    Dim commentsCollection As PdfPopupAnnotationCollection = rectangleannotation.Comments
    'Saves the document to disk.
    document.Save("Output.pdf")
    document.Close(true)

    ReviewHistory

    Gets the annotation reviews

    Declaration
    public PdfPopupAnnotationCollection ReviewHistory { get; }
    Property Value
    Type
    PdfPopupAnnotationCollection
    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 Rectangle annotation.
     RectangleF rectannot = new RectangleF(0, 30, 100, 50);
     PdfRectangleAnnotation rectangleannotation = new PdfRectangleAnnotation(rectannot, "RectangleAnnotation");
     rectangleannotation.InnerColor = new PdfColor(Color.Red);
     rectangleannotation.Color = new PdfColor(Color.Yellow);
     page.Graphics.DrawString("Rectangle Annotation", font, brush, new PointF(0, 0));
     //Add the annotation to the page
     // Add review state
     PdfPopupAnnotation popup = new PdfPopupAnnotation();
     popup.State = PdfAnnotationState.Accepted;
     popup.StateModel = PdfAnnotationStateModel.Review;
     popup.Text = "Hello PDF Comments";
     rectangleannotation.ReviewHistory.Add(popup);
     //Get Review history
     PdfPopupAnnotationCollection reviewCollection = rectangleannotation.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 rectannot As RectangleF = New RectangleF(0, 30, 100, 50)
    Dim rectangleannotation As PdfRectangleAnnotation = New PdfRectangleAnnotation(rectannot, "RectangleAnnotation")
    rectangleannotation.InnerColor = New PdfColor(Color.Red)
    rectangleannotation.Color = New PdfColor(Color.Yellow)
    page.Graphics.DrawString("Rectangle 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"
    rectangleannotation.ReviewHistory.Add(popup)
    Dim reviewCollection As PdfPopupAnnotationCollection = rectangleannotation.ReviewHistory
    'Saves the document to disk.
    document.Save("Output.pdf")
    document.Close(true)

    Methods

    Initialize()

    Initializes annotation object.

    Declaration
    protected override void Initialize()
    Overrides
    PdfSquareAnnotation.Initialize()

    Save()

    Saves an annotation.

    Declaration
    protected override void Save()
    Overrides
    PdfSquareAnnotation.Save()

    Implements

    IPdfWrapper
    System.ComponentModel.INotifyPropertyChanged

    Extension Methods

    DateTimeExtension.ToDateTime(Object)

    See Also

    PdfDocument
    PdfPage
    PdfFont
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved