In my application I have a third-party spellchecker which the user can employ to correct spelling in annotations. A problem arises when the text in an annotation is updated. If the user had changed the font size or color, for example, these will be set back to their defaults when the Javascript code is executed to change the annotation text. Is this a bug? I haven't tried comparable Javascript in Acrobat to see if it does the same thing.
My Javascript looks like this (for example):
"var annots = this.getAnnots(); annots[0].contents = \"Some text\";"
I am using build 40.7.
Thanks.
Lewis
Problem updating annotation text using Javascript
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
- User
- Posts: 223
- Joined: Wed Aug 22, 2007 4:40 pm
-
- Site Admin
- Posts: 3586
- Joined: Thu Jul 08, 2004 10:36 pm
Re: Problem updating annotation text using Javascript
If you set text for annotations via the contents property, all text formatting will be removed and the default applied.
To set formatted text, you need to use richContents. But, to be honest, it is not so easy to use !
To set formatted text, you need to use richContents. But, to be honest, it is not so easy to use !
PDF-XChange Co Ltd. (Project Director)
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
-
- User
- Posts: 223
- Joined: Wed Aug 22, 2007 4:40 pm
Re: Problem updating annotation text using Javascript
Well, I modified my code to use the richContents property, but I am still having the same problem.
A sample: if replacing the text of the second span in the first annotation:
"var annots = this.getAnnots(); var contents = annots[0].richContents; contents[1].text = \"some text\"; annots[0].richContents = contents;"
All text in the specified annotation reverts to the default properties.
I also tried a more complex Javascript where it declares a new array of span objects, and copies the values one by one from the existing array, modifies the desired text, and then assigns the new array to the richContents property. The result is still the same.
Thanks.
A sample: if replacing the text of the second span in the first annotation:
"var annots = this.getAnnots(); var contents = annots[0].richContents; contents[1].text = \"some text\"; annots[0].richContents = contents;"
All text in the specified annotation reverts to the default properties.
I also tried a more complex Javascript where it declares a new array of span objects, and copies the values one by one from the existing array, modifies the desired text, and then assigns the new array to the richContents property. The result is still the same.
Thanks.
-
- Site Admin
- Posts: 3586
- Joined: Thu Jul 08, 2004 10:36 pm
Re: Problem updating annotation text using Javascript
Reproduced. Fix will be available into the next build.
PDF-XChange Co Ltd. (Project Director)
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
-
- User
- Posts: 223
- Joined: Wed Aug 22, 2007 4:40 pm
Re: Problem updating annotation text using Javascript
This problem is still happening for me in build 41.1.
Has the fix for this been postponed to a later build?
Thanks.
Has the fix for this been postponed to a later build?
Thanks.
-
- Site Admin
- Posts: 5223
- Joined: Tue Jun 29, 2004 10:34 am
Re: Problem updating annotation text using Javascript
Hi,
This will be resolved in build 41.2 released this Friday - thanks for your patience.
This will be resolved in build 41.2 released this Friday - thanks for your patience.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com
-
- Site Admin
- Posts: 2449
- Joined: Thu Jun 30, 2005 4:11 pm
Re: Problem updating annotation text using Javascript
This bug will be fixed in build 41.2.
PDF-XChange Co. LTD (Project Developer)
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.