Hi Nigel,
thank you for reply. I'd tried the above code without success before opening this thread. Meanwhile I solved the ScrToCharIndex coordinates problem by processing the file in background by a temporary TImageEnView object using the following code:
memo1.Clear;
ImageEnView1 := TImageEnView.Create(Self);
try
ImageEnView1.PdfViewer.Enabled := True;
ImageEnView1.PdfViewer.LoadFromFile(path);
s := InputBox('Find', 'search term', '');
ImageEnView1.PdfViewer.Find(s, False, False, False, False, False);
while ImageEnView1.PdfViewer.FindNext( wordIdx, wordLen, False, False ) do
rects := rects + ImageEnView1.PdfViewer.GetTextRects( wordIdx, wordLen );
for i := Low(rects) to High(rects) do
begin
CharIndex := ImageEnView1.PdfViewer.ScrToCharIndex(dstX, rects[i].Top, 2.0, 1.0);
ImageEnView1.PdfViewer.CharIndexToWord(CharIndex, TextIndex, TextLength);
memo1.Lines.Add(ImageEnView1.PdfViewer.GetText(CharIndex, TextLength));
end;
finally
ImageEnView1.Free;
end;
Comparing the coordinates with their relative page position created an issue: ImageEnView1.PdfViewer.PageWidth <> ImageEnView1.PdfViewer.CurrentPage.Width
ImageEnView1.PdfViewer.PageWidth returns the correct value.
Al