/
AsposeReplaceTxtInPlaceHolders.java
42 lines (34 loc) · 1.22 KB
/
AsposeReplaceTxtInPlaceHolders.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.aspose.slides.examples.asposefeatures.presentation.replacetxtinplaceholders;
import com.aspose.slides.IAutoShape;
import com.aspose.slides.IShape;
import com.aspose.slides.ISlide;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import com.aspose.slides.examples.Utils;
public class AsposeReplaceTxtInPlaceHolders
{
public static void main(String[] args)
{
// The path to the documents directory.
String dataDir = Utils.getDataDir(AsposeReplaceTxtInPlaceHolders.class);
// Instantiate Presentation class that represents PPTX
Presentation pres = new Presentation(dataDir + "demo.pptx");
// Access first slide
ISlide slide = pres.getSlides().get_Item(0);
IShape shape = null;
// Iterate through the shapes and set a reference to the table found
for (int i = 0; i < slide.getShapes().size(); i++)
{
shape = slide.getShapes().get_Item(i);
if (shape.getPlaceholder() != null)
{
// Change the text of each placeholder
((IAutoShape) shape).getTextFrame().setText("This is Placeholder");
}
}
// Write the PPTX to Disk
pres.save(dataDir + "AsposeReplaceTxt.pptx", SaveFormat.Pptx);
// Status
System.out.println("Process completed successfully.");
}
}