该文将介绍如何使用Spire.Presentation for Java移除幻灯片中的文本和图片水印。
示例文档:
import com.spire.presentation.*;
import com.spire.presentation.drawing.*;
public class removeTextOrImageWatermark {
public static void main(String[] args) throws Exception {
//加载示例文档
Presentation presentation = new Presentation();
presentation.loadFromFile("Sample.pptx");
//移除文本水印
for (int i = 0; i < presentation.getSlides().getCount(); i++)
{
for (int j = 0; j < presentation.getSlides().get(i).getShapes().getCount(); j++)
{
if (presentation.getSlides().get(i).getShapes().get(j) instanceof IAutoShape)
{
IAutoShape shape = (IAutoShape)presentation.getSlides().get(i).getShapes().get(j);
if (shape.getTextFrame().getText().contains("E-iceblue"))
{
presentation.getSlides().get(i).getShapes().remove(shape);
}
}
}
}
//移除图片水印
for (int i = 0; i < presentation.getSlides().getCount(); i++)
{
presentation.getSlides().get(i).getSlideBackground().getFill().setFillType(FillFormatType.NONE);
}
//保存文档
presentation.saveToFile("removeTextOrImageWatermark.pptx";, FileFormat.PPTX_2013);
}
}
效果图: