Color property of Text annotations

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

DanielG
User
Posts: 34
Joined: Wed Oct 09, 2013 5:58 pm

Color property of Text annotations

Post by DanielG »

Hello,

I am looking to save the properties of a Text annotation to a file and then load those same properties back in so that I can programmatically create the same Text annotation.

This is what I am using to save the properties:

var annot = this.getAnnot(0, "b272fac4-8acc-45ea-a199b757531e5c60");

var output;
output = "Author=" + annot.author + ";";
output += "FillColor=" + annot.fillColor + ";";
output += "NoteIcon=" + annot.noteIcon + ";";
output += "Opacity=" + annot.opacity + ";";
output += "PopupOpen=" + annot.popupOpen + ";";
output += "PopupRect=" + annot.popupRect + ";";
output += "Rect=" + annot.rect + ";";
output += "StrokeColor=" + annot.strokeColor + ";";
output += "Type=" + annot.type + ";";
this.Results = output;

I have noticed that when I do this, the values of FillColor and StrokeColor are both T. I would have thought one of them, FillColor, would be the actual color of the Text annotation.

So I then use these values to create the Text annotation:

var annot = this.addAnnot({
page: 0,
author: "chq-dang",
creationDate: cDate,
fillColor: ["T"],
modDate: mDate,
noteIcon: "Comment",
opacity: 1,
popupOpen: true,
popupRect: [261.66729857819905,469,411.66729857819905,549],
rect: [188.94028436018957,384.75,208.94028436018957,402.75],
strokeColor: ["T"],
type: "Text"});

I intentionally left out the rich contents values for sake of clarity. The resulting Text annotation is white, not the color it was when I saved the properties.

Am I doing something wrong?
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: Color property of Text annotations

Post by Vasyl - PDF-XChange »

var annot = this.getAnnot(0, "b272fac4-8acc-45ea-a199b757531e5c60");
I have noticed that when I do this, the values of FillColor and StrokeColor are both T
In which way this annot was created - programmatically or by end-user? Which build you are using?
I intentionally left out the rich contents values for sake of clarity. The resulting Text annotation is white, not the color it was when I saved the properties.
It is correct when you applying the previously saved "T" (transparent) color from annot's "fillColor" property (as I see in your "annot-restoring" script).
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.
DanielG
User
Posts: 34
Joined: Wed Oct 09, 2013 5:58 pm

Re: Color property of Text annotations

Post by DanielG »

The annotation is created by the user, but I am saving all of its properties so that I can create it again later. When saving the properties for a Text annotation, both the fillColor and strokeColor have a value of "T":

var fColor = annot.fillColor; // this will be "T"
var sColor = annot.strokeColor; // this will be "T"

So when I create the Text annotation again, I set its fillColor and strokeColor to "T" because those are the values returned to me:

annot.fillColor = "T";
annot.strokeColor = "T";

When obtaining the attributes to save them to a file, I would have thought one of the two color properties, either fillColor or strokeColor, would be an actual color value.
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: Color property of Text annotations

Post by Vasyl - PDF-XChange »

I tried to reproduce the trouble with fillColor=="T" in our end-user app. For this:
1. created the blank document
2. put the StikyNote on the first page
3. displayed the JS-Console (Ctrl+J) and executed script:
var aa = getAnnots(0);
aa[0].fillColor;
the console output was:
"RGB,1,1,0"
- yellow(default) color.
So, I couldn't reproduce case fillColor==T. May be this trouble depended with specific document. Can you send to us the simple example document for reproducing?
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.
DanielG
User
Posts: 34
Joined: Wed Oct 09, 2013 5:58 pm

Re: Color property of Text annotations

Post by DanielG »

Here is the file I am working with.

Here are the steps I take to obtain the annotation attributes:

Run DoVerb('Documents[0].Pages[0]', 'GetAnnotsCount', dataIn, dataOut, 0); to get the number of annotations on the page

Run DoVerb('Documents[0].Pages[0]', 'GetAnnotName', dataIn, dataOut, 0); to get the name for each annotation (where dataIn is the annotation number)

Run
var annot = this.getAnnot(0, "<annotation name>");

var output;
output = "Author=" + annot.author + ";";
output += "FillColor=" + annot.fillColor + ";";
output += "NoteIcon=" + annot.noteIcon + ";";
output += "Opacity=" + annot.opacity + ";";
output += "PopupOpen=" + annot.popupOpen + ";";
output += "PopupRect=" + annot.popupRect + ";";
output += "Rect=" + annot.rect + ";";
output += "StrokeColor=" + annot.strokeColor + ";";
output += "Type=" + annot.type + ";";
this.Results = output;

to get all attributes for a specific annotation. When I do this, I get a fillColor of "T".

I tried your steps and got the actual fillColor of the Text annotation (not "T").
You do not have the required permissions to view the files attached to this post.
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: Color property of Text annotations

Post by Vasyl - PDF-XChange »

Your sample document doesn't contain sticky notes annotations..
In which way should I create annots to reproduce issue with your script: like end-user or by JS?

Firstly I created one annot by it:

Code: Select all

var annot = this.addAnnot({
page: 0,
author: "AAA",
fillColor: color.green,
opacity: 1,
popupOpen: true,
popupRect: [261.66729857819905,469,411.66729857819905,549],
rect: [188.94028436018957,384.75,208.94028436018957,402.75],
type: "Text"});
and then - I used your "get-annot-props" script. The result:

Code: Select all

Author=AAA;FillColor=RGB,0,1,0;NoteIcon=Comment;Opacity=1;PopupOpen=true;PopupRect=239.1744075829384,398.5,389.17440758293844,478.5;Rect=188.94028436018957,384.75,208.94028436018957,402.75;StrokeColor=T;Type=Text;
As you see: FillColor=RGB,0,1,0 - that is correct.

Next - I created annot like end-user then run your script and got correct result also.

Which version of SDK you are using?
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.
DanielG
User
Posts: 34
Joined: Wed Oct 09, 2013 5:58 pm

Re: Color property of Text annotations

Post by DanielG »

I came across the issue having the end-user create the annotation and then getting the properties via JS. I am using version 2.5.213.1 of the SDK.

I have taken a different direction regarding saving/recreating annotations. As a result, this is no longer an issue for me.

Thanks for researching this issue.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: Color property of Text annotations

Post by Stefan - PDF-XChange »

:)