get encircled text contained under annotation rectangle ?

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

miromr
User
Posts: 59
Joined: Sat May 09, 2009 3:05 pm

get encircled text contained under annotation rectangle ?

Post by miromr »

Hi,
is possible get encircled text contained under annotation rectangle?
please a small example in delphi
Thank you Miro
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: get encircled text contained under annotation rectangle ?

Post by Corwin - Tracker Sup »

Hello Miro,

I'm afraid that we don't have any samples of such kind.
However this can be done by using JS to get annotation coordinates and then get coordinates of text in PDF and try to find any intersections in this coordinates.

Best regards
tdonovan
User
Posts: 61
Joined: Tue Jun 12, 2007 9:21 pm

Re: get encircled text contained under annotation rectangle ?

Post by tdonovan »

You might look at the "problems getting chars Quad in .NET" as one of the messages has some code that I use to do what I think your asking.
miromr
User
Posts: 59
Joined: Sat May 09, 2009 3:05 pm

Re: get encircled text contained under annotation rectangle ?

Post by miromr »

Yes! thank you very much
Miro
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: get encircled text contained under annotation rectangle ?

Post by Stefan - PDF-XChange »

tdonovan,

Thanks for the help.

And miromr, please let us know if this helped you solve your problem.

Best,
Stefan
miromr
User
Posts: 59
Joined: Sat May 09, 2009 3:05 pm

Re: get encircled text contained under annotation rectangle ?

Post by miromr »

Hi,
Is not it perfect but sufficient for my needs
Miromr

Var
scr: WideString;
result: WideString;
S,Str: String;
SL: TStringList;
DataIn,DataOut:OleVariant;
Words,Word: IPDFXCsmartp;
i,WordCount: Integer;
SelRect: TMyRect;
WordRect: TMyRect;
vArr:array of OLEVariant;
Y: Double;
begin
Memo1.Lines.Clear;
Scr := 'var OutStr = ""; var Annot = this.getAnnot(0, "mySquare");'
+'Result = Annot.rect;';
try
PDFview.RunJavaScript (scr,result,0,0);
except
on ex : EOleException do
ShowErrorMessage(ex.ErrorCode);
end;
SL:= TStringList.Create;
SL.Delimiter :=',';
SL.DelimitedText:=Result;
for I := 0 to SL.Count - 1 do
Begin
SL:=StringReplace(SL, '.', DecimalSeparator,[]);
End;
SelRect.xlb:=StrToFloat(SL[0]);
SelRect.ylb:=StrToFloat(SL[1]);
SelRect.xrt:=StrToFloat(SL[2]);
SelRect.yrt:=StrToFloat(SL[3]);
SL.Free;
PDFView.DoVerb('Documents[0].Pages[0].Text.Words', '.SP', DataIn, DataOut, 0);
Words:=IDispatch(DataOut) as IPDFXCsmartp;
Words.GetProperty('Count', DataOut, 0);
WordCount:=DataOut;
SetLength(vArr,8);
Y:=0;
S:='';
for I := 1 to WordCount do
Begin
Words.GetItemPointByIndex(i, Word);
if (Word = nil) then
Continue;
Word.GetProperty('String', DataOut, 0);
Str:=dataOut;
if Str='' then Continue;
Word.GetProperty('Quads.Value', DataOut, 0);
vArr:=DataOut;
WordRect.xlb:=vArr[0];
WordRect.ylb:=vArr[1];
WordRect.xrt:=vArr[4];
WordRect.yrt:=vArr[5];
if RectIntersect(WordRect,SelRect) then
Begin
if Y=0 then
Y:=WordRect.ylb;
If Y=WordRect.ylb Then
Begin
if S='' then
S:=Str
else
S:=S+' '+Str;
End
else
Begin
Memo1.Lines.Add(S);
S:=Str;
Y:=WordRect.ylb;
End;
End;
End;
if S<>'' then
Begin
Memo1.Lines.Add(S);
S:=Str;
Y:=0;
End;
end;
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: get encircled text contained under annotation rectangle ?

Post by Stefan - PDF-XChange »

Glad the problem is solved :)

Best,
Stefan