Skip to main content
Known Participant
April 14, 2023
Question

Looking for JavaScript to add blank page to a form

  • April 14, 2023
  • 5 replies
  • 2600 views

Hello, Community! I'm a novice programmer and new to JavaScript. I've been crawling the web for the past several hours to find JavaScript that I can use to add a blank page with a single large (page-filling) text box. The use case is that on my form, there's a text input box for users to add comments to the form. If they need to add a lot of text, though, the auto-sizing feature makes the text eventually too small to read. My proposed solution is to set a fixed size to the input box font and provide a button to add a second page with a fillable text box.

 

I've tried entering this single-line command in the button's "Run a JavaScript" Action box:

this.newPage(1);

Clicking the button in the form does not add a page - nothing happens...no error, just...nothing.

 

I've tried this code: 

var A = this.getTemplate("Short Form");
A.spawn(2,false,false);
this.pageNum=1;

 Same result - nothing happens.

 

I'm not putting this code inside braces what you see is exactly what I put in the box.

 

During my webcrawl, I found hints that the page may not generate if nothing is added to it, but I also am not sure that the code is to add my desired box. Maybe the solution is that either will work if I then add code to put the text box in place. 

 

Any pointers? Remember, I'm new to coding, so if there are customary pieces of code required to make code run, I don't know that... 🙂

This topic has been closed for replies.

5 replies

JR Boulay
Community Expert
Community Expert
April 17, 2023
Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
Community Expert
April 14, 2023

"I've tried this code:

var A = this.getTemplate("Short Form");
A.spawn(2,false,false);
this.pageNum=1;"

 

Did you create a hidden template before running this script?

Acrobate du PDF, InDesigner et Photoshopographe
mer67Author
Known Participant
April 17, 2023

I did not. I don't know how to do that, and the website where I found this approach didn't mention hidden templates. (I have looked at so many that I don't recall which site shared this solution, and I saw it on a few sites.)

 

Thanks for taking time to post!

Legend
April 14, 2023

First thing: are you designing for

-yourself, and other people paying for Actonat Pro?

-people who use the free Acrobat Reader, and know how to download and open in Reader

-people who will open from browser or email 

-people on phones or tablets

-a mixture

please be detailed. It's the difference between "do this" and "give up the idea". 

mer67Author
Known Participant
April 17, 2023

Oh, shoot...I'm normally better about my posts. Answers:
Most people form whom I'm creating this form will be using Reader, though some will be using Pro.

Most will download the form from a repository and open it on their PC, but I suspect some will try using it on their smart phones. It is also possible some will receive the form via email and save it to their desktop to fill it out; I am hoping that there is no difference in construction between a form downloaded from a repository versus a saved email attachment. My users are a captive user base and I can tell them to only use a PC ( / Mac) to open the form.

 

Thanks for taking time to work this for me.

mer67Author
Known Participant
April 14, 2023

...and, wow, I really shouldn't post when I'm on sinus meds. I meant that I am not sure WHAT the code is to add the desired text box. 

 

Apologies for this low-quality post.

mer67Author
Known Participant
April 14, 2023

I should have also stated that I'm using the Continuous Release version of Acrobat. I'm currently on Continuous Release version 2023.001.20143 - 64-bit.