The Watermark Does Not Appear above Tables on Slides in a PowerPoint Presentation

Hi
When trying to watermark powerpoint slides using Aspose Slides for Java api, it is not showing watermark on the slides in the portion where tables are there.

Any suggestions for that?

This is the code snippet used:

IMasterSlideCollection presCollection = pres.getMasters();
for (IMasterSlide master : presCollection) {
    //IMasterSlide master = pres.getMasters().get_Item(0);
    //IAutoShape watermarkShape = master.getShapes().addAutoShape(ShapeType.Rectangle, 0, 0, 0, 0);
    //ITextFrame watermarkTextFrame = watermarkShape.addTextFrame(watermarkText);

    Point2D.Float center = new Point2D.Float((float) pres.getSlideSize().getSize().getWidth() / 2,
            (float) pres.getSlideSize().getSize().getHeight() / 2);

    float width = 300;
    float height = 300;
    float x = (float) center.getX() - width / 2;
    float y = (float) center.getY() - height / 2;

    // Add shape
    IAutoShape watermarkShape = master.getShapes().addAutoShape(ShapeType.Rectangle, x, y, width, height);

    // Set fill type
    watermarkShape.getFillFormat().setFillType(FillType.NoFill);
    watermarkShape.getLineFormat().getFillFormat().setFillType(FillType.NoFill);

    // Set rotation angle
    watermarkShape.setRotation(-45);

    // Set text
    ITextFrame watermarkTextFrame = watermarkShape.addTextFrame(watermarkText);

    // Set font and color
    IPortion watermarkPortion = watermarkTextFrame.getParagraphs().get_Item(0).getPortions().get_Item(0);
    watermarkPortion.getPortionFormat().setFontHeight(52);

    int alpha = 150, red = 200, green = 200, blue = 200;
    watermarkPortion.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
    watermarkPortion.getPortionFormat().getFillFormat().getSolidFillColor()
            .setColor(new Color(red, green, blue, alpha));

    // Lock Shapes from modifying
    watermarkShape.getAutoShapeLock().setSelectLocked(true);
    watermarkShape.getAutoShapeLock().setSizeLocked(true);
    watermarkShape.getAutoShapeLock().setTextLocked(true);
    watermarkShape.getAutoShapeLock().setPositionLocked(true);
    watermarkShape.getAutoShapeLock().setGroupingLocked(true);
}

Thanks
Sabarish

@sabkan,
Thank you for contacting support.

I have reviewed your code example. Please note that you are adding the watermarks on master slides, but I guess the tables you mentioned are placed on normal presentation slides. The presentation slide content is always placed above the master slide content. If you want to place the watermarks above all content on presentation slides, you should add them on normal slides last.

for (ISlide slide : pres.getSlides()) {
    // Add watermarks to the slides...
}

@andrey.potapov
Thanks for the prompt reply.Will check and update.

@sabkan,
Thank you for using Aspose.Slides.

Hi

How to put the watermark in the footer with the code snippet I had shared earlier? Any suggestions?

@sabkan,
Thank you for the question. Please share the following files:

  • initial sample presentation
  • presentation with the expected watermark created in PowerPoint manually

We will then help you to make the same with Aspose.Slides for Java.

Hi
@andrey.potapov
Sorry,not able to share the presentation and watermark because of security issues.

You can take any presentation and watermark text is of around 172 characters in length.

Thanks in advance.
Sabarish

@andrey.potapov
Tried to upload sample pptx ile,it says that format is not supported,so uploaded a image of a sample ppt slide

Watermark text will be like this

PROPRIETARY INFORMATION OF xyz RIGHTS ARE DEFINED UNDER THE ASSET PURCHASE AGREEMENT, IP LICENSE AGREEMENT, AND SDR LICENSE AGREEMENT, DATED 4 FEBRUARY 2012

image.png (58.8 KB)

@sabkan,
You can zip the files mentioned above and upload an archive here. Please do this, it will help us understand the issue better.

Creating Sites.zip (342.2 KB)

@andrey.potapov
Have uploaded a sample ppt as a zip file.

Watermark text will be like this

PROPRIETARY INFORMATION OF xyz RIGHTS ARE DEFINED UNDER THE ASSET PURCHASE AGREEMENT, IP LICENSE AGREEMENT, AND SDR LICENSE AGREEMENT, DATED 4 FEBRUARY 2012

@sabkan,
If I understand correctly, you want to replace the “Agile PLM Site Management” text in the footer with the watermark text. Could you please confirm?

@andrey.potapov
Best will be if we can add the watermark text below the existing footer.

Or in worst case we can have the existing footer removed.

@sabkan,
Thank you for the additional information. You are already able to add watermarks to your slides. What exact problem are you facing right now?

@andrey.potapov
Actually wanted to add the watermark text in the bottom or footer of the slides.

Not sure how to do that with the code snippet used earlier.

@sabkan,
Please use the following code example:

var presentation = new Presentation("Creating Sites.pptx");

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

var watermarkText = "PROPRIETARY INFORMATION OF xyz RIGHTS ARE DEFINED UNDER THE ASSET PURCHASE AGREEMENT, IP LICENSE AGREEMENT, AND SDR LICENSE AGREEMENT, DATED 4 FEBRUARY 2012";
var watermarkWidth = (float) slideSize.getWidth();
var watermarkHeight = 10;
var watermarkX = 0;
var watermarkY = (float) slideSize.getHeight() - watermarkHeight;
var watermarkFontHeight = 10;

for (var slide : presentation.getSlides()) {
    var watermarkShape = slide.getShapes().addAutoShape(
            ShapeType.Rectangle, watermarkX, watermarkY, watermarkWidth, watermarkHeight);

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

    var watermarkTextFrame = watermarkShape.addTextFrame(watermarkText);

    var watermarkPortion = watermarkTextFrame.getParagraphs().get_Item(0).getPortions().get_Item(0);
    watermarkPortion.getPortionFormat().setFontHeight(watermarkFontHeight);

    int alpha = 120, red = 120, green = 120, blue = 120;
    var fillFormat = watermarkPortion.getPortionFormat().getFillFormat();
    fillFormat.setFillType(FillType.Solid);
    fillFormat.getSolidFillColor().setColor(new Color(red, green, blue, alpha));

    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();

Thanks.Can you suggest java code for this snippet?

@sabkan,
This is a Java code.

@andrey.potapov

ok.I am having Java 8, converted the code.

watermark is coming now. thanks. but it is very feeble.

image.png (108.1 KB)

When tried using the values for colors like this
int alpha = 150, red = 200, green = 200, blue = 200;
,the watermark is not visible at all.
Any suggestions on that.

@sabkan,
Please try using the following values:

int alpha = 255, red = 0, green = 0, blue = 0;

You can change the values in the range from 0 to 255 and select the best for you.
https://docs.oracle.com/javase/8/docs/api/java/awt/Color.html

Thank you very much.Now this looks fine.