PDF Mosaic: How to create polygon annotation


Home       Features       Download       Tutorial       Version History       License       Source Code

 

This sample shows how to polygon annotation to your PDF document.


 

C# :

using PDFMosaic;
using System;
using System.Drawing;
 
namespace MarkupAnnotations
{
  class MarkupAnnotations
  {
    static void Main()
    {
      PDFDocument document = new PDFDocument();
      PDFPage page = new PDFPage(PDFPaperFormat.A4);
 
      PointF[] pt = { new PointF(30, 70), new PointF(110, 70), new PointF(45, 110), new PointF(70, 45),
             new PointF(90, 110), new PointF(30, 70)};
      PDFPointsArray points = new PDFPointsArray(pt);
      PDFPolygonAnnotation polygonAnnotation = new PDFPolygonAnnotation(points);
      polygonAnnotation.Color = new PDFColorRGB(255, 200, 0);
      polygonAnnotation.BackgroundColor = new PDFColorRGB(255, 255, 0);
      page.Annotations.Add(polygonAnnotation);
 
      document.Pages.Add(page);
      document.Save("PolygonAnnotation.pdf", true);
    }
  }
}

 

Visial Basic.NET :

Imports PDFMosaic
Imports System
Imports System.Drawing
 
Module MarkupAnnotations
  Sub Main()
    Dim document As New PDFDocument()
    Dim page As New PDFPage(PDFPaperFormat.A4)
 
    Dim pt As PointF() = New PointF(5) {New PointF(30, 70), New PointF(110, 70), New PointF(45, 110), New   PointF(70, 45), New PointF(90, 110), New PointF(30, 70)}
    Dim points As New PDFPointsArray(pt)
    Dim polygonAnnotation As New PDFPolygonAnnotation(points)
    polygonAnnotation.Color = New PDFColorRGB(255, 200, 0)
    polygonAnnotation.BackgroundColor = New PDFColorRGB(255, 255, 0)
    page.Annotations.Add(polygonAnnotation)
 
    document.Pages.Add(page)
    document.Save("PolygonAnnotation.pdf", True)
  End Sub
End Module

 


Home       Features       Download       Tutorial       Version History       License       Source Code