Aspose.slides记录(二)
来源:互联网 发布:怎么查询域名注册商 编辑:程序博客网 时间:2024/06/13 17:28
形状及表格
public void readShapes(File inFile) throws FileNotFoundException { InputStream in = null; if (inFile != null) { in = new FileInputStream(inFile); } // 生成presentation对象 Presentation pres = new Presentation(in); // 获取幻灯片 ISlideCollection slides = pres.getSlides(); for (ISlide slide : slides) { // 判断是否为隐藏幻灯片 if (slide.getHidden()) { continue; } // 获取广义的图形对象 IShapeCollection shapes = slide.getShapes(); IPortionCollection portions = null; IParagraphCollection paras = null; for (IShape shape : shapes) { /** 形状及文本框 */ if (shape instanceof IAutoShape) { IAutoShape autoShape = (IAutoShape) shape; paras = autoShape.getTextFrame().getParagraphs(); int len = paras.getCount(); // 文本中段落 for (int paraNum = 0; paraNum < len; paraNum++) { portions = paras.get_Item(paraNum).getPortions(); readStyle(portions); } /**表格*/ } else if (shape instanceof ITable) { ITable table = (ITable) shape; int rowLen = table.getRows().size(); //行 for (int rowNum = 0; rowNum < rowLen; rowNum++) { int columnLen = table.getColumns().size(); //列 for (int columnNum = 0; columnNum < columnLen; columnNum++) { //单元格 ICell cell = table.getRows().get_Item(rowNum).get_Item(columnNum); if (rowNum != cell.getFirstRowIndex() || columnNum != cell.getFirstColumnIndex()) { continue; } paras = cell.getTextFrame().getParagraphs(); for (int paraNum = 0,paraLen = paras.getCount(); paraNum < paraLen; paraNum++) { portions = paras.get_Item(paraNum).getPortions(); readStyle(portions); } } } } } } }
获取样式
public void readStyle(IPortionCollection portions) { IHyperlink hyperlink = null; String font = ""; for (IPortion portion : portions) { // 文本 String text = portion.getText(); System.out.println("文本:"+text); // 字体 IPortionFormat portFormart = portion.getPortionFormat(); if (portFormart.getLatinFont() != null) { font = portFormart.getLatinFont().getFontName(); } else if (portFormart.getEastAsianFont() != null) { font = portFormart.getEastAsianFont().getFontName(); } System.out.println("字体:"+font); // 颜色 Color color = null; if (portFormart.getFillFormat().getSolidFillColor() != null && portFormart.getFillFormat().getSolidFillColor().getColor() != null) { color = portFormart.getFillFormat().getSolidFillColor().getColor(); } System.out.println("颜色:"+color.getRGB()); // 字高 Float fontSize = portFormart.getFontHeight(); if (!fontSize.isNaN()) { System.out.println("字高:" + fontSize); } // 删除线 if (portFormart.getStrikethroughType() == TextStrikethroughType.Single) { System.out.println("单行删除线"); } // 加粗 if (portFormart.getFontBold() == NullableBool.True) { System.out.println("加粗"); } // 下划线 if (portFormart.getFontUnderline() == TextUnderlineType.Single) { System.out.println("加粗"); } // 斜体 if (portFormart.getFontItalic() == NullableBool.True) { System.out.println("斜体"); } // 下标 if (portFormart.getEscapement() < 0) { System.out.println("下标"); } // 上标 if (portFormart.getEscapement() > 0) { System.out.println("上标"); } // 超链接 if (portFormart.getHyperlinkClick() != null) { hyperlink = portFormart.getHyperlinkClick(); } else if (portFormart.getHyperlinkMouseOver() != null) { hyperlink = portFormart.getHyperlinkMouseOver(); } String linkAddress = ""; if (hyperlink != null) { if (StringUtils.isNotBlank(hyperlink.getExternalUrl())) { linkAddress = hyperlink.getExternalUrl(); } else if (hyperlink.getTargetSlide() != null) { linkAddress = "" + hyperlink.getTargetSlide().getSlideId(); } } System.out.println("超链接:"+linkAddress); } }
阅读全文
0 0
- Aspose.slides记录(二)
- Aspose.slides记录(一)
- Aspose.slides记录(三)
- Aspose.slides记录(四)
- Aspose.slides记录(五)
- aspose.slides添加文本框代码反编译
- ppt 在线预览类库:Aspose.Slides.dll
- 【版本更新】Aspose.Slides V17.10发布 | 支持免费下载
- 【更新】PPT管理控件Aspose.Slides V17.5发布 | 附下载
- PPT控件Aspose.Slides V17.7发布 | 支持在文本框中添加列
- PPT组件Aspose.Slides V17.8发布 | 支持PP2010 PPTX与嵌入式视频
- PPT组件Aspose.Slides V17.9发布 | 改进导出HTML性能
- Aspose
- aspose
- Aspose.Slides 12月新版17.12发布 | 修复了17.7版tomcat 8.0.21无法启动的bug
- Aspose.words编程指南之DocumentBuilder二
- C# Aspose.Word 操作word文档【二】
- Lecture Slides
- java封装继承方法重载重写
- 【Linux】TCP 客户端与服务器端通信
- Android音视频API(android.media.effect):概览
- 信号阻塞
- 对自己之前学java的认识
- Aspose.slides记录(二)
- JDBC操作数据库的基本步骤
- mysql的安装及一些初级操作
- 设置mysql允许外部IP访问
- Dubbo详细介绍与安装使用过程
- Unity3D-调用IOS原生分享的实现
- Codeforces Round #297 (Div. 2)E. Anya and Cubes(折半搜索)
- HPE Mobile Center 试用感受功能简单,不推荐
- Maven 之 SNATSHOT 和release