Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Javascript new line

Explorer ,
Sep 06, 2020 Sep 06, 2020

New Line: \n

Empty Line (row): \n\n

Half Empty Line (row): ?

Is there such thing?

TOPICS
Acrobat SDK and JavaScript
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Sep 06, 2020 Sep 06, 2020

You can use richValue to set empty text with whatever size you want your empty line to be.

try adapt this to your code:

var spans = new Array();
spans[0] = new Object();
spans[0].text = " \n";
spans[0].textSize = 5;
event.richValue = spans;}

Translate
Community Expert , Sep 06, 2020 Sep 06, 2020

For some reason I thought that wouldn't change the height of the line, but it does... The full code would be:

var spans = new Array();
spans[0] = new Object();
spans[0].text = "Line 1\n";
spans[0].textSize = 10;
spans[1] = new Object();
spans[1].text = "\n";
spans[1].textSize = 5; // change this value to change the distance between the two lines
spans[2] = new Object();
spans[2].text = "Line 2";
spans[2].textSize = 10;

this.getField("Text1").richValue = spans;

 

 

Translate
Community Expert ,
Sep 06, 2020 Sep 06, 2020

What is an "half empty line"? Please explain what you mean.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 06, 2020 Sep 06, 2020

Lets say if \n\n is 10px height empty line between rows, is there code that does 5px height empty line ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 06, 2020 Sep 06, 2020

Ah, I see. No, that's not possible with a script.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 06, 2020 Sep 06, 2020

Thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 06, 2020 Sep 06, 2020

Is this for form text fields?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 06, 2020 Sep 06, 2020

Yes

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 06, 2020 Sep 06, 2020

You can use richValue to set empty text with whatever size you want your empty line to be.

try adapt this to your code:

var spans = new Array();
spans[0] = new Object();
spans[0].text = " \n";
spans[0].textSize = 5;
event.richValue = spans;}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 06, 2020 Sep 06, 2020

For some reason I thought that wouldn't change the height of the line, but it does... The full code would be:

var spans = new Array();
spans[0] = new Object();
spans[0].text = "Line 1\n";
spans[0].textSize = 10;
spans[1] = new Object();
spans[1].text = "\n";
spans[1].textSize = 5; // change this value to change the distance between the two lines
spans[2] = new Object();
spans[2].text = "Line 2";
spans[2].textSize = 10;

this.getField("Text1").richValue = spans;

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 06, 2020 Sep 06, 2020
LATEST

Thanks Nesa and Try67 that worked for me.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines