错误:-
警告:出现了非法反射访问操作警告: 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)对字段com.sun.imageio.plugins.jpeg.JPEGImageReader.colorSpaceCode的非法反射访问警告:请考虑向com.aspose.slides.ms.core.System.Drawing.imagecodecs.的维护人员报告此操作jpeg.oracle.OracleJpegImageReader警告:使用
问题1:我已经创建了pptx,并且在一张幻灯片中有两个相同的图像。当我试图替换一个图像时,这两个图像都会被替换,并且它会抛出以上警告信息。
问题2:,我已经创建了pptx,它有2个图像,在一段时间后,我在第二个位置添加了第三个图像,我正在尝试替换它。它正在取代第三位置的图像。
我正在尝试以下代码..。
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);
}pptx链接:-
发布于 2019-08-27 18:36:21
对于您的下列问题:
问题1:我已经创建了pptx,并且在一张幻灯片中有两个相同的图像。当我试图替换一个图像时,这两个图像都会被替换,并且它会抛出以上警告信息。
这不是问题。实际上,表示中的图像实际上是添加到演示图像集合中的。因此,如果添加两个类似的图像,则API只保留其中一个,并避免重复。因此,两个或两个以上的形状,如果共享相同的图像,那么在后端有一个图像集合为他们的单一图像。此外,当您将图像添加到演示文稿中时,首先将图像添加到ImageCollection,然后按需要将该图像关联到一个或多个形状。因此,这不是一个问题,如果你想要这种方法,那么你的图像必须略有不同。否则,Aspose.Slides将把它们视为相似的图像。所以当你改变图像时,所有与该图像相关的形状都将取代图像。这不是问题。
问题2:我已经创建了pptx,在一段时间后,它有了2个图像,我在第二个位置添加了第三个图像,我正在尝试替换它。它正在取代第三位置的图像。
我使用了您使用Aspose.Slides forJava19.7共享的源文件,无法观察问题。我也与您分享了我的生成结果,供您参考。
我在Aspose做支持开发人员/布道者。
https://stackoverflow.com/questions/57424103
复制相似问题