Line breaks in JS

Hi,

I know that it is possible to create line breaks when I fill the text of a text box through JS by inserting ‘\n’. Is there also a way to create a new paragraph when I fill the text of a shape through JS, i.e. something similar to

prez.object('Box').text("abc \p def")

Thanks,

Rolf

Please choose an appropriate sub-category to post your question or topic.

Hi Roft,

You can use the html function of the object to achieve what you want.
prez.object('Box').html("<p>abc</p><p>def</p>");

If you don’t need 2 paragraphs but just need a line break, then the following is fine:
prez.object('Box').html("abc<br>def");

Hope that it helps.
BR,

1 Like

Thanks Thuy,

I was hoping that if I use this, the output would also have the spacing after paragraphs that I specified in the box for the paragraphs. The html function does seems to ignore these values.
best, Rolf

Hi Rolf,

Please let us know how the spacing is set up.
If the settings are in the editor, when calling the html() function, it will replace all the old text so it will no longer be effective.

BR,

Hi, Thanks,

that explains that. I set the spacing in AP GUI. Is there a way to set spacing etc through JS?

Best, Rolf

Hi Rolf,

Yes, you can add the style to the html.
For example, use the margin-bottom style for the first paragraph:
html('<p style="margin-bottom:20px;">abc</p><p>def</p>');
If you want the spacing to be far or near, edit the value of “20px”.

BR,

1 Like