> but I dont see any method in XSLFTextShape to know the > original height of the text box the original height of the text box is the anchor height.
here is an example, which stops (usually) when the textbox is full.
public void overflow() throws Exception {
boolean useXml = false;
try (SlideShow ppt = (useXml ? new XMLSlideShow() : new HSLFSlideShow())) {
// intialize Slide slide = ppt.createSlide();
TextBox box = slide.createTextBox();
box.setAnchor(new Rectangle2D.Double(100,100,300,300));
box.setStrokeStyle(Color.RED);
box.setInsets(new Insets2D(0,0,0,0));
// Compare height final double maxHeight = box.getAnchor().getHeight();
// randomize Random rnd = new Random();
double textHeight = 0;
while (textHeight < maxHeight) {
TextRun tr = box.appendText("blub ", textHeight > 0 &&
rnd.nextBoolean());
for (int i=rnd.nextInt(5); i>0; i--) {
switch (rnd.nextInt(5)) {
case 0:
tr.setFontSize(2. + rnd.nextInt(20));
break;
case 1:
tr.setBold(rnd.nextBoolean());
break;
case 2:
tr.setFontColor(new Color(rnd.nextInt(0xFFFFFF)));
break;
case 3:
tr.setUnderlined(rnd.nextBoolean());
break;
case 4:
tr.setFontFamily(rnd.nextBoolean() ? "Arial" : "Courier
New");
break;
}
}
textHeight = box.getTextHeight();
}
try (FileOutputStream fos = new
FileOutputStream("blub.ppt"+(useXml?"x":""))) {
ppt.write(fos);
}
}
}
signature.asc
Description: OpenPGP digital signature
