How to Add 3 to 4 Lines of Watermark Text to PowerPoint Presentation?

Hi Andrey,
Can you please provide Java code for same lock presentation.
Regards,
Sravan

@ssanex,
I apologize for the code example above. Please try using the following one in Java:

var sourcePresentation = new Presentation("example.pptx");
var slideSize = sourcePresentation.getSlideSize().getSize();
var slideWidth = (float) slideSize.getWidth();
var slideHeight = (float) slideSize.getHeight();

// Prepare a new "locked" presentation.
var lockedPresentation = new Presentation();
lockedPresentation.getSlides().removeAt(0);
lockedPresentation.getSlideSize().setSize(slideWidth, slideHeight, SlideSizeScaleType.DoNotScale);

for (var slide : sourcePresentation.getSlides())
{
    // Create an image of the original slide.
    var slideImage = slide.getThumbnail(1.5f, 1.5f);

    // Add the image to resources of the new presentation.
    var backgroundImage = lockedPresentation.getImages().addImage(slideImage);

    // Add an empty slide to the new presentation.
    var layout = lockedPresentation.getLayoutSlides().getByType(SlideLayoutType.Blank);
    var lockedSlide = lockedPresentation.getSlides().addEmptySlide(layout);

    // Set the slide image as a background for the empty slide.
    lockedSlide.getBackground().setType(BackgroundType.OwnBackground);
    var fillFormat = lockedSlide.getBackground().getFillFormat();
    fillFormat.setFillType(FillType.Picture);
    fillFormat.getPictureFillFormat().setPictureFillMode(PictureFillMode.Stretch);
    fillFormat.getPictureFillFormat().getPicture().setImage(backgroundImage);
}

lockedPresentation.save("locked.pptx", SaveFormat.Pptx);
lockedPresentation.dispose();

sourcePresentation.dispose();

Documents: Presentation Background
API Reference: ISlide interface | IBackground interface

Hi Andrey,
This is don net code not a java code.Could you please provide Java code for same lock presentation.
Regards,
Sravan.

@ssanex,
This is Java code that compiles successfully with JDK 11 and language level 11. Could you please specify the Java language level used in your app?

Hi Andrey,
We are using java 1.8 version.
Regards,
Sravan.

@ssanex,
The following code example shows you how to do the same conversion using JDK 1.8 and Java language level 8:

Presentation sourcePresentation = new Presentation("example.pptx");
Dimension2D slideSize = sourcePresentation.getSlideSize().getSize();
float slideWidth = (float) slideSize.getWidth();
float slideHeight = (float) slideSize.getHeight();

// Prepare a new "locked" presentation.
Presentation lockedPresentation = new Presentation();
lockedPresentation.getSlides().removeAt(0);
lockedPresentation.getSlideSize().setSize(slideWidth, slideHeight, SlideSizeScaleType.DoNotScale);

for (ISlide slide : sourcePresentation.getSlides())
{
    // Create an image of the original slide.
    BufferedImage slideImage = slide.getThumbnail(1.5f, 1.5f);

    // Add the image to resources of the new presentation.
    IPPImage backgroundImage = lockedPresentation.getImages().addImage(slideImage);

    // Add an empty slide to the new presentation.
    ILayoutSlide layout = lockedPresentation.getLayoutSlides().getByType(SlideLayoutType.Blank);
    ISlide lockedSlide = lockedPresentation.getSlides().addEmptySlide(layout);

    // Set the slide image as a background for the empty slide.
    lockedSlide.getBackground().setType(BackgroundType.OwnBackground);
    IFillFormat fillFormat = lockedSlide.getBackground().getFillFormat();
    fillFormat.setFillType(FillType.Picture);
    fillFormat.getPictureFillFormat().setPictureFillMode(PictureFillMode.Stretch);
    fillFormat.getPictureFillFormat().getPicture().setImage(backgroundImage);
}

lockedPresentation.save("locked.pptx", SaveFormat.Pptx);
lockedPresentation.dispose();

sourcePresentation.dispose();

Hi Andrey,
1.We have implemented lock code and watermark slides for PPTx files.After implementing lock functionality it took more time to generate watermark pptx files it took around 2 half minute to generate 91 slides presentation file.Generally we will upload 90 to 150 slides watermark PPTx.It should not take more than 1 mins otherwise our application will not process watermark file since we have limitation to 1 min.
2.We are trying to add watermark text to PPTx files.when we have images in slides watermark is not appearing for plain text it appearing fine. you can refer slide 3,slide 5 and slide 7 we have added watermark text but not appearing in slide 3,slide 5 and slide 7.
and slide 2,slide 4,slide 8 and slide 9 watermark text is coming partially.
Can you please look the above scenarios.watermarked-presentation_latest_url_locked - Copy.zip (2.7 MB)

@ssanex,

PowerPoint documents do not allow you to lock slides. The code example above was suggested simply as a workaround to achieve the same result as demonstrated in the presentation you provided earlier. You can try another way: set locking options for all slide shapes in the original presentation. It should work faster.

It looks like the watermark text was placed behind the images. Please make sure the watermark text is added as a last shape on the slides.

Please share the code snippet

@ssanex,
Please try enumerating all slide objects, use the method getShapeLock and code snippet above to lock the presentation objects. If there is a problem with it, please describe what exactly is not working for you.