PDFiumVCL Docs

WebLink property

Dieser API-Eintrag behält Bezeichner, Signaturen, Codeblöcke und PDF-Begriffe in ihrer Originalform.
Component: TPdf  ·  Unit: PDFium
URL and bounding rectangles for an auto-detected web link on a page.

Syntax

property WebLink[PageNumber, Index: Integer]: TWebLink; // read only

Description

WebLink returns a TWebLink record for the URL detected at the specified 1-based PageNumber and 0-based Index. The record contains the Url string (typically http://, https://, or mailto:) and a Rectangles array of TPdfRectangle bounding boxes — one rectangle per visual line, since PDFium reports separate rectangles when a single URL wraps onto multiple lines.

Index ranges from 0 to WebLinkCount[PageNumber] - 1. Outside that range PDFium returns an empty record (Url is empty, Rectangles is nil). Web link detection runs lazily on the first read for a given page and is cached until the page is reloaded; reading WebLink itself is O(1) after the scan completes.

WebLink complements LinkAnnotation, which surfaces explicit /Link annotations declared by the PDF author. Use the rectangles to build click-through overlays on a custom renderer, or to highlight URLs in extracted text. The data is read-only — PDFiumVCL exposes detection results, not modification primitives. To insert real link annotations, use the FPDFPage_CreateAnnot path on the underlying Page handle.

Remarks

Example

var Link: TWebLink;
var I: Integer;
for I := 0 to Pdf1.WebLinkCount[1] - 1 do
begin
  Link := Pdf1.WebLink[1, I];
  Memo1.Lines.Add(Format('%s  (%d rects)',
    [Link.Url, Length(Link.Rectangles)]));
end;

See Also

WebLinkCount, LinkAnnotation, TPdfView.OnWebLinkClick, TPdfView.LinkOptions