PDF Mosaic: How to create text annotations


Home       Features       Download       Tutorial       Version History       License       Source Code

 

This sample shows how to add text annotations to your PDF document.


 

C# :

using PDFMosaic;
using System;
 
namespace TextAnnotations
{
  class TextAnnotations
  {
    static void Main()
    {
      PDFDocument document = new PDFDocument();
      PDFPage page = new PDFPage(PDFPaperFormat.A4);
 
      PDFTextAnnotation textAnnotation1 = new PDFTextAnnotation(40, 40);
      textAnnotation1.Icon = PDFTextAnnotationIcon.Comment;
      textAnnotation1.Contents = "Comment";
      page.Annotations.Add(textAnnotation1);
 
      PDFTextAnnotation textAnnotation2 = new PDFTextAnnotation(40, 65);
      textAnnotation2.Open = true;
      textAnnotation2.Color = new PDFColorRGB(255, 0, 0);
      textAnnotation2.Contents = "Text text text";
      page.Annotations.Add(textAnnotation2);
 
      PDFTextAnnotation textAnnotation3 = new PDFTextAnnotation(40, 90);
      textAnnotation3.Icon = PDFTextAnnotationIcon.Help;
      textAnnotation3.Open = true;
      textAnnotation3.Color = new PDFColorRGB(0, 0, 255);
      textAnnotation3.Contents = "Help";
      page.Annotations.Add(textAnnotation3);
 
      document.Pages.Add(page);
      document.Save("TextAnnotations.pdf", true);
    }
  }
}

 

Visial Basic.NET :

Imports PDFMosaic
Imports System
 
Module TextAnnotations
  Sub Main()
    Dim document As New PDFDocument()
    Dim page As New PDFPage(PDFPaperFormat.A4)
 
    Dim textAnnotation1 As New PDFTextAnnotation(40, 40)
    textAnnotation1.Icon = PDFTextAnnotationIcon.Comment
    textAnnotation1.Contents = "Comment"
    page.Annotations.Add(textAnnotation1)
 
    Dim textAnnotation2 As New PDFTextAnnotation(40, 65)
    textAnnotation2.Open = True
    textAnnotation2.Color = New PDFColorRGB(255, 0, 0)
    textAnnotation2.Contents = "Text text text"
    page.Annotations.Add(textAnnotation2)
 
    Dim textAnnotation3 As New PDFTextAnnotation(40, 90)
    textAnnotation3.Icon = PDFTextAnnotationIcon.Help
    textAnnotation3.Open = True
    textAnnotation3.Color = New PDFColorRGB(0, 0, 255)
    textAnnotation3.Contents = "Help"
    page.Annotations.Add(textAnnotation3)
 
    document.Pages.Add(page)
    document.Save("TextAnnotations.pdf", True)
  End Sub
End Module

 


Home       Features       Download       Tutorial       Version History       License       Source Code