The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.

How to: Add a Link to URI

  • 2 min to read
Important

You require a license to the DevExpress Office File API or DevExpress Universal Subscription to use these examples in production code. Refer to the DevExpress Subscription page for pricing information.

This example shows how to add a hyperlink to a URI using the PdfGraphics.AddLinkToUri method.

Imports System
Imports DevExpress.Pdf
Imports System.Drawing

Namespace AddLinkToUri
    Friend Class Program
        Shared Sub Main(ByVal args() As String)

            Using processor As New PdfDocumentProcessor()

                ' Create an empty document.
                processor.CreateEmptyDocument("..\..\Result.pdf")

                ' Create and draw graphics.
                Using graphics As PdfGraphics = processor.CreateGraphics()
                    DrawGraphics(graphics)

                    ' Create a link to URI specifying link area and URI.
                    graphics.AddLinkToUri(New RectangleF(310, 150, 180, 15), New Uri("https://www.devexpress.com"))

                    ' Render a page with graphics.
                    processor.RenderNewPage(PdfPaperSize.Letter, graphics)
                End Using
            End Using
        End Sub

        Private Shared Sub DrawGraphics(ByVal graphics As PdfGraphics)

            ' Draw a text line on the page. 
            Using font As New Font("Arial", 10)
                Dim blue As SolidBrush = CType(Brushes.Blue, SolidBrush)
                graphics.DrawString("https://www.devexpress.com", font, blue, 310, 150)
            End Using
        End Sub
    End Class
End Namespace
See Also