PdfAttachmentAnnotation Class
Represents an attachment annotation of the PDF document.
Implements
Inherited Members
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfAttachmentAnnotation : PdfFileAnnotation, IPdfWrapper, INotifyPropertyChanged
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)
Declaration
public PdfAttachmentAnnotation(RectangleF rectangle, string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.RectangleF | rectangle | The bounds of the annotation. |
System.String | fileName | 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.jpg");
//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)
'Create a new attachment annotation.
Dim attachmentAnnotation As New PdfAttachmentAnnotation(attachmentBounds, "Input.jpg")
'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
PdfAttachmentAnnotation(RectangleF, String, Byte[])
Declaration
public PdfAttachmentAnnotation(RectangleF rectangle, string fileName, byte[] data)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.RectangleF | rectangle | The bounds of the annotation. |
System.String | fileName | A string value specifying the full path to the file to be embedded in the PDF file. |
System.Byte[] | data | A byte array specifying the content of the annotation's embedded file. |
Remarks
If both FileName and FileContent are specified, the FileContent takes precedence.
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)
See Also
PdfAttachmentAnnotation(RectangleF, String, Stream)
Declaration
public PdfAttachmentAnnotation(RectangleF rectangle, string fileName, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.RectangleF | rectangle | The bounds of the annotation. |
System.String | fileName | A string value specifying the full path to the file to be embedded in the PDF file. |
System.IO.Stream | stream | The stream specifying the content of the annotation's embedded file. |
Remarks
If both FileName and FileContent are specified, the FileContent takes precedence.
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)
See Also
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();
//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)
FileName
Declaration
public override string FileName { get; set; }
Property Value
Type | Description |
---|---|
System.String | A string value specifying the full path to the file to be embedded in the PDF file. |
Overrides
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.
Declaration
public PdfAttachmentIcon Icon { get; set; }
Property Value
Type | Description |
---|---|
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
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();
//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)
Methods
Initialize()
Initializes object.
Declaration
protected override void Initialize()
Overrides
Save()
Saves annotation object.
Declaration
protected override void Save()