Java (485)
Detect if an Excel Document is Password Protected in Java
2020-06-02 08:23:45 Written by AdministratorThis article demonstrates how to detect whether an Excel document is password protected or not using Spire.XLS for Java.
import com.spire.xls.*;
public class DetectProtectedOrNot {
public static void main(String[] args) {
//Get the file path
String filePath= "C:\\Users\\Administrator\\Desktop\\sample.xlsx";
//Detect whether the workbook is password protected or not
Boolean isProtected = Workbook.isPasswordProtected(filePath);
//Print results
if (isProtected) {
System.out.print("The document is password protected.");
}
else {
System.out.print("The document is not protected.");
}
}
}

Published in
Security
Tagged under
Java remove text or image watermark from presentation slides
2020-06-01 06:23:35 Written by AdministratorThis article will demonstrate how to use Spire.Presentaion for Java to remove text watermark and image watermark from the presentation slides.
Firstly, view the sample PowerPoint document with text and image watermark:

import com.spire.presentation.*;
import com.spire.presentation.drawing.*;
public class removeTextOrImageWatermark {
public static void main(String[] args) throws Exception {
//Load the sample document
Presentation presentation = new Presentation();
presentation.loadFromFile("Sample.pptx");
//Remove text watermark by removing the shape which contains the string "E-iceblue".
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);
}
}
}
}
//Remove image watermark
for (int i = 0; i < presentation.getSlides().getCount(); i++)
{
presentation.getSlides().get(i).getSlideBackground().getFill().setFillType(FillFormatType.NONE);
}
//Save to file.
presentation.saveToFile("removeTextOrImageWatermark.pptx", FileFormat.PPTX_2013);
}
}
Effective screenshot after removing text or image watermark:

Published in
Watermark
Tagged under
We have introduced how to use Spire.Presentaion for Java to add text watermark to PowerPoint document. This article will demonstrate how to add image watermark to presentation slides in java applications.
Firstly view the sample PowerPoint document:

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 {
//Create a PowerPoint document.
Presentation presentation = new Presentation();
//Load the file from disk.
presentation.loadFromFile("Sample.pptx");
//Get the image you want to add as image watermark.
File file =new File("logo.png");
IImageData image = presentation.getImages().append(ImageIO.read(file));
//Set the properties of SlideBackground, and then fill the image as watermark.
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);
String result = "addImageWatermark.pptx";
//Save to file.
presentation.saveToFile(result, FileFormat.PPTX_2013);
}
}
Effective screenshot after adding image watermark to PowerPoint document:

Published in
Watermark
Tagged under