Java (486)
This article demonstrates how to get the position of text in PowerPoint in Java using Spire.Presentation for Java.
import com.spire.presentation.IAutoShape;
import com.spire.presentation.ISlide;
import com.spire.presentation.Presentation;
import java.awt.geom.Point2D;
public class GetPositionOfText {
public static void main(String []args) throws Exception {
//Create a Presentation instance
Presentation ppt = new Presentation();
//Load a PowerPoint document
ppt.loadFromFile("Sample.pptx");
//Get the first slide
ISlide slide = ppt.getSlides().get(0);
//Get the first shape
IAutoShape shape = (IAutoShape)slide.getShapes().get(0);
//Get location of text in the shape
Point2D location =shape.getTextFrame().getTextLocation();
//Print out the x and y coordinates of the location relative to slide
String point1="Text's position relative to Slide: x= "+location.getX()+" y = "+location.getY();
System.out.println(point1);
//Print out the x and y coordinates of the location relative to shape
String point2 = "Text's position relative to shape: x= " + (location.getX() - shape.getLeft()) + " y = " + (location.getY() - shape.getTop());
System.out.println(point2);
}
}
Output:

Published in
Paragraph and Text
Tagged under
Evenly Distribute Rows and Columns in PowerPoint Table in Java
2021-06-22 03:35:14 Written by KoohjiThis article demonstrates how to evenly distribute the rows and columns of a PowerPoint table using Spire.Presentation for Java.
The input document:

import com.spire.presentation.FileFormat;
import com.spire.presentation.ISlide;
import com.spire.presentation.ITable;
import com.spire.presentation.Presentation;
public class DistributeRowsAndColumns {
public static void main(String []args) throws Exception {
//Create a Presentation instance
Presentation ppt = new Presentation();
//Load the PowerPoint document
ppt.loadFromFile("Input.pptx");
//Get the first slide
ISlide slide = ppt.getSlides().get(0);
//Get the table in the slide
ITable table = (ITable) slide.getShapes().get(0);
//Distribute table rows
table.distributeRows(0,4);
//Distribute table columns
table.distributeColumns(0,4);
//Save the result document
ppt.saveToFile("DistributeRowsAndColumns.pptx", FileFormat.PPTX_2013);
}
The output document:

Published in
Table
Tagged under
This article demonstrates how to apply transparency to text in PowerPoint using Spire.Presentation for Java.
import com.spire.presentation.*;
import com.spire.presentation.drawing.FillFormatType;
import java.awt.*;
import java.awt.geom.Rectangle2D;
public class ApplyTransparency {
public static void main(String[] args) throws Exception {
//Create a PowerPoint document
Presentation presentation = new Presentation();
presentation.getSlideSize().setType(SlideSizeType.SCREEN_16_X_9);
//Add a shape
IAutoShape textbox = presentation .getSlides().get(0).getShapes().appendShape(ShapeType.RECTANGLE,new Rectangle2D.Float(50, 70, 300, 120));
textbox.getShapeStyle().getLineColor().setColor(new Color(1,1,1,0));
textbox.getFill().setFillType(FillFormatType.NONE);
//Remove default paragraphs
textbox.getTextFrame().getParagraphs().clear();
//Add three paragraphs and apply colors with different alpha values to the text
int alpha = 55;
for (int i = 0; i < 3; i++)
{
textbox.getTextFrame().getParagraphs().append(new ParagraphEx());
textbox.getTextFrame().getParagraphs().get(i).getTextRanges().append(new PortionEx("Text Transparency"));
textbox.getTextFrame().getParagraphs().get(i).getTextRanges().get(0).getFill().setFillType(FillFormatType.NONE);
textbox.getTextFrame().getParagraphs().get(i).getTextRanges().get(0).getFill().setFillType(FillFormatType.SOLID);
textbox.getTextFrame().getParagraphs().get(i).getTextRanges().get(0).getFill().getSolidColor().setColor(new Color(176, 48, 96, alpha));
alpha += 100;
}
//Save to file
presentation.saveToFile("TextTransparency.pptx", FileFormat.PPTX_2013);
}
}

Published in
Paragraph and Text
Tagged under