How To Create Link Annotation in PDF Mosaic Library .NET

This samples shows how to add a link to a document page.

Use PDFLinkAnnotation class to add a link to page.

C# :

using PDFMosaic;
using System;

namespace LinkToPage
{
  class LinkToPage
  {
    static void Main()
    {
      PDFDocument document = new PDFDocument();
      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));
      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));

      PDFDestination destination = new PDFDestination(document.Pages[1], 200);
      PDFLinkAnnotation link = new PDFLinkAnnotation(destination, 100, 100, 80, 80);
      link.Color = new PDFColorRGB(255, 0, 0);
      document.Pages[0].Annotations.Add(link);

      PDFFont font = new PDFFont(PDFStandardFont.Helvetica, 12);
      PDFBrush brush = new PDFSolidBrush();
      document.Pages[1].Canvas.DrawString("Link target", font, brush, 100, 200);

      document.Save("LinkToPage.pdf", true);
    }
  }
}

VB.NET :

Imports PDFMosaic
Imports System

Module LinkToPage
  Sub Main()
    Dim document As New PDFDocument()
    document.Pages.Add(New PDFPage(PDFPaperFormat.A4))
    document.Pages.Add(New PDFPage(PDFPaperFormat.A4))

    Dim destination As New PDFDestination(document.Pages(1), 200)
    Dim link As New PDFLinkAnnotation(destination, 100, 100, 80, 80)
    link.Color = New PDFColorRGB(255, 0, 0)
    document.Pages(0).Annotations.Add(link)

    Dim font As New PDFFont(PDFStandardFont.Helvetica, 12)
    Dim brush As New PDFSolidBrush()
    document.Pages(1).Canvas.DrawString("Link target", font, brush, 100, 200)

    document.Save("LinkToPage.pdf", True)
  End Sub
End Module