Hi,
I am trying to replace the portion from paragraph but keep the same gradient formating as the original portion. When I open the saved file they look different.Can you please check this out?
file: path.pptx.zip (21.0 KB)
picture: path.PNG (26.7 KB)
code:
String path = "path.pptx";
Presentation presentation = new Presentation(path);
ISlide slide = presentation.getSlides().get_Item(0);
AutoShape shape = (AutoShape) slide.getShapes().get_Item(0);
IParagraph paragraph = shape.getTextFrame().getParagraphs().get_Item(0);
IPortionCollection portions = paragraph.getPortions();
IPortion portion = portions.get_Item(0);
IGradientFormatEffectiveData gradientFormat = portion.createPortionFormatEffective().getFillFormat()
.getGradientFormat();
byte gradientShape = gradientFormat.getGradientShape();
IGradientStopCollectionEffectiveData stops = gradientFormat.getGradientStops();
Portion newPortion = new Portion("Path");
IFillFormat fillFormat = newPortion.getPortionFormat().getFillFormat();
fillFormat.setFillType(FillType.Gradient);
IGradientFormat newPortionGradient = fillFormat.getGradientFormat();
newPortionGradient.setGradientShape(gradientShape);
newPortionGradient.getGradientStops().add(stops.get_Item(0).getPosition(), stops.get_Item(0).getColor());
newPortionGradient.getGradientStops().add(stops.get_Item(1).getPosition(), stops.get_Item(1).getColor());
newPortionGradient.getGradientStops().add(stops.get_Item(2).getPosition(), stops.get_Item(2).getColor());
portions.clear();
portions.add(newPortion);
presentation.save("saved.pptx", SaveFormat.Pptx);
Thanks,
Zeljko