javascript: possible bug creating new text annotation with empty richContents

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
Mathew
User
Posts: 188
Joined: Thu Jun 19, 2014 7:30 pm

javascript: possible bug creating new text annotation with empty richContents

Post by Mathew »

If you duplicate a FreeText annotation in javascript that has no richContents, the resulting FreeText will have empty contents. If you delete the richContents property before creating the duplicate, then it's fine.

To reproduce: Create a textbox with some text in it. Don't do any formatting of the text. Select it and run the script. It will make two copies: the first will be empty, the second, after the richContents property is deleted, will be the same as the original.

Code: Select all

var a = this.selectedAnnots[0].getProps();
a.rect = [a.rect[0]-20,a.rect[1]-20,a.rect[2]-20,a.rect[3]-20]; // move over 20pt
this.addAnnot(a); // this one will be blank
if ( ! a.richContents.length ) { // ie the richContents are empty
	delete a.richContents; // workaround for empty richContents bug
}
a.rect = [a.rect[0]-20,a.rect[1]-20,a.rect[2]-20,a.rect[3]-20]; // move over 20pt
this.addAnnot(a); // this one is fine
This only happens if there is no richText formatting in the text box.
User avatar
Paul - Tracker Supp
Site Admin
Posts: 6813
Joined: Wed Mar 25, 2009 10:37 pm
Location: Chemainus, Canada
Contact:

Re: javascript: possible bug creating new text annotation with empty richContents

Post by Paul - Tracker Supp »

I've also asked the devs about this.

This has also been corrected in the code already and the fix will be in the initial V10 release.
Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
Post Reply