Question Details

avatar
Keep your eye on the next goal: Frequent Contributor.

how do I format subscript/superscript characters in a text field?

I am creating a form where the user enters a formula in a linear format and then javascript takes that value and reformats it as variables with superscripted and subscipted characters.

ie.

event.rc = true;
if (event.value != "")
{
if
(
event.value.toUpperCase() != "N_X=E_X*N_A/E_A" &&
event.value.toUpperCase() != "N_X=E_XXN_A/E_A"
)
{
app.alert ("Incorrect, Try Again...Enter Subscripted Formulas in a Linear Format\r + (ie. E\u2093=I\u2090xR\u2090 would be entered as E_X=I_A*R_A).");
event.rc = false;
}
else
{
event.value = "N\u2093=E\u2093N\u2090/E\u2090";
document.write(event.value);
}
}

This works but I need to do this with N_P=E_P*N_S/E_S.

How can I write a subscripted-P and a subscripted-S to the field?


Brett Fleming 198 days ago


2 Answers

Voted Best Answer

avatar
<p>Congratulations! The Acrobat User Community selection team has approved your status as Expert in the Acrobat User Community. We appreciate all your past contributions and hope you will continue to support the community by answering questions and participating in the Acrobat Answers Q&A program as you've done in the past.</p>

<p>As an expert, you will get a badge to display on your profile with the level EXPERT next to your name and you have become eligible to be nominated to the Adobe Community Professional Program.</p>

<p>After reviewing the Adobe Community Professional Program information at https://www.adobe.com/communities/professionals/, please let us know if you are interested.</p>

<p>Someone from the selection team will contact you soon regarding the community professional program. Keep up the good work!</p>

<p>Regards,</p>

<p>The Acrobat User Community Team</p>


<p>**** Disclosure Requirements for Endorsements Received by Third Parties  ****</p>

<p>If you endorse or refer people to the Acrobat User Community in any venue,  it is our responsibility to ensure that you are aware of required compliance with the <a href="http://ftc.gov/os/2009/10/091005revisedendorsementguides.pdf">FTC’s Guidelines</a>. Both you and Adobe can be held liable under federal law for making unsubstantiated claims and for not disclosing your relationship with Adobe. In particular:</p>

<ol>
<li>Always disclose if you have received any type of incentive – free products, promotional items, travel, gifts, payment, and so on from Adobe. The disclosure must be on the same page as the endorsement.</li>
<li>Be truthful. Endorsements should not be misleading. Never make unsubstantiated or exaggerated claims about the benefits of Adobe products or programs. Any statements or endorsements about an Adobe product must be based on upon your actual experience.</li>
</ol>

Thank you again for your support of Adobe and the Acrobat User Community</p>

First of all, document.write() is not an object and a method that are supported in Acrobat JavaScript, only in browsers.

To have text in a text field show up as sub- or superscript you need to use the Rich Text Formatting option. Enable that in your field and then read about the richValue property and how to set it using an array of Span objects. Among the properties of these objects are subscript and superscript.

.


Visit my custom-made PDF scripts website: http://try67.blogspot.com
Contact me personally: try6767@gmail.com


By Gilad D (try67) answered 198 days ago  |   Comments (0)  |  New Comment

avatar

  |   Report
Was this answer helpful?  
1
0

avatar
Keep your eye on the next goal: Frequent Contributor.

I see what you mean, but how do I take a users input, reformat it and write it back to the field in the correct format. Where can I read about richValue property and how to set it using an array of Span objects?

I am somewhat new to this.

I also am not sure why this routine works if document.write() is not supported. I am using Acrobat pro X.


Brett Fleming answered 198 days ago  |   Comments (1)  |  New Comment

avatar
<p>Congratulations! The Acrobat User Community selection team has approved your status as Expert in the Acrobat User Community. We appreciate all your past contributions and hope you will continue to support the community by answering questions and participating in the Acrobat Answers Q&A program as you've done in the past.</p>

<p>As an expert, you will get a badge to display on your profile with the level EXPERT next to your name and you have become eligible to be nominated to the Adobe Community Professional Program.</p>

<p>After reviewing the Adobe Community Professional Program information at https://www.adobe.com/communities/professionals/, please let us know if you are interested.</p>

<p>Someone from the selection team will contact you soon regarding the community professional program. Keep up the good work!</p>

<p>Regards,</p>

<p>The Acrobat User Community Team</p>


<p>**** Disclosure Requirements for Endorsements Received by Third Parties  ****</p>

<p>If you endorse or refer people to the Acrobat User Community in any venue,  it is our responsibility to ensure that you are aware of required compliance with the <a href="http://ftc.gov/os/2009/10/091005revisedendorsementguides.pdf">FTC’s Guidelines</a>. Both you and Adobe can be held liable under federal law for making unsubstantiated claims and for not disclosing your relationship with Adobe. In particular:</p>

<ol>
<li>Always disclose if you have received any type of incentive – free products, promotional items, travel, gifts, payment, and so on from Adobe. The disclosure must be on the same page as the endorsement.</li>
<li>Be truthful. Endorsements should not be misleading. Never make unsubstantiated or exaggerated claims about the benefits of Adobe products or programs. Any statements or endorsements about an Adobe product must be based on upon your actual experience.</li>
</ol>

Thank you again for your support of Adobe and the Acrobat User Community</p>

All is documented in the JavaScript for Acrobat API Reference files.
Basically you would use the Format (or even Validate) event to "re-format" the value the user entered.

My guess is that if you look in the console window you'll see a bunch of errors about the document object not being defined, or something of that nature.

Gilad D (try67) Commented 197 days ago  |   Report


avatar

  |   Report
Was this answer helpful?  
0
0


Download
Acrobat XI trial

Get the trial now


Other Questions Needing Answers