word wrap for legend, note, header, etc.

0 votes
asked Feb 25, 2016 in Wanted features by anonymous
hellow, plantuml is a fantastic project, it works in my work very well.
But I 've put long long paragraphs in legend, so I have to break lines manually avoiding generating a super width image. It causes troubles we I have to modify the paragraph which changes the length of a  line.

3 Answers

0 votes
answered Feb 16, 2018 by DieterVDW
+1 . Line wrapping would be a great feature to have!
0 votes
answered Mar 4, 2021 by J.O. Schmidt


I have also been hoping for a built-in word-wrap function. In the meantime, I have been tinkering with 2 solutions; neither works for universally. 


the following function: $wrap2("text", width). As you can see below, it works well in messages between participants as well as in tables. However, despite protracted fiddling, I am unable to get the text to render properly on its own in a note. The function inserts the "\n" into the output returned variable, but the text is not split over multiple lines...

The link to the code is found here


I also created a procedure $wrap1("text", width). As you see in the below output, text wraps text perfectly in a note, but does not display correctly in a table. Also, this procedure results in a syntax error when used in messages between participants (try line 23).

The link to the code is available here

Ideally, I would like to have a single, unified function/procedure that works for each application. Any help from the community would be very much appreciated! Many thanks in advance. 



commented Mar 4, 2021 by Martin (8,360 points)
edited Mar 4, 2021 by Martin

A very impressive pair of macros.

For WRAP2, can't you just use "note right: $wrap2($test1, 50)" for the note?

(Generally Plantuml has two lots of syntax for everything* depending on whether you are doing multiline with real linefeeds or with \n.  And you can't mix and match.  So which ever macro you choose, you will be restricted to using that form for everything).

* Well not everything, because I don't think you can do a multi-line sequence message between participants using real linefeeds, you can only use \n.  But you do have the maxMessageSize option.

commented Mar 4, 2021 by J. O. Schmidt

Thank you very much, Martin!

Amazing what the addition of one, little colon after the note command can accomplish...
WRAP2 and skinparam maxMessageSize are my two new best friends! laugh

+1 vote
answered Jul 15, 2023 by Potherca (430 points)

You can use wrapWidth and maxMessageSize:

skinparam {
    wrapWidth 400
    maxMessageSize 400

!$test = "The requested resource exists, but the request could not be processed because of a conflict in the current state of the resource. Another user may be trying to assign it at the same time. Please try again in a few minutes. If the problem persists, please contact Client Services for assistance."

A -> B: $test

note right
end note


commented Jan 31 by Berlodo

Great answer @Potherca ! Your solution worked perfectly for me, ( trying to view plantuml Class representation of a Python package & modules that was generated by pylint/pyreverse ... giving very looooong text boxes in the viewer !) Many Thanks yes