I'm trying to highlight a word with javascript. For the life of me, I can't get anything but the bowtie. The output seems to be different between highlight and a square but I'm not sure how.
The script I've trying to get to work looks as follows:
for (var p = 0; p < this.numPages; p++)
{
var numWords = this.getPageNumWords(p);
for (var i=0; i<numWords; i++)
{
var ckWord = this.getPageNthWord(p, i, true);
if ( ckWord == "NOTES")
{
var q = this.getPageNthWordQuads(p, i);
var annot = this.addAnnot(
{
type: "Highlight",
page: p,
rect: q,
author: "A. C. Robat",
strokeColor: color.yellow,
}
)
}
}
};
I've seen that sometimes the quads are split and inverted etc which seems to work with a square, but the highlight always ends in a bowtie for me. Any help would be appreciated. thanks
Highlighting with JS
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan
Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
-
- User
- Posts: 22
- Joined: Wed Aug 02, 2023 4:19 pm
Highlighting with JS
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 17960
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
Re: Highlighting with JS
Hello dustinbagley,
You are getting quads - which are 8 values, and are then trying to apply them to the rectangle for your annotation which expects only four.
Please try this code (only the rect: is replaced with quads: for the annotation) - and it should work for you - it did for me:
Kind regards,
Stefan
You are getting quads - which are 8 values, and are then trying to apply them to the rectangle for your annotation which expects only four.
Please try this code (only the rect: is replaced with quads: for the annotation) - and it should work for you - it did for me:
Code: Select all
for (var p = 0; p < this.numPages; p++)
{
var numWords = this.getPageNumWords(p);
for (var i=0; i<numWords; i++)
{
var ckWord = this.getPageNthWord(p, i, true);
if ( ckWord == "YourWordHere")
{
var q = this.getPageNthWordQuads(p, i);
var annot = this.addAnnot(
{
type: "Highlight",
page: p,
quads: q,
author: "A. C. Robat",
strokeColor: color.yellow,
}
)
}
}
};
Stefan
-
- Site Admin
- Posts: 8624
- Joined: Wed Jan 03, 2018 6:52 pm
Highlighting with JS
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Tracker Software Products (Canada) LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com