PDFiumVCL Docs

WebLinkCount property

Component: TPdf  ·  Unit: PDFium
Number of auto-detected web URLs identified by scanning a page's text.

Syntax

property WebLinkCount[PageNumber: Integer]: Integer; // read only

Description

WebLinkCount reports the number of URL patterns PDFium discovered on the page identified by the 1-based PageNumber argument by scanning the rendered text page. Unlike LinkAnnotationCount — which counts explicit /Link annotations declared by the PDF author — WebLinkCount surfaces URLs that appear as plain text (such as https://example.com) but were not wrapped in a clickable annotation. PDFium uses pattern matching (FPDFLink_LoadWebLinks on a FPDF_TEXTPAGE) to discover http, https, mailto: and a handful of other common URI schemes.

The value is 0 when Active is False or when no URL pattern is found. Pass PageNumber in the range 1 .. PageCount. WebLinkCount drives the auto-detection layer used by TPdfView.OnWebLinkClick and the loAutoOpenURI option — both rely on the same scan results.

Use WebLink[PageNumber, Index] to retrieve a TWebLink record (the URL string plus an array of TPdfRectangle bounding boxes, one per line since a single URL can wrap). Scans are cached per page until the page is reloaded, so repeated reads of WebLinkCount are cheap; the first read for a given page does the actual scan.

Remarks

Example

var P, I: Integer;
var Link: TWebLink;
for P := 1 to Pdf1.PageCount do
  for I := 0 to Pdf1.WebLinkCount[P] - 1 do
  begin
    Link := Pdf1.WebLink[P, I];
    Memo1.Lines.Add(Link.Url);
  end;

See Also

WebLink, LinkAnnotationCount, TPdfView.OnWebLinkClick, TPdfView.LinkOptions