Table of Contents

Class PdfAttachmentAnnotation

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

Represents an attachment annotation of the PDF document.

public class PdfAttachmentAnnotation : PdfFileAnnotation, INotifyPropertyChanged
Inheritance
PdfAttachmentAnnotation
Implements
Inherited Members

Examples

//Create a new PDF Document.
PdfDocument document = new PdfDocument();
//Create a new page.
PdfPage page = document.Pages.Add();
//Create a new rectangle.
RectangleF attachmentRectangle = new RectangleF(10, 40, 30, 30);
//Create a new attachment annotation.
PdfAttachmentAnnotation attachmentAnnotation = new PdfAttachmentAnnotation(attachmentRectangle, @"Input.png");
//Set the attachment icon to attachment annotation.
attachmentAnnotation.Icon = PdfAttachmentIcon.PushPin;
//Add this annotation to a new page.
page.Annotations.Add(attachmentAnnotation);
//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 a new rectangle.
Dim attachmentRectangle As New RectangleF(10, 40, 30, 30)
'Create a new attachment annotation.
Dim attachmentAnnotation As New PdfAttachmentAnnotation(attachmentRectangle, "Input.png")
'Set the attachment icon to attachment annotation.
attachmentAnnotation.Icon = PdfAttachmentIcon.PushPin
'Add this annotation to a new page.
page.Annotations.Add(attachmentAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'close the document.
document.Close(True)

Constructors

PdfAttachmentAnnotation(RectangleF, string, byte[])

public PdfAttachmentAnnotation(RectangleF rectangle, string fileName, byte[] data)

Parameters

rectangle RectangleF

The bounds of the annotation.

fileName string

A string value specifying the full path to the file to be embedded in the PDF file.

data byte[]

A byte array specifying the content of the annotation's embedded file.

Examples

//Create a new PDF Document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF attachmentBounds = new RectangleF(10, 40, 30, 30);
//Load the image as bytes
byte[] imageBytes = File.ReadAllBytes("Input.jpg");
//Create a new attachment annotation.
PdfAttachmentAnnotation attachmentAnnotation = new PdfAttachmentAnnotation(attachmentBounds, @"Input.jpg", imageBytes);
//Add this annotation to a new page.
page.Annotations.Add(attachmentAnnotation);
//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 a new rectangle
Dim attachmentBounds As New RectangleF(10, 40, 30, 30)
'Load the image as bytes
Dim imageBytes() As Byte = File.ReadAllBytes("Input.jpg")
'Create a new attachment annotation.
Dim attachmentAnnotation As New PdfAttachmentAnnotation(attachmentBounds, "Input.jpg", imageBytes)
'Add this annotation to a new page.
page.Annotations.Add(attachmentAnnotation)
'Save the  document to disk.
document.Save("Output.pdf")
'close the document
document.Close(True)

Remarks

If both FileName and FileContent are specified, the FileContent takes precedence.

See Also

PdfAttachmentAnnotation(RectangleF, string, Stream)

public PdfAttachmentAnnotation(RectangleF rectangle, string fileName, Stream stream)

Parameters

rectangle RectangleF

The bounds of the annotation.

fileName string

A string value specifying the full path to the file to be embedded in the PDF file.

stream Stream

The stream specifying the content of the annotation's embedded file.

Examples

//Create a new PDF Document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create a new rectangle.
RectangleF attachmentBounds = new RectangleF(10, 40, 30, 30);
//Load the image as stream.
FileStream stream = new FileStream(@"Input.jpg", FileMode.Open);
//Create a new attachment annotation.
PdfAttachmentAnnotation attachmentAnnotation = new PdfAttachmentAnnotation(attachmentBounds, "Input.jpg", stream);
//Add this annotation to a new page.
page.Annotations.Add(attachmentAnnotation);
//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 a new rectangle.
Dim attachmentBounds As New RectangleF(10, 40, 30, 30)
'Load the image as stream.
Dim stream As New FileStream("Input.jpg", FileMode.Open)
'Create a new attachment annotation.
Dim attachmentAnnotation As New PdfAttachmentAnnotation(attachmentBounds, "Input.jpg", stream)
'Add this annotation to a new page.
page.Annotations.Add(attachmentAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'close the document.
document.Close(True)

Remarks

If both FileName and FileContent are specified, the FileContent takes precedence.

See Also

Properties

Comments

Gets the annotation comments

public PdfPopupAnnotationCollection Comments { get; }

Property Value

PdfPopupAnnotationCollection

Examples

//Creates a new PDF Document.
 PdfDocument document = new PdfDocument();
 //Creates a new page
 PdfPage page = document.Pages.Add();
 //Creates a new rectangle
 RectangleF attachmentRectangle = new RectangleF(10, 40, 30, 30);
 //Creates a new attachment annotation.
 PdfAttachmentAnnotation attachmentAnnotation = new PdfAttachmentAnnotation(attachmentRectangle, @"logo.png");
 //Sets the attachment icon to attachment annotation.
 attachmentAnnotation.Icon = PdfAttachmentIcon.PushPin;
 //set comments
 PdfPopupAnnotation popupComments = new PdfPopupAnnotation();
 popupComments.Author = "TestAuthor";
 popupComments.Text = "Test Text";
 attachmentAnnotation.Comments.Add(popupComments);
 //Get annotation comments
 PdfPopupAnnotationCollection commentsCollection = attachmentAnnotation.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
Dim attachmentRectangle As RectangleF = New RectangleF(10, 40, 30, 30)
Dim attachmentAnnotation As PdfAttachmentAnnotation = New PdfAttachmentAnnotation(attachmentRectangle, "logo.png")
'Sets the attachment icon to attachment annotation.
attachmentAnnotation.Icon = PdfAttachmentIcon.PushPin
Dim popupComments As PdfPopupAnnotation = New PdfPopupAnnotation
popupComments.Author = "TestAuthor"
popupComments.Text = "Test Text"
attachmentAnnotation.Comments.Add(popupComments)
Dim commentsCollection As PdfPopupAnnotationCollection = attachmentAnnotation.Comments
'Saves the document to disk.
document.Save("Output.pdf")
document.Close(true)
See Also

FileName

public override string FileName { get; set; }

Property Value

string

A string value specifying the full path to the file to be embedded in the PDF file.

Examples

//Create a new PDF Document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create a new rectangle.
RectangleF attachmentBounds = new RectangleF(10, 40, 30, 30);
//Create a new attachment annotation.
PdfAttachmentAnnotation attachmentAnnotation = new PdfAttachmentAnnotation(attachmentBounds, @"Input.wav");
//Set the file name.
attachmentAnnotation.FileName = "input.wav";
//Add this annotation to a new page.
page.Annotations.Add(attachmentAnnotation);
//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 a new rectangle.
Dim attachmentRectangle As New RectangleF(10, 40, 30, 30)
'Create a new attachment annotation.
Dim attachmentAnnotation As New PdfAttachmentAnnotation(attachmentRectangle, "Input.png")
'Set the file name.
attachmentAnnotation.FileName = "input.wav"
'Add this annotation to a new page.
page.Annotations.Add(attachmentAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'close the document.
document.Close(True)
See Also

Icon

Gets or Sets the attachment's icon.

public PdfAttachmentIcon Icon { get; set; }

Property Value

PdfAttachmentIcon

A PdfAttachmentIcon enumeration member specifying the icon for the annotation when it is displayed in closed state.

Examples

//Create a new PDF Document.
PdfDocument document = new PdfDocument();
//Create a new page.
PdfPage page = document.Pages.Add();
//Create a new rectangle.
RectangleF attachmentRectangle = new RectangleF(10, 40, 30, 30);
//Create a new attachment annotation.
PdfAttachmentAnnotation attachmentAnnotation = new PdfAttachmentAnnotation(attachmentRectangle, @"Input.png");
//Set the attachment icon to attachment annotation.
attachmentAnnotation.Icon = PdfAttachmentIcon.PushPin;
//Add this annotation to a new page.
page.Annotations.Add(attachmentAnnotation);
//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 a new rectangle.
Dim attachmentRectangle As New RectangleF(10, 40, 30, 30)
'Create a new attachment annotation.
Dim attachmentAnnotation As New PdfAttachmentAnnotation(attachmentRectangle, "Input.png")
'Set the attachment icon to attachment annotation.
attachmentAnnotation.Icon = PdfAttachmentIcon.PushPin
'Add this annotation to a new page.
page.Annotations.Add(attachmentAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'close the document.
document.Close(True)
See Also

ReviewHistory

Gets the annotation reviews

public PdfPopupAnnotationCollection ReviewHistory { get; }

Property Value

PdfPopupAnnotationCollection

Examples

 //Creates a new PDF Document.
PdfDocument document = new PdfDocument();
//Creates a new page
PdfPage page = document.Pages.Add();
//Creates a new rectangle
RectangleF attachmentRectangle = new RectangleF(10, 40, 30, 30);
//Creates a new attachment annotation.
PdfAttachmentAnnotation attachmentAnnotation = new PdfAttachmentAnnotation(attachmentRectangle, @"logo.png");
//Sets the attachment icon to attachment annotation.
attachmentAnnotation.Icon = PdfAttachmentIcon.PushPin;
//set Review history
PdfPopupAnnotation popup = new PdfPopupAnnotation();
popup.State = PdfAnnotationState.Accepted;
popup.StateModel = PdfAnnotationStateModel.Review;
popup.Text = "Hello PDF Comments";
attachmentAnnotation.ReviewHistory.Add(popup);
//Get Review history
PdfPopupAnnotationCollection reviewCollection = attachmentAnnotation.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
Dim attachmentRectangle As RectangleF = New RectangleF(10, 40, 30, 30)
Dim attachmentAnnotation As PdfAttachmentAnnotation = New PdfAttachmentAnnotation(attachmentRectangle, "logo.png")
'Sets the attachment icon to attachment annotation.
attachmentAnnotation.Icon = PdfAttachmentIcon.PushPin
Dim popup As PdfPopupAnnotation = New PdfPopupAnnotation
popup.State = PdfAnnotationState.Accepted
popup.StateModel = PdfAnnotationStateModel.Review
popup.Text = "Hello PDF Comments"
attachmentAnnotation.ReviewHistory.Add(popup)
Dim reviewCollection As PdfPopupAnnotationCollection = attachmentAnnotation.ReviewHistory
'Saves the document to disk.
document.Save("Output.pdf")
document.Close(true)
See Also

Methods

Initialize()

Initializes object.

protected override void Initialize()
See Also

Save()

Saves annotation object.

protected override void Save()
See Also

See Also