Highlighted

Javascript new line

Community Beginner ,
Sep 06, 2020

Copy link to clipboard

Copied

New Line: \n

Empty Line (row): \n\n

Half Empty Line (row): ?

Is there such thing?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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;

 

 

TOPICS
Acrobat SDK and JavaScript, How to

Views

78

Likes

Translate

Translate

Report

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

Javascript new line

Community Beginner ,
Sep 06, 2020

Copy link to clipboard

Copied

New Line: \n

Empty Line (row): \n\n

Half Empty Line (row): ?

Is there such thing?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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;

 

 

TOPICS
Acrobat SDK and JavaScript, How to

Views

79

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 06, 2020 0
Most Valuable Participant ,
Sep 06, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 06, 2020 0
Community Beginner ,
Sep 06, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 06, 2020 0
Most Valuable Participant ,
Sep 06, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 06, 2020 0
Community Beginner ,
Sep 06, 2020

Copy link to clipboard

Copied

Thanks.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 06, 2020 0
Adobe Community Professional ,
Sep 06, 2020

Copy link to clipboard

Copied

Is this for form text fields?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 06, 2020 0
Community Beginner ,
Sep 06, 2020

Copy link to clipboard

Copied

Yes

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 06, 2020 0
Engaged ,
Sep 06, 2020

Copy link to clipboard

Copied

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;}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 06, 2020 0
Most Valuable Participant ,
Sep 06, 2020

Copy link to clipboard

Copied

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;

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 06, 2020 0
Blaž LATEST
Community Beginner ,
Sep 06, 2020

Copy link to clipboard

Copied

Thanks Nesa and Try67 that worked for me.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 06, 2020 0