All code samples

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);

//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

//write the PDF document to the disk
const string fileName = @"..\..\addnote.pdf";
using (FileStream file = new FileStream(fileName, FileMode.Create, FileAccess.Write))
        Dim document As New Document()
        Dim page As New Page(PageSize.Letter)

        Dim note As New Note(300, 300, 10, 10)
        note.Text = "This page is empty."
        note.IconName = "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)
        End Using

The result:

PDF With Note Added

Relevant products