Add Sticky Note to Existing Pdf Document using Aspose.PDF for .NET - Add Annotations

I have a requirement to open an existing pdf document and add a sticky note. I am not seeing a full, solid example of how to do this.


Can you point me in the right direction?

I have attached a simple example created with Acrobat of what I am after.

Hi there,

Thanks for your inquiry. TextAnnotaiton is used for Sticky Note(annotation), please check documentation link for details and following sample code for the purpose. It will help you to accomplish the task.

// Open document
Document pdfDocument = new Document(@"C:\Users\Home\Downloads\Here+is+a+blank+pdf.pdf");

// Create annotation
TextAnnotation textAnnotation = new TextAnnotation(
    pdfDocument.Pages[1], 
    new Aspose.Pdf.Rectangle(200, 400, 400, 600)
);

textAnnotation.Title = "Sample Annotation Title";
textAnnotation.Subject = "Sticky Note Subject";
textAnnotation.State = AnnotationState.Accepted;
textAnnotation.Contents = "Sample contents of stick note";
textAnnotation.Open = false;
textAnnotation.Icon = TextIcon.Comment;
textAnnotation.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Yellow);

Border border = new Border(textAnnotation);
border.Width = 5;
border.Dash = new Dash(1, 1);

textAnnotation.Border = border;
textAnnotation.Rect = new Aspose.Pdf.Rectangle(200, 400, 400, 600);

// Add annotation in the annotations collection of the page
pdfDocument.Pages[1].Annotations.Add(textAnnotation);

// Save output file
pdfDocument.Save(myDir + "Here+is+a+blank+pdf_output.pdf");

Please feel free to contact us for any further assistance.

Best Regards,