Failed to Add an SVG Image to a PowerPoint Presentation in Java

Hi Team. Need help with adding svg Image to ppt. My code is not reading the svg image url.

 private boolean setImage(PPTFile PPTObj, IPictureFrame pic, HashMap<String, Iterator<Object>> keyMapper, int slideIdx, int timeout, ArrayList<IShape> toDelete){
        //For adding Images in Image Placeholders using Aspose API
        String key = pic.getName();

        HttpURLConnection conn = null;
        log.info("Adding image to shape " + key);
        try {
            String url = (String) keyMapper.get(key).next();
            URL imageURL = new URL(url);
            log.info("Adding image from the URL " + url);

            conn = (HttpURLConnection) imageURL.openConnection();
            System.out.println("conn line 263 ...! " +conn);
            if(conn != null){
                System.out.println("inside if condition..!!");
                (conn).setConnectTimeout(timeout*1000);
                (conn).setRequestMethod("HEAD");
                conn.setReadTimeout(timeout*1000);
            }
            conn.getInputStream();
            long size = conn.getContentLengthLong();

            if(size != -1 && size < imageSize*1024*1024){
                Path path2 = new File(getClass()
                        .getResource(url)
                        .getFile()).toPath();

                System.out.println("printing path 2..!! " +path2);
                Path path1 = new File(getClass().getResource("/data.json").getFile()).toPath();
                System.out.println("Path 1 printing..!!" +path1);
                Reader reader = Files.newBufferedReader(path1);
                System.out.println("Reader..!!" +reader);
                String mainPath = Paths.get(url).toString();
                System.out.println("MainPath..!! "+mainPath);
                Path path = Paths.get(mainPath);
                System.out.println("Path line 280...!! "+path);
                String svgContent = new String(Files.readAllBytes(path));
                System.out.println("string path svgContent "+svgContent);
                ISvgImage svgImage = new SvgImage(svgContent);
                System.out.println("IsvgImage..!!"+svgImage);
                IPPImage img = PPTObj.PPT.getImages().addImage(svgImage);
                System.out.println("IPPImage printing..!! "+img);
                IPictureFrame picNew = PPTObj.PPT.getSlides().get_Item(slideIdx).getShapes().addPictureFrame(ShapeType.Rectangle, pic.getX(), pic.getY(), pic.getWidth(), pic.getHeight(), img);
                System.out.println("IPictureFrame printing..!!"+picNew);

                picNew.setName(pic.getName());
                pic.removePlaceholder();

@AnkitaCisco,
Thank you for contacting support. The issue with reading images over HTTP is not related to Aspose.Slides. Please test your app code carefully.

If you are sure this is a problem with Aspose.Slides, please test your results using the latest version of Aspose.Slides if it is possible. If the issue persists, please share the following data and information:

  • input and output presentation files
  • the SVG image you tried to add to the presentation
  • OS version where the code was executed
  • JDK version in your app
  • Aspose.Slides version you used