Hello,
When adding a SVG-based graphic to a PictureFrame in a Slide, the resulting image becomes distorted with pixelation. This can be observed under Aspose Slides for Java version 19.12, the attached 3D_pie.svg (55.4 KB) file and the following Java code:
try {
final String svgPath = [FILE_PATH] + "3D_pie.svg";
IPresentation pptx = new Presentation();
ISlideCollection slides = pptx.getSlides();
ISlide slide = slides.get_Item(0);
byte[] imagebytes = Files.readAllBytes(Paths.get(svgPath));
ISvgImage svgImg = new SvgImage(imagebytes);
IPPImage imgx = pptx.getImages().addImage(svgImg);
slide.getShapes().addPictureFrame(ShapeType.Rectangle, 10, 10,
imgx.getWidth(), imgx.getHeight(), imgx);
String newFile = svgPath.replace(".svg", ".pptx");
Files.deleteIfExists(Paths.get(newFile));
pptx.save(newFile, SaveFormat.Pptx);
System.out.println("\nSaved Presentation as: " + newFile);
} catch (Exception ex) {
System.out.println("Unexpected exception: " + ex.getMessage());
ex.printStackTrace();
}
After running the code, there should be a new file named “3D_pie.pptx” (also attached). When the Presentation opened in PowerPoint, the pie chart is shows pixelation. However, if you render the same “3D_pie.svg” file in any major Browser (Firefox, Edge/IE, Chrome) the SVG image appears much clearer and without distortions.
We would like for Slides to render SVG-based images as good as (or better than) the Browsers.
Thanks.