Ok, I've made some (debatable) progress: while looping through the spans, I can add a newline at the end of each span and that will fix the paragraph issues; but then it splits the paragraph if there are multiple spans within that paragraph (i.e. a section that is bold within the paragraph).
So, unless there's a better/more proper way to keep the line endings, is there a way to tell if the current span is the end of the paragraph so that I can add the newline only to those spans? I'm guessing I can keep track of the character count as I loop through the spans, and check the character at the next position in the total text.
If anyone has any better suggestions, I'd be very thankful to hear them.
You need to use the "endParagraph" property of the span object to determine if you need to add a "\r" at the end or not. See this Stack Overflow question for some sample code:
Thanks, I'll take a look at that, looks like exactly what I need. My solution did work, but is a bit cumbersome if it's unnecessary.
There's no mention of an 'endParagraph' property in the scripting reference file that I have, not sure why it isn't there if it works.
1 person found this helpful
You will then see all the properties of a span object.
Thanks, that's very helpful!
Is there a way to use this to actually build the richtext for a field? I have several forms which I need to build in the calculate script, but I'm having problems with spacing and certain characters.
I can paste formatted text from Microsoft Word, and the text formatting mostly come in properly (indented bullets, line spacing before) but when I try to build the formatted text, I get characters which are not correct (e.g.bullets, typographer's quotes), and I can now see the values for those using your suggestion, so I think I can get those working.
But, I also have the paragraph line spacing (e.g. 3 pt before each paragraph) and the indents (bullet paragraphs indented 18 pts with first line -18 points and a tab position at 18 pt) that I don't see any information in the span properties.
2 people found this helpful
You can insert special characters using their unicode values, but you can't set things like the line spacing or the indentation.
2 people found this helpful
You can't programmatically "paste" into a rich text value. I've gone down this path multiple times. The Acrobat Properties bar and pasted rich text can do way more formatting than the span object's properties. If you want to set the rich value programmatically, those are the styles you're stuck with.
Thanks, I figured the character codes out (String.fromCharCode(2022) for bullets).
That kinda sucks that I can't set the spacing the way I need to via code to match what can be done via copy/paste.