javascript setting text field size and font

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

dphillips
User
Posts: 7
Joined: Sat Nov 19, 2011 4:58 pm

javascript setting text field size and font

Post by dphillips »

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
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: javascript setting text field size and font

Post by Vasyl - PDF-XChange »

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#):

Code: Select all

try
{
...
    pdfViewer.RunJavaScript(...);
...
}
catch (Exception ex)
{
    int errCode = System.Runtime.InteropServices.Marshal.GetHRForException(ex);
}
HTH
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.
dphillips
User
Posts: 7
Joined: Sat Nov 19, 2011 4:58 pm

Re: javascript setting text field size and font

Post by dphillips »

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
dphillips
User
Posts: 7
Joined: Sat Nov 19, 2011 4:58 pm

Re: javascript setting text field size and font

Post by dphillips »

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.
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: javascript setting text field size and font

Post by Vasyl - PDF-XChange »

Hi, dphillips.

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.
dphillips
User
Posts: 7
Joined: Sat Nov 19, 2011 4:58 pm

Re: javascript setting text field size and font

Post by dphillips »

Any timeline on the date of the release of build 200?
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: javascript setting text field size and font

Post by Stefan - PDF-XChange »

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
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: javascript setting text field size and font

Post by Stefan - PDF-XChange »

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
dphillips
User
Posts: 7
Joined: Sat Nov 19, 2011 4:58 pm

Re: javascript setting text field size and font

Post by dphillips »

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?
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7362
Joined: Wed Mar 25, 2009 10:37 pm

Re: javascript setting text field size and font

Post by Paul - PDF-XChange »

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
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
dphillips
User
Posts: 7
Joined: Sat Nov 19, 2011 4:58 pm

Re: javascript setting text field size and font

Post by dphillips »

can you send a list of the updated/fixed items in the upcoming 2.5 ?
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: javascript setting text field size and font

Post by Stefan - PDF-XChange »

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