<< Click to Display Table of Contents >> Navigation: Tasks > Draw Shapes / Text objects on PDF > VCL: AddHighlightAnnotationForText |
Using this function it is possible to not only find text but also to apply highlight draw objects to the found text.
procedure TWPViewPDF.AddHighlightAnnotationForText(
s : string;
Color : TColor;
Alpha : Integer = 255
);
var b : Boolean;
page, x,y,w,h : Integer;
begin
b := false;
try
command(COMPDF_BEGINUPDATE);
while FindText(s, false, b, true)>=0 do
begin
b := true;
page := command(COMPDF_FindGetXYWH, 10);
if page>=0 then
begin
x := command(COMPDF_FindGetXYWH, 11);
y := command(COMPDF_FindGetXYWH, 12);
w := command(COMPDF_FindGetXYWH, 13);
h := command(COMPDF_FindGetXYWH, 14);
AddHighlightRect(page, x,y,w,h, Color,
[wpAsAnnot,wpAnnotAtFoundText], Alpha);
end
else break;
end;
finally
command(COMPDF_ENDUPDATE, 2);
end;
end;