none
Power Point pptx auto fit text RRS feed

  • Question

  • Hello!

    I am writing a pptx generator. I am putting text into slides. I want that it take determine width. For excample, text "param pam pam" should take 1.5 inch. For it purpose I put <a:normAutofit /> in <a:bodyPr ..> in <p:txBody> in... slideN.xml

    If generated xml text block has not enough width to contain some text, than some part of this text will be translate to next line in text block. I use <a:normAutofit /> http://msdn.microsoft.com/en-us/library/documentformat.openxml.drawing.normalautofit(v=office.14).aspx without attributes (fontScale, lnSpcReduction) because I don’t know what ratio I need in each textblock. But if I use PowerPoint application to open my generated file and after it I change some shape position, than PowerPoint automatically rebuild all text blocks on slide in a right way. As result my text "param pam pam" takes 1.5 inch.

    Question is: how rebuild all text in my presentation automatically? Can I do it in XML or I need use PowerPoint COM model?

    I tried to open my generated pptx throw PowerPoint COM model. Then I made some modification (text was rebuild), then I saved presentation and it looked like ok. But when I used presentation with many slides (1300 for example ), I got rebuild text only on first several slides, all other slides had “bad” text.

    My next try was:  I tried to make modification throw COM model to each slide in cycle and I resaved presentation. I got document with some bad text and some good text…

    Next test: I tried to do it  throw PowerPoint by hands. I opened presentation and began make changes in each few slides, the result was ok – text on all processed slides has been rebuild. After it I renamed pptx file to the zip, uncompressed it and looked on slideN.xml. I had found than PowerPoint added fontScale and lnSpcReduction attributes with different values.

    How to make autofit in whole document? I hope PowerPoint COM model has some “refresh/update” method which can guaranty rebuild all text in document. Or OpenXML has some flag which can help me.

    Part of my bigtest pptx you can find here

    https://onedrive.live.com/redir?resid=D3D1964EFDBEF026!291&authkey=!AB68jEPGOM94Yrw&ithint=file%2c.pptx



    Friday, April 25, 2014 11:53 AM

Answers

  • I'm afraid there is no way to make autofit in whole document.

    The better solution is that you need to input content which is in one slide into a textbox, all content in this textbox will not be out of width and height will be increase automatically base on content.

    Monday, April 28, 2014 7:19 AM

All replies

  • I'm afraid there is no way to make autofit in whole document.

    The better solution is that you need to input content which is in one slide into a textbox, all content in this textbox will not be out of width and height will be increase automatically base on content.

    Monday, April 28, 2014 7:19 AM
  • I am not advanced powerpoint xml user.

    "The better solution is that you need to input content which is in one slide into a textbox, all content in this textbox will not be out of width and height will be increase automatically base on content."

    How to do it? My generated slide1.xml looks like

    <p:sp>
                <p:nvSpPr>
                   <p:cNvPr id="1" name="text 1" />
                   <p:cNvSpPr txBox="1" />
                   <p:nvPr />
                </p:nvSpPr>
                <p:spPr>
                   <a:xfrm>
                      <a:off x="1620499" y="1110343" />
                      <a:ext cx="1602304" cy="185577" />
                   </a:xfrm>
                   <a:prstGeom prst="rect">
                      <a:avLst />
                   </a:prstGeom>
                </p:spPr>
                <p:txBody>
                <a:bodyPr wrap="none" lIns="0" tIns="0" rIns="0" bIns="0" rtlCol="0" vert="horz">
    			<a:spAutoFit />
                   </a:bodyPr>
                   <a:lstStyle />
                   <a:p>
                      <a:pPr marL="0">
                         <a:lnSpc>
                            <a:spcPct val="100000" />
                         </a:lnSpc>
                      </a:pPr>
                      <a:r>
                         <a:rPr sz="1200" spc="10" dirty="0">
                            <a:latin typeface="Times New Roman" />
                            <a:cs typeface="Times New Roman" />
                         </a:rPr>
                         <a:t>param pam pam ruram. some text not in main bound</a:t>
                      </a:r>
                      <a:endParaRPr sz="1200">
                         <a:latin typeface="Times New Roman" />
                         <a:cs typeface="Times New Roman" />
                      </a:endParaRPr>
                   </a:p>
                </p:txBody>
             </p:sp>

    as a result I have textbox which has "some text not in main bound" text out of box.

    how to expand box's width according to containing text width? (I dont know how many space it will be need)



    Monday, May 12, 2014 12:26 PM
  • If I insert a textbox and input some text as below:

    Slide1.xml looks like:

    <p:sp>
            <p:nvSpPr>
              <p:cNvPr id="7" name="TextBox 6" />
              <p:cNvSpPr txBox="1" />
              <p:nvPr />
            </p:nvSpPr>
            <p:spPr>
              <a:xfrm>
                <a:off x="1319645" y="904009" />
                <a:ext cx="1953491" cy="923330" />
              </a:xfrm>
              <a:prstGeom prst="rect">
                <a:avLst />
              </a:prstGeom>
              <a:noFill />
            </p:spPr>
            <p:txBody>
              <a:bodyPr wrap="square" rtlCol="0">
                <a:spAutoFit />
              </a:bodyPr>
              <a:lstStyle />
              <a:p>
                <a:r>
                  <a:rPr lang="en-US" dirty="0" err="1" smtClean="0" />
                  <a:t>param</a:t>
                </a:r>
                <a:r>
                  <a:rPr lang="en-US" dirty="0" smtClean="0" />
                  <a:t> pam </a:t>
                </a:r>
                <a:r>
                  <a:rPr lang="en-US" dirty="0" err="1" smtClean="0" />
                  <a:t>pam</a:t>
                </a:r>
                <a:r>
                  <a:rPr lang="en-US" dirty="0" smtClean="0" />
                  <a:t>
                  </a:t>
                </a:r>
                <a:r>
                  <a:rPr lang="en-US" dirty="0" err="1" smtClean="0" />
                  <a:t>ruram</a:t>
                </a:r>
                <a:r>
                  <a:rPr lang="en-US" dirty="0" smtClean="0" />
                  <a:t>. some text not in main bound</a:t>
                </a:r>
                <a:endParaRPr lang="en-US" dirty="0" />
              </a:p>
            </p:txBody>
          </p:sp>
    

    You need to insert some run elements under this paragraph:

    Tuesday, May 13, 2014 1:32 AM
  • This is way to expand textbox in height. But I need to expend it in width. 

    Ideally, it should look like this

    Maybe, it is very large string. In my test usually I get something like this

    Rigth rectangle border should be red border.

    The aim is - to expend textblock's width according to text width inside.

    I have tried several tests with <a:spAutoFit />, <a:normAutoFit />, <a:noAutoFit /> and <a:bodyPr wrap="square" rtlCol="0">, <a:bodyPr wrap="none" rtlCol="0">, but I got no good result.

    Do power point has any other parameters which can determinate box behavior according to text inside?

    Tuesday, May 13, 2014 12:00 PM
  • Microsoft does not provide how he dynamically calculates width.

    AutoFit is just a properties but no actual meaning.

    If the content is not fixed, you need to find its length and set the width with the length.

    This is my opinion.

    Wednesday, May 14, 2014 3:03 AM
  • Thanks for the help.
    Wednesday, May 14, 2014 7:31 AM