Table of Contents

Class PdfWebLink

Namespace
nebulae.dotPDFium
Assembly
dotPDFium.dll

Represents a web link within a PDF document, providing access to its associated text range, URL, and bounding rectangles.

public sealed class PdfWebLink
Inheritance
PdfWebLink
Inherited Members

This class allows users to retrieve information about a web link in a PDF, such as its text range, URL, and the rectangular regions that define its clickable area. Instances of this class are typically obtained through a parent PdfPageText object.

Methods

Retrieves the rectangle at the specified index for the current link.

public FsRect GetRect(int rectIndex)

Parameters

rectIndex int

The zero-based index of the rectangle to retrieve.

Returns

FsRect

An FsRect representing the rectangle's boundaries, defined by its left, top, right, and bottom coordinates.

Exceptions

dotPDFiumException

Thrown if the rectangle cannot be retrieved for the specified rectIndex.

Gets the number of rectangular areas associated with the current link annotation.

public int GetRectCount()

Returns

int

The total number of rectangular areas that define the clickable regions of the link annotation. Returns 0 if no rectangles are associated with the link.

This method retrieves the count of rectangles that represent the clickable regions of a link annotation in a PDF document. Each rectangle corresponds to a distinct clickable area.

Retrieves a collection of rectangles currently managed by the system.

public IEnumerable<FsRect> GetRects()

Returns

IEnumerable<FsRect>

An IEnumerable<T> of FsRect objects representing the rectangles. The collection will be empty if no rectangles are available.

Each rectangle in the collection is retrieved lazily as the enumeration progresses. This method is suitable for scenarios where the number of rectangles is large or unknown, as it avoids loading all rectangles into memory at once.

Retrieves the start position and length of the text range associated with the current web link.

public (int Start, int Length) GetTextRange()

Returns

(int Start, int Length)

A tuple containing the start position and length of the text range:

  • Start: The zero-based starting position of the text range.
  • Length: The number of characters in the text range.

Exceptions

dotPDFiumException

Thrown if the text range cannot be retrieved due to an internal error.

Retrieves the URL associated with the current link object.

public string GetUrl()

Returns

string

A string containing the URL of the link. Returns an empty string if no URL is available.

The returned URL is trimmed of any trailing null characters. This method allocates unmanaged memory to retrieve the URL and ensures proper cleanup of resources.