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.

Can anyone see what I am doing wrong, any recommendations/feedback are
welcome!

public static void main (String[] args) throws FileNotFoundException,
IOException {

    XMLSlideShow ppt = new XMLSlideShow();

    XSLFSlide slide1 = ppt.createSlide();
    XSLFTextBox shape1 = slide1.createTextBox();
    Rectangle anchor = new Rectangle(170, 100, 300, 100);
    shape1.setAnchor(anchor);

    XSLFTextParagraph p1 = shape1.addNewTextParagraph();
    XSLFTextRun r1 = p1.addNewTextRun();
    r1.setText("The Apache POI Project's mission is to create and maintain
Java APIs for manipulating various file formats based upon the Office Open
XML standards (OOXML) and Microsoft's OLE 2 Compound Document format
(OLE2). In short, you can read and write MS Excel files using Java. In
addition, you can read and write MS Word and MS PowerPoint files using
Java. Apache POI is your Java Excel solution (for Excel 97-2008). We have a
complete API for porting other OOXML and OLE2 formats and welcome others to
participate.OLE2 files include most Microsoft Office files such as XLS,
DOC, and PPT as well as MFC serialization API based file formats. Office
OpenXML Format is the new standards based XML file format found in
Microsoft Office 2007 and 2008. This includes XLSX, DOCX and PPTX.
Microsoft opened the specifications to this format in October 2007. We
would welcome contributions.");

    shape1.setTextAutofit(TextAutofit.NORMAL);

    FileOutputStream out = new FileOutputStream("text.pptx");
    ppt.write(out);
    out.close();
    }


-- 

*Apoorva Chaudhari*

The information in this email is confidential and is intended solely for the
addressee(s). Access to this email by anyone else is unauthorized. If you are 
not
an intended recipient, please notify the sender of this email immediately. You
should not copy, use or disseminate the information contained in the email.
Any views expressed in this message are those of the individual sender, except
where the sender specifically states them to be the views of Capco.
http://www.capco.com

Reply via email to