Remove text watermark

Dear Team,

Please provide source code in JAVA to remove text watermark from
Excel, PPT, Word, Pdf and images files.

@praveen043

Thank you for contacting support.

You may remove watermark text from Word documents with Aspose.Words for Java, as explained in Working with Watermark.

For other file formats, please share sample documents as ZIP files so that we may investigate further and assist you accordingly.

Dear Team,

Please find the attached document for remove the watermark.WaterMarkRemove.zip (669.9 KB)

WaterMarkRemove.zip (557.9 KB)

Please find the attached document with watermark.

@praveen043

Thanks for sharing the documents.

To remove watermark from XLSX, please use the following code example.

Workbook wb = new Workbook("c:\\temp\\Test_xlsx_20181119_4042.xlsx");
Worksheet ws = wb.getWorksheets().get(0);
int cnt = ws.getShapes().getCount();
System.out.println(cnt);
for (int i = cnt-1; i >=0; i--)
{
    Shape shape = ws.getShapes().get(i);
    if (shape.isWordArt())
    {
        ws.getShapes().remove(shape);
    }
}
wb.save("c:\\temp\\out1.xlsx");

Following code example shows how to remove watermark from PPTX.

String path="C:\\temp\\Watermark\\";
String WatermarkText="test_kunalmalani@samil.motherson.com";
com.aspose.slides.Presentation pres = new com.aspose.slides.Presentation(path+"Test_Pptx_20181119_4047.pptx");
com.aspose.slides.ISlideCollection slds = (com.aspose.slides.ISlideCollection) pres.getSlides();

IMasterSlide master=pres.getMasters().get_Item(0);
for(int i=0;i<master.getShapes().size();i++)
{
    IShape shape=master.getShapes().get_Item(i);
    if(shape instanceof IAutoShape)
    {
        IAutoShape ashp=(IAutoShape)shape;
        if(ashp.getTextFrame()!=null)
        {
            if(ashp.getTextFrame().getText().compareTo(WatermarkText)==0)
            {
                master.getShapes().remove(shape);

            }
        }
    }

}
pres.save("c:\\temp\\RemovedWatermark.pptx", SaveFormat.Pptx);

Please use following code example to remove the watermark from the Word document.

Document doc = new Document(MyDir + "Test_Docx_20181119_4132.docx");
for(Section section : doc.getSections())
{
    for(HeaderFooter headerFooter : section.getHeadersFooters())
    {
        NodeCollection shapes = headerFooter.getChildNodes(NodeType.SHAPE, true);
        for (Shape shape : (Iterable<Shape>) shapes)
        {
            if(shape.getTextPath() != null && shape.getTextPath().getText().trim().length() > 0)
                shape.remove();
        }
    }
}
doc.save(MyDir + "output.docx");