【问题标题】:Unable to embed styling in aspose ppt which is rendered from html file无法在从 html 文件呈现的 aspose ppt 中嵌入样式
【发布时间】:2018-03-03 16:02:47
【问题描述】:

我正在使用 aspose java 库将 html 转换为 ppt。但是,我无法生成像 (padding,background-color,etc) 这样的样式,而像 (color,font-size) 这样的样式工作得很好,看看代码..

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

【问题讨论】:

    标签: java html css aspose pptp


    【解决方案1】:

    @Balchandar 雷迪,

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

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

    【讨论】:

    • 我的要求很复杂,它包括html表格,每个单元格都有不同的背景颜色,有些页面有各种图表,如条形图、柱形图和饼图等。这可能与aspose有关吗?
    • @Balchandar Reddy 目前,Aspose.Slides 仅支持从 HTML 到演示文本框架的基本文本导入。
    猜你喜欢
    • 2012-08-10
    • 2020-09-25
    • 1970-01-01
    • 1970-01-01
    • 2013-07-29
    • 2015-05-29
    • 2020-07-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多