使用 Aspose.Slide 获取PPT中的所有幻灯片的标题
2015-04-20 10:27
253 查看
本文使用的是第三方类库 Aspose.Slide,如果你使用的是OpenXml可以看下面的链接,原理是相同的,这个文章里也有对Xml标签的详细解释。
如何:获取演示文稿中的所有幻灯片的标题
原理:
原理说白了很简单,明白了原理大家都写得出来。
简单说,一个PPT里有多个幻灯片,一个幻灯片里有多个Shape, Shape会有一个Plcaeholder,Placeholder的Type属性来决定是否是标题。
Aspose的对像 IPresentation->Slide->Shape->PlaceHolder
代码:
判断Shape是一个Title,采用了扩展方法的方式:
View Code
再扩展IPresentation对象,增加一个GetTitles的方法
总结:
这东西本身,很简单的东西,主要就是判断哪个属性。幸好查到了微软的那篇文章。
本文原创
转载请注明出处:/article/7076055.html
如何:获取演示文稿中的所有幻灯片的标题
原理:
原理说白了很简单,明白了原理大家都写得出来。
简单说,一个PPT里有多个幻灯片,一个幻灯片里有多个Shape, Shape会有一个Plcaeholder,Placeholder的Type属性来决定是否是标题。
Aspose的对像 IPresentation->Slide->Shape->PlaceHolder
代码:
判断Shape是一个Title,采用了扩展方法的方式:
public class SlideTitle { public int PageNum { get; set; } public int TitleCount { get; set; } public string[] Titles { get; set; } }
View Code
再扩展IPresentation对象,增加一个GetTitles的方法
public static class PresentationExtension { public static IEnumerable<SlideTitle> GetTitles(this IPresentation p_presentation) { var presentation = p_presentation; if (presentation != null) { foreach (var slide in presentation.Slides) { List<string> titles = new List<string>(); foreach (var shape in slide.Shapes) { if (!shape.IsTitleShape()) { continue; } var autoShape = shape as AutoShape; if (autoShape == null) { continue; } titles.Add(autoShape.TextFrame.Text); } var title = new SlideTitle() { PageNum = slide.SlideNumber, TitleCount = titles.Count, Titles = titles.ToArray() }; yield return title; } } } }
总结:
这东西本身,很简单的东西,主要就是判断哪个属性。幸好查到了微软的那篇文章。
本文原创
转载请注明出处:/article/7076055.html
相关文章推荐
- 使用Aspose.Pdf获取PDF文档中的所有注释
- 使用Aspose.Pdf获取PDF文件中的所有附件
- 使用HtmlUnit获取博客园第一页的所有文章标题
- C# 如何获取PPT演示文档中的所有标题
- VBA 获取窗口标题 - 在PPT放映窗口与其他窗口间切换
- Android获取activity的所有子view(使用到递归)
- 使用python获取系统所有进程PID以及进程名称
- 使用python获取博客园作者的文章列表的超链接以及标题
- 获取所有打开的窗口的标题
- 使用Aspose.Pdf从PDF文件中获取个别的附件
- 使用Aspose.Pdf删除PDF文件中的所有附件
- 使用Aspose.Pdf获取附件信息
- 超时时间已到。超时时间已到,但是尚未从池中获取连接。出现这种情况可能是因为所有池连接均在使用,并且达到了最大池大小。
- C#获取局域网中的所有正在使用的IP地址
- C#获取局域网中的所有正在使用的IP地址
- android 获取手机中所有的传感器Sensor类使用方法
- java使用正则表达式获取字符串中的所有英文单词或数字
- 获取当某个表所有索引使用情况
- 【使用JSOUP实现网络爬虫】获取所有链接
- 使用递归获取网站下的所有同类型文件