We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cell y position is wrong

I've just noticed my code no longer get the correct y position of the textframe of a cell. I create a table of four rows and one column and interate through them to get the Y postion of the four cells.Each row is 328 in height and the table starts at the y position of 300. However every time I get the y position of each cell in the table it is way out.

first row Y position via cell textframe = 300

second row Y position via cell textframe = 2860

third row Y position via cell textframe = 5420

fourth row Y position via cell textframe = 7980

I can't work out what is going wrong as this happens as soon as the table is created. If I change the table the Y positions do not alter or if they do they are still widely out.

Regards

Harry

Dear Harry,

It will be because of font height in TextFrame.

As an illustration, create a table in MS-PowerPoint, try to reduce it as much as possible. You will see, the table does not reduce more than a certain height.

Now, click inside the table and notice the font height, in my case it is Arial 28

Now, select the entire table, and change the font height to Arial 16 and again try to reduce the height of the table by dragging its bottom-right corner upward.

You will see, now you are able to reduce table height even more.

This is the same reason that you create a table with certain height and width but it gets adjusted by Aspose.Slides.

Hello,

I have run the following code using Aspose.Slides for JAVA 1.9 and the output of the code is exactly what is expected as mentioned in the comments.

//Create a presentation

Presentation pres = new Presentation();

//Get the first slide

Slide sld = pres.getSlideByPosition(1);

//Table height and its rows height will adjust automatically

//because of default font height 28

Table tbl=sld.getShapes().addTable(300, 300, 3000, 200, 2, 4);

//Read the Y position of each row

//Each row height is 328, so the

//Y positon of 1st Row=300 + 0 * 328 = 300

//Y positon of 2nd Row=300 + 1 * 328 = 628

//Y positon of 3rd Row=300 + 2 * 328 = 956

//Y positon of 4th Row=300 + 3 * 328 = 1284

for (int i = 0; i < tbl.getRowsNumber(); i++)

{

TextFrame tf = tbl.getCell(1, i).getTextFrame();

System.out.println(tf.getY());

}

I ran this code and also set all the text frames in each cell to font 12 and still the Y positions of the cell come back wrong. The table it self is draws correctly but I use the X and Y position of the cells to position other slide objects on top and these are way out.

row1 300

row2 2860

row3 5420

row4 7980

Could I be setting something globally to make this happen. Like I say the table itself displays perfectly but the positions of the cell are not coect.

regards

Harry

Can you please test it with the Aspose.Slides for Java 1.9.0?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />