Skip to main content

Link

Version: 12.0

cete.dynamicpdf.pageelements.link

Represents a link with a destination or action.

public class Link : TaggablePageElement, IAnnotation, IArea, ICoordinate, ISerializable
Public Class Link
Inherits TaggablePageElement
Implements IAnnotation, IArea, ICoordinate, ISerializable

Inheritance: Object → PageElement → TaggablePageElement → Link

Implements: IAnnotation, IArea, ICoordinate, ISerializable

Derived: AutoLink

Licensing Info​

This class is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Examples​

The following example will place a label on the PDF then create a link at that location that links to a webpage.

Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements

Module MyModule

Sub Main()

' Create a PDF Document
Dim MyDocument As Document = New Document

' Create a Page and add it to the document
Dim MyPage As Page = New Page
MyDocument.Pages.Add(MyPage)

Dim MyText As String = "This is a link to mydomain.com"
Dim MyFont As Font = Font.Helvetica

' Create the link's label
Dim MyLabel As Label = New Label(MyText, 50, 50, 400, 20, MyFont, 18, _
RgbColor.Blue)
MyLabel.Underline = True

' Set the action then create the link
Dim action As UrlAction = New UrlAction("http://www.mydomain.com")
Dim MyLink As Link = New Link(50, 50, MyFont.GetTextWidth(MyText, 18), _
20, Action)

' Add the label and the link to the page
MyPage.Elements.Add(MyLabel)
MyPage.Elements.Add(MyLink)

' Save the PDF
MyDocument.Draw("C:\MyDocument.pdf")

End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;

public class Example
{
public static void CreatePDF(string outputPath)
{
// Create a PDF Document
Document document = new Document();

// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add( page );

string text = "This is a link to mydomain.com";
Font font = Font.Helvetica;

// Create the link's label
Label label = new Label( text, 50, 50, 400, 20, font, 18, RgbColor.Blue );
label.Underline = true;

// Set the action then create the link
UrlAction action = new UrlAction( "http://www.mydomain.com" );
Link link = new Link( 50, 50, font.GetTextWidth( text, 18 ), 20, action );

// Add the label and the link to the page
page.Elements.Add( label );
page.Elements.Add( link );

// Save the PDF
document.Draw( outputPath );
}
}

Remarks​

This class can be used to place links on the PDF.

NOTE: This page element cannot be used within a table cell, or transformation group.

Constructors​

Link(Single, Single, Single, Single, Action)​

Initializes a new instance of the Link class.

public Link(float x, float y, float width, float height, Action action)
Public Sub New (x As Single, y As Single, width As Single, height As Single, action As Action)

Parameters​

X coordinate of the link.

Y coordinate of the link.

Width of the link.

Height of the link.

Action or destination of the link.

Licensing Info​

This constructor is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Properties​

Action​

Gets the Action to be taken by the link.

public Action Action { get; }
Public Property Action As Action

Property Value​

Action

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

AlternateDescription​

Gets or sets the alternate description of the link.

public string AlternateDescription { get; set; }
Public Property AlternateDescription As String

Property Value​

String

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Height​

Gets or sets the height of the link.

public float Height { get; set; }
Public Property Height As Single

Property Value​

Single

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

ID​

Gets or sets the ID of the page element. (Inherited from PageElement)

public string ID { get; set; }
Public Property ID As String

Property Value​

String

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

IgnoreMargins​

Gets or sets ignore margin property. Setting false will consider the margin while placing the page element based on the RelativeTo property. (Inherited from PageElement)

public bool IgnoreMargins { get; set; }
Public Property IgnoreMargins As Boolean

Property Value​

Boolean

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Examples​

The following example will place the Label in the top-left of the page with IgnoreMargin

using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;

public class Example
{
public static void CreatePDF(string outputPath)
{
// Create a PDF Document
Document document = new Document();

// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add(page); // Create an Label and place it in page top left with margin ignored
Label label = new Label("I am placed in Page top left with margin ignored", 0, 0, 160, 30);
label.RelativeTo = RelativeTo.TopLeft;
label.IgnoreMargin=true; page.Elements.Add(label);

// Save the PDF
document.Draw(outputPath);
}
}

RelativeTo​

Gets and sets placement of the page element on the page. (Inherited from PageElement)

public RelativeTo RelativeTo { get; set; }
Public Property RelativeTo As RelativeTo

Property Value​

RelativeTo

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Examples​

The following example will place the Label in the top-left of the page.

using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;

public class Example
{
public static void CreatePDF(string outputPath)
{
// Create a PDF Document
Document document = new Document();

// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add(page); // Create an Label and place it in page top left with margin
Label label = new Label("I am placed in Page top left with margin.", 0, 0, 160, 30);
label.RelativeTo = RelativeTo.TopLeft;
page.Elements.Add(label);

// Save the PDF
document.Draw(outputPath);
}
}

Tag​

Gets or sets the structure element of the link.

public Tag Tag { get; set; }
Public Property Tag As Tag

Property Value​

Tag

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

TagOrder​

Gets or sets the tag order of the taggable element. (Inherited from TaggablePageElement)

public int TagOrder { get; set; }
Public Property TagOrder As Int32

Property Value​

Int32

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Width​

Gets or sets the width of the link.

public float Width { get; set; }
Public Property Width As Single

Property Value​

Single

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

X​

Gets or sets the X coordinate of the link.

public float X { get; set; }
Public Property X As Single

Property Value​

Single

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Y​

Gets or sets the Y coordinate of the link.

public float Y { get; set; }
Public Property Y As Single

Property Value​

Single

Licensing Info​

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Methods​

Draw(PageWriter)​

Draws the link to the given PageWriter object.

public void Draw(PageWriter writer)
Sub Draw(writer As PageWriter)

Parameters​

PageWriter object to receive the link's output.

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

DrawAnnotation(DocumentWriter)​

Draws the link to the given DocumentWriter object.

public void DrawAnnotation(DocumentWriter writer)
Sub DrawAnnotation(writer As DocumentWriter)

Parameters​

DocumentWriter object to receive the link's output.

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Equals(Object)​

Determines whether the specified Object is equal to the current Object . (Inherited from Object)

public bool Equals(Object obj)
Function Equals(obj As Object) As Boolean

Parameters​

The Object to compare with the current Object .

Returns​

true if the specified Object is equal to the current Object ; otherwise, false.

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

GetHashCode()​

Serves as a hash function for a particular type. (Inherited from Object)

public int GetHashCode()
Function GetHashCode() As Integer

Returns​

A hash code for the current Object .

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

GetType()​

Gets the Type of the current instance. (Inherited from Object)

public Type GetType()
Function GetType() As Type

Returns​

The Type instance that represents the exact runtime type of the current instance.

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

ToString()​

Returns a String that represents the current Object . (Inherited from Object)

public string ToString()
Function ToString() As String

Returns​

A String that represents the current Object .

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

See Also​

ceTe.DynamicPDF.PageElements