This sample shows how to add text annotations (sticky notes) to your PDF document using PdfPage.AddTextAnnotation(..) method.
AddTextAnnotation method returns an instance of PdfTextAnnotation class.
using System.Diagnostics; namespace BitMiracle.Docotic.Pdf.Samples { public static class Annotations { public static void Main() { // NOTE: // When used in trial mode, the library imposes some restrictions. // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx // for more information. PdfDocument pdf = new PdfDocument(); PdfPage page = pdf.Pages[0]; const string content = "Lorem ipsum dolor sit amet, consectetur adipisicing elit"; PdfTextAnnotation textAnnotation = page.AddTextAnnotation(10, 50, "Docotic.Pdf Samples", content); textAnnotation.Icon = PdfTextAnnotationIcon.Comment; textAnnotation.Opened = true; string pathToFile = "Annotations.pdf"; pdf.Save(pathToFile); pdf.Dispose(); Process.Start(pathToFile); } } }
Imports System.Diagnostics Imports System.IO Imports BitMiracle.Docotic.Pdf Namespace BitMiracle.Docotic.Pdf.Samples Public NotInheritable Class Annotations Public Shared Sub Main() ' NOTE: ' When used in trial mode, the library imposes some restrictions. ' Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx ' for more information. Dim pdf As New PdfDocument() Dim page As PdfPage = pdf.Pages(0) Const content As String = "Lorem ipsum dolor sit amet, consectetur adipisicing elit" Dim textAnnotation As PdfTextAnnotation = page.AddTextAnnotation(10, 50, "Docotic.Pdf Samples", content) textAnnotation.Icon = PdfTextAnnotationIcon.Comment textAnnotation.Opened = True Dim pathToFile As String = "Annotations.pdf" pdf.Save(pathToFile) pdf.Dispose() Process.Start(pathToFile) End Sub End Class End Namespace
