How to create PPTX when using POI XSLF?

When I create PPTX with POI XSLF I get blank slide:

XMLSlideShow ppt = new XMLSlideShow();
XSLFSlide slide = ppt.createSlide();
XSLFTextBox shape = slide.createTextBox();
XSLFTextParagraph p = shape.addNewTextParagraph();
XSLFTextRun r1 = p.addNewTextRun();
r1.setText("the");
r1.setFontColor(Color.blue);
r1.setFontSize(24);

OutputStream out = new FileOutputStream("d:/font.pptx");
ppt.write(out);
out.close();

      

Why is the slide blank without any text?

+3


source to share


1 answer


There is no anchor in your textbox (position and size).

You can check POI examples how to add a text field: XSLF Examples - Tutorial 6



XSLFTextBox shape = slide.createTextBox();
shape.setAnchor(new Rectangle(x, y, width, height));

      

+4


source







All Articles