property WebLinkCount[PageNumber: Integer]: Integer; // read only
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.
LinkAnnotationCount and a
non-zero WebLinkCount for the same URL.TPdfView.OnWebLinkClick and set the Handled
parameter to True.
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;