javascript setting text field size and font
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
- User
- Posts: 7
- Joined: Sat Nov 19, 2011 4:58 pm
javascript setting text field size and font
The viewer activex throws an error when trying to set the size or font face for text fields using javascript.
the following does not work:
this.getField("text field).textFont = 'Courier';
this.getField("text field).textSize = 18;
the following does work:
this.getField("text field").textColor = color.blue;
When can we expect a fix for this bug?
Thanks
the following does not work:
this.getField("text field).textFont = 'Courier';
this.getField("text field).textSize = 18;
the following does work:
this.getField("text field").textColor = color.blue;
When can we expect a fix for this bug?
Thanks
-
- Site Admin
- Posts: 2445
- Joined: Thu Jun 30, 2005 4:11 pm
Re: javascript setting text field size and font
Your example script is incorrect.
Sure, if you pass the incorrect script then viewer returns the special error code by HRESULT and your client app (.NET, may be) throws the COM-exeption on it. You may skip the any exception generating by using of try/catch brackets (C#):
HTH
Sure, if you pass the incorrect script then viewer returns the special error code by HRESULT and your client app (.NET, may be) throws the COM-exeption on it. You may skip the any exception generating by using of try/catch brackets (C#):
Code: Select all
try
{
...
pdfViewer.RunJavaScript(...);
...
}
catch (Exception ex)
{
int errCode = System.Runtime.InteropServices.Marshal.GetHRForException(ex);
}
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.
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 7
- Joined: Sat Nov 19, 2011 4:58 pm
Re: javascript setting text field size and font
i see what your are referring to but i am using javascript inside the pdf document. the code you show is to. be run outside the document,correct? the code i displayed is run while viewing the document with your control.
the textColor property works but the textFont and textSize do not.
how would i be able to use your code to change the font size when i am loading the document? also can we make an external call using the runjavascript method from a button on the pdf document?
for example , is there a hook available that will allow me to make an external call to the runjavascript methodt from a form button on the pdf documnt?
thanks
the textColor property works but the textFont and textSize do not.
how would i be able to use your code to change the font size when i am loading the document? also can we make an external call using the runjavascript method from a button on the pdf document?
for example , is there a hook available that will allow me to make an external call to the runjavascript methodt from a form button on the pdf documnt?
thanks
-
- User
- Posts: 7
- Joined: Sat Nov 19, 2011 4:58 pm
Re: javascript setting text field size and font
Vasyl,
I have just confirmed that the textSize and textFont properties have problems using you fulldemo C# example project.
I created a dummy pdf with a text field called 'Text2'.
I loaded the document using the 'browse' and 'open' options on the document tab.
Once the document is displayed, I used the javascript tab to run the following code:
this.getField('Text2').textColor = color.blue;
The text color turned to blue as requested. I then added the following line of code to change the font face for the field and the font face did not change.
this.getField('Text2').textFont=font.Times;
The 'Result of JS Executing' window on the Javascript tab displayed the following text but the font face did not change in the field.
Times-Roman
It looks as if the code was able to deterrmine what the font was supposed to be but it did not actually change the font face.
I have just confirmed that the textSize and textFont properties have problems using you fulldemo C# example project.
I created a dummy pdf with a text field called 'Text2'.
I loaded the document using the 'browse' and 'open' options on the document tab.
Once the document is displayed, I used the javascript tab to run the following code:
this.getField('Text2').textColor = color.blue;
The text color turned to blue as requested. I then added the following line of code to change the font face for the field and the font face did not change.
this.getField('Text2').textFont=font.Times;
The 'Result of JS Executing' window on the Javascript tab displayed the following text but the font face did not change in the field.
Times-Roman
It looks as if the code was able to deterrmine what the font was supposed to be but it did not actually change the font face.
-
- Site Admin
- Posts: 2445
- Joined: Thu Jun 30, 2005 4:11 pm
Re: javascript setting text field size and font
Hi, dphillips.
The problem with textSize/textFont properties is confirmed. Thanks for report.
We will fix it in the next build (#200).
Best
Regards.
The problem with textSize/textFont properties is confirmed. Thanks for report.
We will fix it in the next build (#200).
Best
Regards.
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.
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 7
- Joined: Sat Nov 19, 2011 4:58 pm
Re: javascript setting text field size and font
Any timeline on the date of the release of build 200?
-
- Site Admin
- Posts: 19885
- Joined: Mon Jan 12, 2009 8:07 am
Re: javascript setting text field size and font
Hello dphillips,
I don't have an exact release date for build 200 yet, but our devs asked me to make a ticket for your case:
#1341: Implement textSize/textFont properties for JS-field
So that it can be properly followed and fixed.
We will update the topic when the problem is resolved.
Best,
Stefan
I don't have an exact release date for build 200 yet, but our devs asked me to make a ticket for your case:
#1341: Implement textSize/textFont properties for JS-field
So that it can be properly followed and fixed.
We will update the topic when the problem is resolved.
Best,
Stefan
-
- Site Admin
- Posts: 19885
- Joined: Mon Jan 12, 2009 8:07 am
Re: javascript setting text field size and font
Hello dphillips,
Good news. We've just implemented this, and it will be available in build 200 of our Viewer SDKs later this week.
Best,
Stefan
Good news. We've just implemented this, and it will be available in build 200 of our Viewer SDKs later this week.
Best,
Stefan
-
- User
- Posts: 7
- Joined: Sat Nov 19, 2011 4:58 pm
Re: javascript setting text field size and font
We have also found a bug with multiline text fields.
When the multiline text fields are set to a fixed size font they automaitcally scroll when a user enters in too much text. The native behavior of the multiline field should prevent the user from typing in too much information to scroll the field.
If you set the field properties to for example : 8pt courier, Multi-line and set the Scroll Long Text option off, the viewer allows the user to continue to add text so it adds the scroll bars to the right hand side of the text field. The allows user to enter too much information and will scroll the text off the page.
We know that auto-size font setting will not scroll off the field space but we cannot use the auto size font and need to have a fixed sized font used in the field.
Can this be fixed in the upcoming update?
When the multiline text fields are set to a fixed size font they automaitcally scroll when a user enters in too much text. The native behavior of the multiline field should prevent the user from typing in too much information to scroll the field.
If you set the field properties to for example : 8pt courier, Multi-line and set the Scroll Long Text option off, the viewer allows the user to continue to add text so it adds the scroll bars to the right hand side of the text field. The allows user to enter too much information and will scroll the text off the page.
We know that auto-size font setting will not scroll off the field space but we cannot use the auto size font and need to have a fixed sized font used in the field.
Can this be fixed in the upcoming update?
-
- Site Admin
- Posts: 7362
- Joined: Wed Mar 25, 2009 10:37 pm
Re: javascript setting text field size and font
Hi dphillips,
yes, we are aware of this behaviour and it has been addressed for V3. It will not change in the 2.5 series.
hth
yes, we are aware of this behaviour and it has been addressed for V3. It will not change in the 2.5 series.
hth
Best regards
Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
-
- User
- Posts: 7
- Joined: Sat Nov 19, 2011 4:58 pm
Re: javascript setting text field size and font
can you send a list of the updated/fixed items in the upcoming 2.5 ?
-
- Site Admin
- Posts: 19885
- Joined: Mon Jan 12, 2009 8:07 am
Re: javascript setting text field size and font
Hello dphillips,
The fixes in a given build are listed in the version history, but the page for the Viewer hasn't been updated with the things updated in build 200. We will see to do that as soon as possible.
Ver 2.5 is already live - and as Paul said - the issue with multiline fields will be fixed in ver3.
Best,
Stefan
The fixes in a given build are listed in the version history, but the page for the Viewer hasn't been updated with the things updated in build 200. We will see to do that as soon as possible.
Ver 2.5 is already live - and as Paul said - the issue with multiline fields will be fixed in ver3.
Best,
Stefan