LinkToURL.vb
- ''
- '' This code is part of Document Solutions for PDF demos.
- '' Copyright (c) MESCIUS inc. All rights reserved.
- ''
- Imports System.IO
- Imports System.Drawing
- Imports System.Numerics
- Imports GrapeCity.Documents.Pdf
- Imports GrapeCity.Documents.Text
- Imports GrapeCity.Documents.Drawing
- Imports GrapeCity.Documents.Pdf.Annotations
- Imports 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 Function
- End Class
-