Problem updating annotation text using Javascript

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

ugradedeveloper
User
Posts: 223
Joined: Wed Aug 22, 2007 4:40 pm

Problem updating annotation text using Javascript

Post by ugradedeveloper »

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
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: Problem updating annotation text using Javascript

Post by Ivan - Tracker Software »

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 !
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.
ugradedeveloper
User
Posts: 223
Joined: Wed Aug 22, 2007 4:40 pm

Re: Problem updating annotation text using Javascript

Post by ugradedeveloper »

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.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: Problem updating annotation text using Javascript

Post by Ivan - Tracker Software »

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.
ugradedeveloper
User
Posts: 223
Joined: Wed Aug 22, 2007 4:40 pm

Re: Problem updating annotation text using Javascript

Post by ugradedeveloper »

This problem is still happening for me in build 41.1.

Has the fix for this been postponed to a later build?

Thanks.
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: Problem updating annotation text using Javascript

Post by John - Tracker Supp »

Hi,

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
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2449
Joined: Thu Jun 30, 2005 4:11 pm

Re: Problem updating annotation text using Javascript

Post by Vasyl - PDF-XChange »

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.