Accessing default appearance and text formatting properties

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

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

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

Accessing default appearance and text formatting properties

Post by DanielG » Tue Jan 14, 2014 11:04 pm

Hello,

Is there a way to access the default appearance and formatting properties?

I can use the Typewriter tool to place some text. Then I can change the text's appearance and text formatting and make these changes the default. Then when I use the Typewriter tool again, the new text has the new appearance and text formatting changes.

However, if I create a text annotation either by using DoVerb('', 'ExecuteCommand', 'Paste', oleVariant, 0) or creating a FreeText annotation via JavaScript, the resulting text annotation does not use the default appearance and text formatting properties.

Thanks,
Daniel

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 14161
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Accessing default appearance and text formatting propert

Post by Tracker Supp-Stefan » Wed Jan 15, 2014 1:41 pm

Hi Daniel,

If you "paste" - the pasted object will be a copy of what is in the clipboard - so it's expected that it will not be with the default settings, and when using JS - you have full control over all the appearance of the object created anyway.

Regards,
Stefan

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

Re: Accessing default appearance and text formatting propert

Post by DanielG » Wed Jan 15, 2014 3:01 pm

Hi Stephan,

Thanks for the reply and information. Given the two options, I will opt to use JavaScript and set the appearance as necessary.

So back to my first question - is there a way to know what the default appearance and text formatting properties are? When I go to set the font size, for example, is there a way to know what the deafult font size is?

Thanks,
Daniel

User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 1991
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Accessing default appearance and text formatting propert

Post by Vasyl-Tracker Dev Team » Wed Jan 15, 2014 11:28 pm

Hi, Daniel.
However, if I create a text annotation either by using DoVerb('', 'ExecuteCommand', 'Paste', oleVariant, 0) or creating a FreeText annotation via JavaScript, the resulting text annotation does not use the default appearance and text formatting properties.
In new build you will able to handle new event "Notifications.NewAnnotAdded" to modify some props of just added annotation. Some details about new event that will be added:

Code: Select all

// Notification parameters structure:
Notification.NewAnnotAdded
    Enabled : (int/boolean) - enables/disables the sending of event from the control. Enabled==false by default.
    DocID : int - target document identifier
    PageIndex : int - target page index (zero-based)
    Name : string - unique name of new annot
    Temp : int/boolean - when is non-zero then annot was added but not completely and adding can be canceled (some text boxes)
    Source: int - describes in which way the annot was created: by user, by java-script, by paste. Possible values:
        0 == "User"
        1 == "JS"
        2 == "Paste"
And small example of using:

Code: Select all

pdfViewer.SetProperty("Notifications.NewAnnotAdded.Enabled", 1);
...

youreventhandler OnEvent(type, name, ...)
{
    if (type == PXCVA_OnNamedNotify AND name == Notifications.NewAnnotAdded)
    {
         int src = 0;
         pdfViewer.GetProperty(name + ".Source", out src, 0);
         if (val == 1 // added by JS
             OR
             val == 2 // added by 'Paste'
          )
         {
             string newAnnotName;   
             pdfViewer.GetProperty(name + ".Name", out newAnnotName, 0);
             // update annot appearance props by JS using 'newAnnotName'....
         }
    } 
}
The other topic about similar problem:
http://www.tracker-software.com/forum3/ ... 36&t=20047

And, when you pasted text on the page then viewer creates new text box annotation and uses the appearance props from an "Commenting.TextBox.Styles[#" + styleID + "]". The example code that changes the current textbox-style:

Code: Select all

int curStyleID = 0;
pdfViewer.GetProperty("Tools.TextBox.Style", out curStyleID);

string pathToCurStyle = "Commenting.TextBox.Styles[#" + ToStr(curStyleID) + "]";
...
double fs = 0;
pdfViewer.GetProperty(pathToCurStyle + ".TextFormat.FontSize", out fs);
fs += 5;
pdfViewer.SetProperty(pathToCurStyle + ".TextFormat.FontSize", fs);
...
pdfViewer.SetProperty(pathToCurStyle + ".TextFormat.FontName", "Courier New");
HTH
Vasyl Yaremyn
Tracker Software Products
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: Accessing default appearance and text formatting propert

Post by DanielG » Thu Jan 16, 2014 3:58 pm

Thanks for getting back to me Vasyl. However, I am getting an "Invalid Operation" error when trying to get the FontName or FontSize property.

Here is my code:
style: integer;
path: string;
dataOut: oleVariant;

fCoPDFXCview.GetProperty('Tools.TextBox.Style', dataOut, 0);
style := dataOut;
path := 'Commenting.TextBox.Styles[#' + IntToStr(style) + ']';

// these next two lines will result in an "Invalid Argument" error
fCoPDFXCview.GetProperty(path + '.TextFormat.FontName', dataOut, 0);
fCoPDFXCview.GetProperty(path + '.TextFormat.FontSize', dataOut, 0);

Any idea what I'm doing wrong

User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 1991
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Accessing default appearance and text formatting propert

Post by Vasyl-Tracker Dev Team » Thu Jan 16, 2014 5:37 pm

Sorry for my small mistake - should be:

CoPDFXCview.GetProperty(path + '.TextFormat.Char.FontName', dataOut, 0);
CoPDFXCview.GetProperty(path + '.TextFormat.Char.FontSize', dataOut, 0);

Please look to our SDK help..

HTH
Vasyl Yaremyn
Tracker Software Products
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: Accessing default appearance and text formatting propert

Post by DanielG » Thu Jan 16, 2014 10:47 pm

Thanks Vasyl. I was able to find the information in the API document.

Got a related question: Is there a way to determine what the current commenting sytle is? Or what the comment style is for a selected annotation? I've been looking and looking throught the API document, but I can't seem to find anything.

I've tried using GetAnnotType, but that seems to return 4107 no matter if the annotation was created by TypeWriter or TextBox.

User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 1991
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Accessing default appearance and text formatting propert

Post by Vasyl-Tracker Dev Team » Fri Jan 17, 2014 9:12 pm

Currently you can get the style for new comments creation only. For example the creation-style ID for TextBox-annots:

Code: Select all

style: integer;
dataOut: oleVariant;

fCoPDFXCview.GetProperty('Tools.TextBox.Style', dataOut, 0);
style := dataOut;
But you cannot determine by existing annotation what style-ID was used for creation of it..
Vasyl Yaremyn
Tracker Software Products
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: Accessing default appearance and text formatting propert

Post by DanielG » Fri Jan 24, 2014 4:32 pm

Thanks for your response. Not the answer I was looking for, but I have been able to code around it.

Do you know if the ability to know the commenting style for a selected annotation will be added to a future release?

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 14161
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Accessing default appearance and text formatting propert

Post by Tracker Supp-Stefan » Fri Jan 24, 2014 4:46 pm

Hi Daniel,

I don't think that is possible because once added the annotation has it's own list of settings that will determine it's appearance and the "style used" is not a value that is recorded. You could change the annotation later and it won't match any predefined style in the Viewer. You could use JS to obtain each and every annotation parameter though, and create new ones using the exactly same values if desired.

Regards,
Stefan

Post Reply