LinkToURL.vb
C# VB
'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''Imports System.IOImports System.DrawingImports GrapeCity.Documents.PdfImports GrapeCity.Documents.TextImports GrapeCity.Documents.Pdf.AnnotationsImports GrapeCity.Documents.Pdf.Actions
'' A simple way to create a link to an external URL,'' and associate it with a text on a page.Public Class LinkToURL Function CreatePDF(ByVal stream As Stream) As Integer Dim doc = New GcPdfDocument() Dim page = doc.NewPage() Dim g = page.Graphics
'' Draw some text that will represent the link: Dim tl = g.CreateTextLayout() tl.MarginAll = 72 tl.Append("Google google on the wall, please tell me all!", New TextFormat() With {.Font = StandardFonts.Times, .FontSize = 14}) tl.PerformLayout(True) g.DrawTextLayout(tl, PointF.Empty)
'' Add a link associated with the text area: page.Annotations.Add(New LinkAnnotation(tl.ContentRectangle, New ActionURI("http://www.google.com"))) '' '' Done: doc.Save(stream) Return doc.Pages.Count End FunctionEnd Class