Watermark in Diagonal Manner and Creating Footer in PowerPoint Using Aspose.Slides for Java API

@andrey.potapov Is it possible to print watermark in diagonal manner and creating footer in powerpoint using Aspose Slides Java API.

Also is it possible to print the date and time in footer programmatically?

@sabkan,
Thank you for contacting support.

Yes, you can rotate watermarks just like any other shape in a PowerPoint presentation using Aspose.Slides for Java.

watermarkShape.setRotation(float);

More examples:

I am working on the question and will get back to you soon.

@sabkan,
To add the date and time to the footer of slides, you can use the IPresentationHeaderFooterManager interface from a Presentation object like this:

presentation.getHeaderFooterManager().setAllDateTimesVisibility(true);

More examples:

@andrey.potapov Thanks for the details. Shall check.

@sabkan,
Thank you for using Aspose.Slides.

@andrey.potapov When trying the code snippet attached, watermark comes in next screen when we scroll down.
Am attaching the screenshot of the slide and also the code snippet for your reference as a zip.
Any suggestions?
details.zip (104.5 KB)

@andrey.potapov Wanted watermark to come diagonally across the slides.

@sabkan,
I have corrected your code example. Please use the following code:

String presentationFilePath = "sample.pptx";
String watermarkText = "Confidential";
float watermarkAngle = -45;
float watermarkFontHeight = 52;
Color watermarkColor = new Color(200, 200, 200, 150);

var presentation = new Presentation(presentationFilePath);

Dimension2D slideSize = presentation.getSlideSize().getSize();

float x = 0;
float y = 0;
float width = (float) slideSize.getWidth();
float height = (float) slideSize.getHeight();

for (ISlide slide : presentation.getSlides()) {
    IAutoShape watermarkShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, x, y, width, height);

    watermarkShape.getFillFormat().setFillType(FillType.NoFill);
    watermarkShape.getLineFormat().getFillFormat().setFillType(FillType.NoFill);

    watermarkShape.setRotation(watermarkAngle);

    ITextFrame watermarkTextFrame = watermarkShape.addTextFrame(watermarkText);

    IPortion watermarkTextPortion = watermarkTextFrame.getParagraphs().get_Item(0).getPortions().get_Item(0);
    watermarkTextPortion.getPortionFormat().setFontHeight(watermarkFontHeight);

    IFillFormat fillFormat = watermarkTextPortion.getPortionFormat().getFillFormat();
    fillFormat.setFillType(FillType.Solid);
    fillFormat.getSolidFillColor().setColor(watermarkColor);

    watermarkShape.getAutoShapeLock().setSelectLocked(true);
    watermarkShape.getAutoShapeLock().setSizeLocked(true);
    watermarkShape.getAutoShapeLock().setTextLocked(true);
    watermarkShape.getAutoShapeLock().setPositionLocked(true);
    watermarkShape.getAutoShapeLock().setGroupingLocked(true);
}

presentation.save("output.pptx", SaveFormat.Pptx);
presentation.dispose();

files.zip (41.1 KB)

@andrey.potapov Thanks it worked.
What was the issue with my earlier code. Just curious.
Which line was the issue?

@sabkan,
We are glad to know that the issue has been resolved on your end.

The position of the watermark shape was incorrect.