12 Replies Latest reply on Oct 24, 2010 8:47 AM by Bernd Alheit

Hi All,

I would like to combine the annotations of several words using their quads, but am finding the conversion from the quads string to array and back very confusing. Anyone has a good tip on how to to this?

• ###### 1. Re: How to combine quads?
In the general case you couldn't, but you could consider this special
case:

If bottom Y co-ordinates are all equal in both quads
AND top Y co-ordinates are equal in all quads
AND right X co-ordinate of left quad is close to left X co-ordinate of
then combine by taking the left side of one and right of the other.

Defining "close" is tricky.

Aandi Inston
• ###### 2. Re: How to combine quads?
Thanks, Aandi.
I got to the point where I have an array with the 8 quads I want, but I can't seem to convert it back to the format Acrobat is looking for. Should it be a string, an array, or something else?
• ###### 3. Re: How to combine quads?
What API are you trying to pass the quad to?

Aandi Inston
• ###### 4. Re: How to combine quads?
I was passing it to addAnnot(), but in the meantime I kind of solved the problem. Once I had an array of the 8 quads I wanted, I converted all of it's members to pure numbers (by multiplying each in 1), and then, and that's the tricky bit, I've created another array and placed the quads array at it's 0-index. This new array was accepted as a valid quads representation by addAnnot().

BUT! This doesn't seem to work in all documents. The reason, I suspect, is that sometimes you need to change different coordinates in the quads array. I used coordinated 3 and 7 because they are supposed to be the X value of the right side of the quad, but this doesn't seem to be consistent. Any ideas on what might be the reason for it?
• ###### 5. Re: How to combine quads?
If the text is not horizontal, then the quad won't be a rectangle in
the orientation you expect. This case is best checked for and
(probably) skipped.

Aandi Inston
• ###### 6. Re: How to combine quads?
I figured it might be something like that (or page rotation), but the text seems horizontal. Any ideas on how to check for it? I searched the AcroJS file to no avail.

[Edit: I was able to achieve the desired result by changing members 2 and 6 of the quads array in addition to 3 and 7]
• ###### 7. Re: How to combine quads?
I had a problem with words that were on both ends of two lines, so I played around with it a bit and found a much better way. You simply add the quads of each word to the final array, and then they are all connected into a single annotation. So finally you have an array of k arrays of 8 coordinates, k being the number of words you highlight.

The only downside to this system is that there's a slight interval between the words when you select them, but they are still a part of the same annotation.
• ###### 8. Re: How to combine quads?

Hi try67: could you possibly post the code (or snippet of the code) you have used to combine the quads please?

I have to search for two consecutive words inside a pdf and and mark-up with one annotation but am unable to combine the quads.

Kind regards. Fusweb

• ###### 9. Re: How to combine quads?

As I wrote, the quads object is actually made of an array of arrays of 8

single item in the inner array. To combine the quads of single words, you

push the that inner-most array to a larger one and then use that one.

• ###### 10. Re: How to combine quads?

Apologies, I'm rather new at this.

I've tried lots of options...

I've got 2 quads defined in an array - highlightedWords

If I type quads: highlightedWords [1] or highlightedWords[2] into the bold line it highlights first or second word correctly.

but I'm still unable to 'combine them' to make one annot highlighting both words -

(i=page, j=word)

page: i,

type: "Highlight",

author: "Mat"

Mat

• ###### 11. Re: How to combine quads?

Hi Try67

UPDATE:

gradually making progress but have hit a wall.

I think I've done what you suggested:

ccreated a higher array and put both quads into it.

myWord now consists of two sets of quads according to the output of the console:

highlightedWords[0]

340.06298828125,736.9004516601562,384.10699462890625,736.9004516601562,340.06298828125,721 .4954833984375,384.10699462890625,721.4954833984375

highlightedWords[1]

388.07586669921875,736.9004516601562,407.58380126953125,736.9004516601562,388.075866699218 75,721.4954833984375,407.58380126953125,721.4954833984375

myWords

340.06298828125,736.9004516601562,384.10699462890625,736.9004516601562,340.06298828125,721 .4954833984375,384.10699462890625,721.4954833984375,388.07586669921875,736.9004516601562,4 07.58380126953125,736.9004516601562,388.07586669921875,721.4954833984375,407.5838012695312 5,721.4954833984375

if (((this.getPageNthWord(i,j))=="Search") && ((this.getPageNthWord(i,j+1))=="String")) {

var myWords = highlightedWords;

console.println(highlightedWords[0]);

console.println(highlightedWords[1]);

console.println(myWords);

page: i,

type: "Highlight",

author: "Matt",

});

}

Yet the annot still only highlights the first set of quads in myWords?

Matt

• ###### 12. Re: How to combine quads?

first:
340.06298828125
736.9004516601562
384.10699462890625
736.9004516601562
340.06298828125
721.4954833984375
384.10699462890625
721.4954833984375

second:
388.07586669921875
736.9004516601562
407.58380126953125
736.9004516601562
388.07586669921875
721.4954833984375
407.58380126953125
721.4954833984375

first + second:
340.06298828125
736.9004516601562
407.58380126953125
736.9004516601562
340.06298828125
721.4954833984375
407.58380126953125
721.4954833984375