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);
}
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
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
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?
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();
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.