Accessing default appearance and text formatting properties
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
Accessing default appearance and text formatting properties
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
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
- Tracker Supp-Stefan
- Site Admin
- Posts: 17910
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Accessing default appearance and text formatting propert
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
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
Re: Accessing default appearance and text formatting propert
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
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
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Accessing default appearance and text formatting propert
Hi, Daniel.
And small example of using:
The other topic about similar problem:
https://forum.pdf-xchange.com/ ... 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:
HTH
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: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.
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"
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'....
}
}
}
https://forum.pdf-xchange.com/ ... 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");
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.
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.
Re: Accessing default appearance and text formatting propert
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
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
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Accessing default appearance and text formatting propert
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
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.
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.
Re: Accessing default appearance and text formatting propert
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.
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.
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Accessing default appearance and text formatting propert
Currently you can get the style for new comments creation only. For example the creation-style ID for TextBox-annots:
But you cannot determine by existing annotation what style-ID was used for creation of it..
Code: Select all
style: integer;
dataOut: oleVariant;
fCoPDFXCview.GetProperty('Tools.TextBox.Style', dataOut, 0);
style := dataOut;
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.
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.
Re: Accessing default appearance and text formatting propert
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?
Do you know if the ability to know the commenting style for a selected annotation will be added to a future release?
- Tracker Supp-Stefan
- Site Admin
- Posts: 17910
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Accessing default appearance and text formatting propert
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
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