If this is due to a commercial scenario, the Java yFiles graphic drawing library may be suitable for your requirements:
You can use the convenient API to create and stylize a chart and automatically layout the chart with the parameters of lots and lots to limit the resulting layout according to your needs. Multi-line and (simple) HTML tags are ready-made. You can also export to PNG (as well as other pixel-based image formats) and vector graphic formats such as SVG, PDF, EPS.
This can be done both in a regular Java application (Swing), and in a headless environment (for example, to create images on a server and to send them dynamically to an Internet-based thin client).
To understand what can be done with the help of this library, I suggest you take a look at the freely available application for the graphical editor "yEd" which is based on yFiles and allows you to perform the above actions in an interactive way.
(Disclosure: I work for yWorks, but on Stackoverflow I don't represent my employer.)
source share