Error :-
WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.aspose.slides.ms.core.System.Drawing.imagecodecs.jpeg.oracle.OracleJpegImageReader (file:/home/prdxn70/.m2/repository/com/aspose/aspose-slides/19.7/aspose-slides-19.7-jdk16.jar) to field com.sun.imageio.plugins.jpeg.JPEGImageReader.colorSpaceCode WARNING: Please consider reporting this to the maintainers of com.aspose.slides.ms.core.System.Drawing.imagecodecs.jpeg.oracle.OracleJpegImageReader WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release
Problem 1: I have created pptx and I am having 2 same image in one slide. as I am trying to replace one image both the image get replaced and it throws above WARNING message.
Problem 2: I have created pptx and it has 2 image after some time I have added 3rd image at the 2nd position and I am trying to replace it. It is replacing image at the 3rd position.
I am Trying Below code..
public static void main(String[] args) throws FileNotFoundException {
String dataDir = "/home/prdxn70/eclipse-workspace/ppt/src/main/resources/com/demo/ppt/App/";
try {
//Instantiate the presentation
Presentation presentation = new Presentation(dataDir + "two.pptx");
//Read image from source
File file = new File(dataDir + "img2.png");
byte[]data = new byte[(int) file.length()];
InputStream inputStream = null;
try {
inputStream = new FileInputStream(file);
inputStream.read(data);
// Instantiate SlideCollection calss ISlideCollection slds =
presentation.getSlides(); // Get the first slide ISlide sld = (ISlide)
presentation.getSlides().get_Item(0);
} finally {
inputStream.close();
}
//Code for replace Image
IPPImage oldImage = presentation.getImages().get_Item(0);
System.out.println(oldImage);
oldImage.replaceImage(data);
//Save the presentation
presentation.save(dataDir + "HelloWorld.pptx", SaveFormat.Pptx);
} catch (Exception e) {
System.out.println(e);
}
Link for pptx:-
https://drive.google.com/open?id=15NSxAHi311q8Hg3lJn4i8HrOkYOg_THT