Split dynamic text in data driven Pages?

5054
5
Jump to solution
03-10-2015 02:11 AM
JohannesBierer
Occasional Contributor III

Is this possible? And how?

0 Kudos
1 Solution

Accepted Solutions
KishorGhatage
Occasional Contributor III

Yes, it is possible. Just use '\n' to split the text.

Could you please provide an example of text and how it should be split.

View solution in original post

5 Replies
KishorGhatage
Occasional Contributor III

Yes, it is possible. Just use '\n' to split the text.

Could you please provide an example of text and how it should be split.

JohannesBierer
Occasional Contributor III

Thanks Kishor, that's it. But in your solution I have to edit the attributes.

Is there also a possibility to do this automatically? Split the text in a certain lenght without editing the attributes?

0 Kudos
by Anonymous User
Not applicable

Yes, same question here.

0 Kudos
NeilAyres
MVP Alum

Well, something like this will split a text string into bit sized bits...

>>> veryLongText = "ahdsgs hdfgsdt jshsst ktpoiyus lorhsjks lsoshft dfagwqrt"
>>> textLen = 10
>>> while len(veryLongText) > 0:
...     newText = veryLongText[:textLen]
...     print newText
...     veryLongText = veryLongText[textLen:]
...     
ahdsgs hdf
gsdt jshss
t ktpoiyus
 lorhsjks 
lsoshft df
agwqrt
>>>
0 Kudos
DavidBarnes
Occasional Contributor III

If the text has spaces and you put it in a rectangle (or other shape) text graphic (see text tool palette in the Draw toolbar) the text will break at spaces when it exceeds the width of the rectangle/shape. For this to work well you would need to make sure the rectangle is wide enough to accommodate the longest piece of text without spaces. If there are parts of the string that are short enough to fit the width, even if there are spaces in between, it won't wrap those; just the lines that are too long to fit.

If the text doesn't have spaces you'll need other solutions, such as one of the ones given above.

0 Kudos