Add a note to PDF
Add a note to PDF
This code sample shows how to add a note to a PDF document.
The note pops up whenever you mouse-over it, and it will then display the note text.
//create new document
Document document = new Document();
//crate a page and add to the document
Page page = new Page(PageSize.Letter);
document.Pages.Add(page);
//create a note
Note note = new Note(100, 600, 20, 20)
{
Text = "This page is empty.",
IconName = "Note"
};
//create a popup and assign it to the note
Popup popup = new Popup(140, 500, 200, 100) { Open = true };
note.Popup = popup;
//add the note to the page
page.Markups.Add(note);
//write the PDF document to the disk
const string fileName = @"..\..\addnote.pdf";
using (FileStream file = new FileStream(fileName, FileMode.Create, FileAccess.Write))
{
document.Write(file);
}
Dim document As New Document()
Dim page As New Page(PageSize.Letter)
document.Pages.Add(page)
Dim note As New Note(300, 300, 10, 10)
note.Text = "This page is empty."
note.IconName = "Note"
page.Markups.Add(note)
Dim popup As New Popup(320, 350, 200, 100)
popup.Open = True
note.Popup = popup
Using file As New FileStream("..\..\addnote.pdf", FileMode.Create, FileAccess.Write)
document.Write(file)
End Using
The result: