Line breaks in JS


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")



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.

If you don’t need 2 paragraphs but just need a line break, then the following is fine:

Hope that it helps.

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.


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”.


1 Like