property WebLink[PageNumber, Index: Integer]: TWebLink; // read only
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 es nil). La detección de enlaces web se ejecuta de forma diferida en la primera lectura de una página determinada y se almacena en caché hasta que la página se recarga; leer WebLink en sí es O(1) después de completar el análisis.
WebLink complements LinkAnnotation, which surfaces explicit
/Link anotaciones declaradas por el autor del PDF. Usa los rectángulos para construir superposiciones clicables en un renderizador personalizado o para resaltar URL en el texto extraído. Los datos son de solo lectura — PDFiumPas expone resultados de detección, no primitivas de modificación. Para insertar anotaciones de enlace reales, usa el
FPDFPage_CreateAnnot path on the underlying Page handle.
TPdfView.PageToScreen to overlay HTML or other widgets.TPdfView.OnAnnotationLinkClick and
TPdfView.OnWebLinkClick.
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;