Darren Roberts <robertsdjguard-poi <at> yahoo.com> writes: > > > What you're doing appears to be technically correct, but has I think exposed a limitation in that part of the > library. The specification says that the normAutofit element in the XML has an attribute called > fontScale which if omitted then a scale of 100% is implied, which is probably why you see your text spilling > over the shape in Powerpoint as it is being rendered at normal size. When you resize the shape by a fraction > in Powerpoint it knows you want autofit, so recalculates and sets the scale, which is why you then see it correctly. > > The XSLFTextShape class merely sets the normAutofit element when you call > > shape1.setTextAutofit(TextAutofit.NORMAL); > > but doesn't set the fontScale attribute (and certainly doesn't calculate it for you). Unfortunately > there doesn't appear to be a way for you to directly set the fontScale attribute at the moment, you would > need to delve into the underlying XML objects for the shape to do that. > Equally calculating the size of the text could get interesting taking into account all the spacing, > justification etc, but once you have that and you know the size of the anchor then it would be relatively > straight-forward to calculate the scaling percentage you need to make the text fit; then it's just a case > of setting the fontScale attribute. > > I may of course be wrong, but that's based on my knowledge of the DrawingML spec relating to textboxes. > > If you aren't in a position to implement and contribute a fix can I ask you to please raise it as bug, as I have a > feeling when I get to the Powerpoint output side of my project I'll need this too, and if it hasn't already > been picked up by someone then I'll have to look at doing it. > > Regards > Darren > > >________________________________ > > From: "Chaudhari, Apoorva" <apoorva.chaudhari <at> capco.com> > >To: user <at> poi.apache.org > >Sent: Monday, August 5, 2013 4:05 AM > >Subject: Text Auto fit function in XSLF POI not working > > > > > >Hello everyone, > > > >I have issues with the implementation of the text auto fit function > >available in POI. I have a code snipplet here, where I want that the > >overflow text ( greater than the size of the anchor ) gets resized to a > >smaller font and fit within the TextBox bounds. However, it doesnt do that. > >BUT if you manually try to resize it, meaning if you try to increase or > >decrease the size of the textbox by even a very small amount, the text gets > >reduced to the size of the font that it should be, to fit within that text > >box.
Hi Darren, Thank you for your insight, I will raise this as a bug as you suggested. Thanks. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
