该文将介绍如何使用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);
}
}
效果图: