Apologies if I have overlooked something: is there a way to get the length in twips or points of the text that is held in an XWPFParagraph. I could achieve it using Font And FontMetrics separately but that seems clunky. Any help will be much appreciated.
i I've searched what I hoped were the relevant Apache Javadocs.
While calculating text length using font metrics may seem a bit cumbersome, it's a common approach across various libraries and frameworks. However, if you're looking for a potentially less clunky method within Apache POI specifically, you might consider using the Graphics2D class from AWT (Abstract Window Toolkit) for font metrics. Here's the implementation in a simplified example:
While it may not significantly reduce the clunkiness, it abstracts away some of the direct font manipulation and calculation, making the code slightly cleaner.