无法在aspose ppt中嵌入样式,该样式是从html文件呈现的

时间:2017-09-22 06:53:11

标签: java html css aspose pptp

我使用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元素。有什么建议吗?

1 个答案:

答案 0 :(得分:1)

@Balchandar Reddy,

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

我是Aspose的支持开发人员/传播者。

相关问题