Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum. |
Add a working hyperlink to RTF-enabled text box? |
Post Reply ![]() |
Author | |
mmitchell_houston ![]() New Member ![]() ![]() Joined: 29 Aug 2018 Location: Houston, TX Points: 10 |
![]() ![]() ![]() ![]() Posted: 01 Sep 2018 at 11:46pm |
Two Questions
txtbox1 = standard text field (text only, no rtf) txtbox2 = text box with rtf enabled (+ multiline, scrolling, etc.) btnSubmit = standard button
IS THIS POSSIBLE? I have experimented with two approaches, and neither works. FIRST (RTF approach) I tried set it with something similar to this var newURLrtf1 = "{\colortbl ;\red0\green0\blue238;}{\field{\*\fldinst HYPERLINK" + getField("txtbox1").value + " }{\fldrslt{\ul\cf1Text to display}}}" getField("txtbox2").value = newURLrtf1 (I know, that code won't work exactly as written -- I'm looking at the concept, not the syntax here) SECOND (HTML approach) I tried to set it with something similar to this: var str = "The description goes here"; var result = str.link("https://www.w3schools.com"); getField("txtbox2").value = result; I even tried this. getField(txtbox2").innerHTML = newURLrtf1; ------------------------------ |
|
![]() |
|
Sponsored Links | |
![]() |
|
mmitchell_houston ![]() New Member ![]() ![]() Joined: 29 Aug 2018 Location: Houston, TX Points: 10 |
![]() ![]() ![]() ![]() |
I am sorry, I should have mentioned that the approaches cited above both work about halfway: the text does move over to the second box, but all the code appears as visible text. It does not work to create a link.
|
|
![]() |
|
gkaiseril ![]() Senior Member ![]() Joined: 15 Jul 2011 Location: USA Points: 4105 |
![]() ![]() ![]() ![]() |
Have you looked at the Acrobat JavaScript API Reference Manual?
You might try using the app.launchURL. Carefully read the description and the sections about privileged context. If this form will be distributed to others, then you or they will have to install a special script file in one of Acrobat's/Reader's JavaScript folders.
|
|
![]() |
|
mmitchell_houston ![]() New Member ![]() ![]() Joined: 29 Aug 2018 Location: Houston, TX Points: 10 |
![]() ![]() ![]() ![]() |
Thank you. That has lead me down some promising avenues. I've learned that I the richValue of a RTF field is an array, and it can be accessed and written to: To get the text stored in richValue, use this: getField("txtboxName1").richValue.toSource(); I can populate the RTF field in this manner: // Build up an array of Span objects var spans = new Array(); spans[0] = new Object(); spans[0].hyperlink = "http://www.bhp.com"; spans[0].text = "My Text Here\r"; spans[0].textColor = color.blue; spans[0].textSize = 10; spans[1] = new Object(); spans[1].text = "Adobe Acrobat 6.0\r"; spans[1].textColor = color.red; spans[1].textSize = 20; spans[1].alignment = "center"; spans[2] = new Object(); spans[2].text = "More text here"; spans[2].textColor = color.blue; spans[2].fontStyle = "italic"; spans[2].underline = true; spans[2].alignment = "right"; // Now give the rich field a rich value getField("txtboxName1").richValue = spans; The line of blue text above DOES NOT work. Can someone suggest something that might let me create a clickable hyperlink? |
|
![]() |
|
BAlheit ![]() Senior Member ![]() Joined: 15 Jul 2011 Points: 1110 |
![]() ![]() ![]() ![]() |
spans doesn't have a hyperlink property.
|
|
![]() |
|
mmitchell_houston ![]() New Member ![]() ![]() Joined: 29 Aug 2018 Location: Houston, TX Points: 10 |
![]() ![]() ![]() ![]() |
Yup. I figured that out. QUESTION: If the RTF field allows me to copy/paste a working URL into it (or I can use the Text Property Editor to add one), how does that work? Why does it allow me to paste it in if I cannot extract it later? This just seems peculiar to me.
|
|
![]() |
|
BAlheit ![]() Senior Member ![]() Joined: 15 Jul 2011 Points: 1110 |
![]() ![]() ![]() ![]() |
Not all features are available in JavaScript.
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |