Quantcast
Channel: Adobe Community : All Content - Acrobat SDK
Viewing all articles
Browse latest Browse all 2571

Acrobat 4.0 API - Problem with highlighting

$
0
0

I am using VB6 and Acrobat 4.0 because for now it's the only that works on an old pc that I have.

 

I need to highlight a word in a document and put an annotation on it. this is the code that I use (I omit the declarations) :

'list

hiliteList.Add 0, 32767

 

'acquiring the page

Set pdPage = pdDoc.AcquirePage(0)

 

'setting the document highlite

Set wordHilite = pdPage.CreateWordHilite(hiliteList)

 

'the word to find in the document

wordFind="1234/1"

 

'looping in the document

For idx = 0 To wordHilite.GetNumText - 1

     'taking the word for searching

     word = Trim(wordHilite.GetText(idx))

     If word = wordFind Then

          'word FOUND and setting the new list with only the found item

          Set hiliteListOk = CreateObject("AcroExch.HiliteList")

          hiliteListOk.Add idx, 1

          'creating the highlight

          set wordToHilite = pdPage.CreatePageHilite(hiliteListOk)

          'Debug.Print wordToHilite.GetText(0)

          'setting selection

          avDoc.SetTextSelection wordToHilite

          'getting the rectangle

          Set myrect1 = wordHilite.GetBoundingRect

          'getting then selection with the rectangle

          Set textSel = pdDoc.CreateTextSelect(0, myrect1)

          avDoc.ShowTextSelect

          Exit For

     End If

Next

 

the problem is that after I found the right word, I create the new list ( hiliteListOk ) with only the item that I want, but the result is not the same.

For example : I find looping the item no 113 (getting it from the looping variable 'idx'), but when I create the new highlight list with only the right item putting no. 113 in the index the text in this item is not the same of the looping.

In the object wordHilite I find item 113 = "1234/1" and putting the 113 as offset in the instruction  hiliteListOk.Add 113, 1 I got a different text.

Looping the document the string "1234/1" is wholly taken, but assigning the index directly the string is splitted into 3 strings : "1234" "/" "1" so the index does not correspond anymore.

 

Any solution  for this problem ?

 

thanks to all that will give me help.


Viewing all articles
Browse latest Browse all 2571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>