It’s often useful, for saving space or providing more information to the user, to place multiple lines of text in a Button caption. This is something that cannot be done from the Acrobat user interface. However, it is easily accomplished with Acrobat JavaScript. All you need to know is the name of the Button Field.
First, let’s create a test document. Display the Acrobat JavaScript Window (Use Ctrl+J for Windows or Command+J for the Mac, or from the Advanced menu). Enter and run the following code to create a new PDF.
app.newDoc();
Now select the Button tool from the Advanced Editing toolbar. Create a Button Field and name it “MyButton”.
Display the Acrobat JavaScript Console again. Enter and run the following code to put two lines into the caption of the Button.
this.getField("MyButton").buttonSetCaption("Hello\nWorld");
The words “Hello” and “World” each appear on different lines because they are separated with “\n”. The forward slash (“\”) is the escape character. It gives the next character in the sequence a special meaning. In this case, “\n” inserts a new line into the string. You can insert this character sequence as many times and anywhere you want in a string to add new lines in the text.
Related topics: |
PDF Forms, JavaScript |
Top Searches: |
Convert existing forms to fillable PDFs fill and sign PDF onlineEdit PDF create PDF Action Wizard |
Try Acrobat DC
Get started >
Learn how to
edit PDF.
Post, discuss and be part of the Acrobat community.
Join now >
0 comments
Comments for this tutorial are now closed.
Comments for this tutorial are now closed.