0

我正在使用 aspose java 库将 html 转换为 ppt。但是,我无法生成像(填充,背景颜色等)这样的样式,而像(颜色,字体大小)这样的样式工作得很好,看看代码..

 public class poi {

        public static void main(String[] args) throws Exception {

            // The path to the documents directory.
            String dataDir = Utils.getDataDir(poi.class);

            // Create Empty presentation instance
            Presentation pres = new Presentation();

            // Access the default first slide of presentation
            ISlide slide = pres.getSlides().get_Item(0);

            // Adding the AutoShape to accommodate the HTML content
            IAutoShape ashape = slide.getShapes().addAutoShape(ShapeType.Rectangle,  50, 150, 300, 150);

            ashape.getFillFormat().setFillType(FillType.NoFill);

            // Adding text frame to the shape
            ashape.addTextFrame("");

            // Clearing all paragraphs in added text frame
            ashape.getTextFrame().getParagraphs().clear();

            // Loading the HTML file using InputStream
            InputStream inputStream = new FileInputStream(dataDir + "file.html");
            Reader reader = new InputStreamReader(inputStream);

            int data = reader.read();
            String content = ReadFile(dataDir + "file.html");

            // Adding text from HTML stream reader in text frame
            ashape.getTextFrame().getParagraphs().addFromHtml(content);

            // Saving Presentation
            pres.save(dataDir + "output.pptx", SaveFormat.Pptx);


        }

        public static String ReadFile(String FileName) throws Exception {

            File file = new File(FileName);
            StringBuilder contents = new StringBuilder();
            BufferedReader reader = null;

            try {
                reader = new BufferedReader(new FileReader(file));
                String text = null;

                // repeat until all lines is read
                while ((text = reader.readLine()) != null) {
                    contents.append(text).append(System.getProperty("line.separator"));
                }
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    if (reader != null) {
                        reader.close();
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                    return null;
                }
            }

            return contents.toString();

        }

    }

如您所见,我正在加载具有内联样式的 html 文件,但我无法完全加载大多数 css 元素。有什么建议么?

4

1 回答 1

1

@Balchandar 雷迪,

我已经观察到您的要求并愿意分享目前 Aspose.Slides 支持基本文本导入以及使用 Aspose.Slides 生成的演示文稿中的有限标签支持。我请求您分享所需的 HTML 以及您打算在 Aspose.Slides 中获得支持的所需标签。我将与我们的产品团队讨论这个问题,并将其作为新功能请求添加到我们的问题跟踪系统中。

我在 Aspose 担任支持开发人员/传播者。

于 2017-09-22T09:16:12.587 回答