LinkToURL.vb
'' 完毕:
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

'' 创建外部 URL 链接的简单方法,
'' 并将其与页面上的文本相关联。
Public Class LinkToURL
    Function CreatePDF(ByVal stream As Stream) As Integer
        Dim doc = New GcPdfDocument()
        Dim page = doc.NewPage()
        Dim g = page.Graphics

        '' 绘制一些代表链接的文本:
        Dim tl = g.CreateTextLayout()
        tl.MarginAll = 72
        tl.Append("墙上谷歌谷歌,请告诉我一切!",
                  New TextFormat() With {.Font = StandardFonts.Times, .FontSize = 14})
        tl.PerformLayout(True)
        g.DrawTextLayout(tl, PointF.Empty)

        '' 添加与文本区域关联的链接:
        page.Annotations.Add(New LinkAnnotation(tl.ContentRectangle, New ActionURI("http://www.google.com")))
        ''
        '' 完毕:
        doc.Save(stream)
        Return doc.Pages.Count
    End Function
End Class