Adding note annotation to the PDF documents is one of the best features provided by Aspose.Pdf . The beauty of Aspose.Pdf is to create complex things with less effort.
To attach a note annotation, we will again make use of Attachment class and set its AttachmentType property to AttachmentType.Note enumeration value. Then we can specify the content to display in the note using NoteContent property of Attachment class. Title of the note can also be specified by setting the NoteHeading property of Attachment class.
Moreover, if developers need to open the note when the PDF document gets opened then they can make use of IsNoteOpen property. IsNoteOpen is a boolean property that can be set to true to implement this effect.
As a reference, two different phases of a note annotation are displayed below:
|
Figure: Note annotation view when PDF document is opened |
|
Figure: Note annotation view when note is clicked |
To attach a note annotation in your PDF document like the above figure, you can follow the example given below.
Example:
[C#]
//Instantiate attachment instance
Attachment noteAttachment = new Attachment();
//Add the attachment in the paragraphs collection of the section
sec1.Paragraphs.Add(noteAttachment);
//Set the attachment type to note to make it a note annotation
noteAttachment.AttachmentType = AttachmentType.Note;
//Set the content of the note annotation
noteAttachment.NoteContent = "This is a note.";
//Set the title or heading of the note
noteAttachment.NoteHeading = "The title";
//Set the note to be opened when PDF document is opened
noteAttachment.IsNoteOpen = true;
[VB.NET]
'Instantiate attachment instance
Dim noteAttachment As Attachment = New Attachment()
'Add the attachment in the paragraphs collection of the section
sec1.Paragraphs.Add(noteAttachment)
'Set the attachment type to note to make it a note annotation
noteAttachment.AttachmentType = AttachmentType.Note
'Set the content of the note annotation
noteAttachment.NoteContent = "This is a note."
'Set the title or heading of the note
noteAttachment.NoteHeading = "The title"
'Set the note to be opened when PDF document is opened
noteAttachment.IsNoteOpen = True
[XML]
<Attachment AttachmentType="Note" IsNoteOpen="true" NoteContent="This is a note."
NoteHeading="The title">
</Attachment>
Note: The note annotation icon can be changed if desired. To change the note icon type, any of the pre-defined value of NoteIconType enumeration can be assigned to NoteIconType property of Attachment class. Different note icon types supported by Aspose.Pdf are shown below in the figure:
|