You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Yegor Kozlov <ye...@dinom.ru> on 2006/06/08 09:41:02 UTC

Re[2]: org.apache.poi.hslf.model.TextRun

Hi

TextRun is just a holder of the text. If you want to work with shapes
you should use Slide.getShapes() which returns a collection of shapes
in the slide:


        SlideShow ppt = new SlideShow(new HSLFSlideShow(filename));

        Dimension pgsize = ppt.getPageSize(); //page size
        
        Slide sl = ppt.getSlides()[0];
        Shape[] sh = sl.getShapes();
        for (int i = 0; i < sh.length; i++) {
            //anchor of the shape
            java.awt.Rectangle anchor = sh[i].getAnchor();
            
            if (sh[i] instanceof TextBox){
               TextBox box = (TextBox)
               String text = box.getText();
               String font = box.getFontName();
               int size = box.getFontSize();
               ...
            }
       }

Warning: In the current implementation  you can get text attributes only if
they are explicitly set. For example, if you don't change the default
font size box.getFontSize() return -1 which means n/a. In this case PowerPoint
uses the default font size which is stored in special container
TxMasterStyleAtom which is not decoded yet.
Also the object model for working with character/paragraph attributes
is likely to change. Current code is rather demonstration of
capabilities, not the final version.


Some documentation is available at
       
http://jakarta.apache.org/poi/hslf/how-to-shapes.html


Regards, Yegor
       
EE> I am asking about the TextRun[] return from the method
EE> org.apache.poi.hslf.model.Slide.getTextRuns().


EE> For each TextRun, I want to know its x/y position.




EE> -----Original Message-----
EE> From: Nick Burch [mailto:nick@torchbox.com] 
EE> Sent: Wednesday, June 07, 2006 5:05 PM
EE> To: Erez Eisenstein
EE> Cc: POI Users List
EE> Subject: Re: org.apache.poi.hslf.model.TextRun

EE> Please always use the lists for asking POI questions.

EE> On Wed, 7 Jun 2006, Erez Eisenstein wrote:
>> How can I get the position (x,y coordinates) of a TextRun in the
EE> slide?

EE> That depends on what kind of text run it is. If it's text positioned 
EE> acording to the master slide, then because we don't currently grok the 
EE> master slides, that information isn't available.

EE> If it's a text run stored in an Escher object (EscherTextboxWrapper),
EE> you 
EE> can get some information on the object's position from the parent Escher

EE> objects.

EE> Nick

EE> ---------------------------------------------------------------------
EE> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
EE> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
EE> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/