Free Support Forum - aspose.com

FitShapeToText bug

Hello, i have a test code which goes like this,

Slide slide = presentation.addEmptySlide();
Table table = slide.getShapes().addTable(500, 500, 3000, 3000, 2, 2);
Cell cell = table.getCell(0, 0);
TextFrame tf = cell.getTextFrame();
tf.setWrapText(false);
tf.setFitShapeToText(true);
Paragraph paragraph = tf.getParagraphs().get(0);
Portion portion = new Portion(“Couuuuuuuuuuuuuuu”);
paragraph.getPortions().add(portion);
presentation.write(new FileOutputStream(“test.ppt”));

So the result expected would be that the first cell is resizing its width dynamically due to the message length…but it doens’t, am i missing something ?

Thanks.

You are not missing anything, but it will not work because of MS-PowerPoint restriction on table and column size.

I am having the same probblem as well

My table width is 1000 and table height is 400

now, what are the restriction in Ms-power point and column size?

Thanks in advance,


The restriction is that MS-PowerPoint does not change the individual cell’s width and wraps the text.

Thanks for the tip.

ok what about if you want the height of the cell/roe to resize automatically?

tfName = myTable.getCell(0, 7).getTextFrame();
tfName.getParagraphs().get(0).getPortions().get(0).setFontBold(true);
tfName.getParagraphs().get(0).getPortions().get(0).setText(textlabelsHashMap.get(“projectPrerequisites”) +": ");


//tfName.fitTextToShape();

tfName.setFitShapeToText(true);



Please note: I have vey long text.

The width of the column will not change but if the text is larger, it will be wrapped and the row height will increase automatically.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please see the attached output of the following code. It was run on Aspose.Slides for JAVA 1.8.4.0.

CODE:

Presentation pres = new Presentation();

Slide sld = pres.getSlideByPosition(1);

//

Table myTable = sld.getShapes().addTable(100, 200, 3000, 2000, 3, 8);

//

TextFrame tfName = myTable.getCell(0, 7).getTextFrame();

tfName.getParagraphs().get(0).getPortions().get(0).setFontBold(true);

tfName.getParagraphs().get(0).getPortions().get(0).setText( "sssssssssssssssssssssssssssssssssssss");

//

//You can change row height or column width

//myTable.setColumnWidth(columnNo, width);

//myTable.setRowHeight(rowNo, height);

//

pres.write(new FileOutputStream( "c:\\outPres.ppt"));

First of all thank you so much for your reply.

>> but if the text is larger, it will be wrapped and the row height will increase automatically.
This is not happening with very long texts. My text is very long
like 20 lines long or so. The cell doesn’t expand to fit all the text.
In other words, I have to drag the bottom border toward the bottom inorder
to see all of my text. Your code works perfectly fine if the text is
short. However, I just tryed it with 20 lines text and I faced the same
problem.
All
I want to achieve is the following: the row height has to be calculated
dynamically, so it shows all the text. As you see in my previous post
(same thread), I tryed different aspose.slides function and I have no
luck.

Thank you in advance,

Moussa

I have created sample ppt file for you that demonstrates the problem
please look at cell 0,6

Thanks in advance

Moussa



We will investigate it, however, you should make use of Table.setRowHeight method to see if it works in your case.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for the invstigation, the content of the cell is dynamic, so the height of the cell should be dynamic as well. An progress on the investigation?

thanks,


Hello,

I am just wondering if you have any updates/news regarding this issue?.

Thanks in advance,

Moussa

Hello,



My client wants this to be fixed ASAP. I am just wondering if you have any good news regarding this problem.

I am not able to upgrade to the new Aspose.Slides due to a faulty behaviour I am getting. please refer to this thread if you would like to know the reason that stops me from upgrading
http://www.aspose.com/community/forums/thread/131096/new-aspose-version.aspx

Your effort is really appreciated,

Moussa


Hello,

I am just wondering if you have any updates/news regarding this issue?.

Thanks in advance,

Moussa

Hello Moussa,

Actually, we are looking for solution last several months and there are no good news.
I even can’t promise we can solve it in the nearest future.

The problem is Java fonts information differ from information provided by .Net so there
is always small error in calculations. In large text error also grow and text wrapping doesn’t work right.

The only solution I can offer is make text shorter and divide it on several paragraphs manually.