This article demonstrates how to horizontally and vertically align a table in a slide using Spire.Presentation for Java.
Below is a screenshot of the sample document.
import com.spire.presentation.FileFormat; import com.spire.presentation.ITable; import com.spire.presentation.Presentation; import com.spire.presentation.ShapeAlignmentEnum; public class AlignTable { public static void main(String[] args) throws Exception { //Create a Presentation object Presentation presentation = new Presentation(); //Load the sample PowerPoint document contain presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\sample.pptx"); //Declare a ITable variable ITable table = null; //Loop through the shapes in the first slide for (Object shape: presentation.getSlides().get(0).getShapes() ) { //Check if shape is an instance of ITable if (shape instanceof ITable) { //Convert shape to table table =(ITable)shape; } } //Horizontally align table to center table.setShapeAlignment(ShapeAlignmentEnum.ShapeAlignment.AlignCenter); //Vertically align table to middle table.setShapeAlignment(ShapeAlignmentEnum.ShapeAlignment.AlignMiddle); //Save to file presentation.saveToFile("AlignTable.pptx", FileFormat.PPTX_2013); } }