Bug 55391 - Text Auto fit function in XSLF POI not working
Summary: Text Auto fit function in XSLF POI not working
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XSLF (show other bugs)
Version: 3.9-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-08 14:06 UTC by Apoorva
Modified: 2013-09-18 11:45 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Apoorva 2013-08-08 14:06:50 UTC
I was asked to raise this as a bug: http://article.gmane.org/gmane.comp.jakarta.poi.user/19987

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.



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();
    }
Comment 1 isontheline 2013-09-18 11:45:51 UTC
I encounter the same bug for same things.

If the PPTX document already contains "TextAutofit.NORMAL" (build by PowerPoint option) the rendered PPTX is good but not the PNG from the PPTX.