满屏斜着的透明水印如何弄 ppt怎么加水印

在前文中,我介绍过如何给PDF文档添加文本和图片水印 。本文将详细讲解如何添加、删除PPT文本和图片水印 。
此次代码示例所用到的工具是Free Spire.Presentation for Java 。Free Spire.Presentation for Java 是一个专业的PowerPoint API,它允许开发人员在Java应用程序中创建、读取、写入、转换和保存PowerPoint文档 。同时,作为一款独立的Java组件,其运行环境无需安装百思特网Microsoft PowerPoint 。
【满屏斜着的透明水印如何弄 ppt怎么加水印】
操作步骤:
通过E-iceblue中文官网下载获取Jar包,解压后将lib文件夹下的Spire.Presentation.jar手动导入Java程序 。
另外,也可通过maven仓库安装产品及导入相关依赖包 。
代码示例示例1 添加图片水印
import com.spire.presentation.*;import com.spire.presentation.drawing.*;import javax.imageio.ImageIO;import java.io.File;public class AddImageWatermark {public static void main(String[] args) throws Exception {//加载示例文档Presentation presentation = new Presentation();presentation.loadFromFile("C:\\Users\\Test1\\Desktop\\Sample.pptx");//获取水印图片File file =new File("C:\\Users\\Test1\\Desktop\\logo.png");IImageData image = presentation.getImages().append(ImageIO.read(file));//获取幻灯百思特网片背景属性,设置图片填充presentation.getSlides().get(0).getSlideBackground().setType(BackgroundType.CUSTOM);presentation.getSlides().get(0).getSlideBackground().getFill().setFillType(FillFormatType.PICTURE);presentation.getSlides().get(0).getSlideBackground().getFill().getPictureFill().setFillType(PictureFillType.STRETCH);presentation.getSlides().get(0).getSlideBackground().getFill().getPictureFill().getPicture().setEmbedImage(image);//保存文档presentation.saveToFile("output/addImageWatermark.pptx", FileFormat.PPTX_2013);}}
添加效果:

示例2 添加文本水印
import com.spire.presentation.*;import com.spire.presentation.drawing.FillFormatType;import java.awt.*;import java.awt.geom.Rectangle2D;public class AddTextWatermark {public static void main(String[] args) throws Exception {//创建presentation对象并加载示例文档Presentation presentation = new Presentation();presentation.loadFromFile("C:\\Users\\Test1\\Desktop\\Sample.pptx");//设置文本水印的宽和高int width= 400;int height= 300;//定义一个长方形区域Rectangle2D.Double rect = new Rectangle2D.Double((presentation.getSlideSize().getSize().getWidth() - width) / 2,(presentation.getSlideSize().getSize().getHeight() - height) / 2, width, height);//添加一个shape到定义区域IAutoShape shape = presentation.getSlides().get(0).getShapes().appendShape(ShapeType.RECTANGLE, rect);//设置shape样式shape.getFill().setFillType(FillFormatType.NONE);shape.getShapeStyle().getLineColor().setColor(Color.white);shape.setRotation(-45);shape.getLocking().setSelectionProtection(true);shape.getLine().setFillType(FillFormatType.NONE);//添加文本到shapeshape.getTextFrame().setText("内部使用");PortionEx textRange = shape.getTextFrame().getTextRange();//设置文本水印样式textRange.getFill().setFillType(FillFormatType.SOLID);textRange.getFill().getSolidColor().setColor(Color.pink百思特网);textRange.setFontHeight(50);//保存文档presentation.saveToFile("output/addTextWatermark.pptx", FileFormat.PPTX_2010);}}
添加效果:

示例3 删除文本和图片水印
import com.spire.presentation.*;import com.spire.presentation.drawing.*;public class DeleteWatermark {public static void main(String[] args) throws Exception {//加载示例文档Presentation presentation = new Presentation();presentation.loadFromFile("C:\\Users\\Test1\\Desktop\\Sample.pptx");//移除文本水印for (int i = 0; i

    推荐阅读