没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
原创|行业资讯|编辑:郝浩|2013-08-07 12:55:32.000|阅读 2509 次
概述:如何从演示文稿中提取文本?本文以Microsoft PowerPoint PPTX演示文稿为例,为你介绍如何用Aspose.Slides控件从中提取文本。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
开发人员需要从演示文稿中提取文本,这并不罕见。要做到这一点,你需要从演示文稿所有不同图形的幻灯片中提取文本。为此,本文以Microsoft PowerPoint PPTX演示文稿为例, 为你介绍如何用Aspose.Slides控件从中提取文本。无论是从一张幻灯片中提取文本,还是从演示文稿的所有幻灯片中提取文本,Aspose.Slides使用静态方法PresentationScanner都能帮你做到。提取的文本会自动打包在命名空间Aspose.Slides.Util下面。
Aspose.Slides for .NET提供一个叫做Aspose.Slides.Util的命名空间,它包括一个PresentationScanner类。这个类显示了多个从一页演示文稿或幻灯片中提取文本的重载静态方法。 从PPTX演示幻灯片中提取文本,可以使用PresentationScanner类下面显示的重载静态方法GetAllTextBoxes。这个方法接收SlideEx对象作为一个参数。
执行时,SlideEx方法扫描经过的幻灯片上的所有文本,作为参数返回一组TextFrameEx对象。这意味着与文本相关的任何文本格式都适用。下面的一段代码显示在第一张幻灯片上提取文本:
//Instatiate PresentationEx class that represents a PPTX file
using(PresentationEx pptxPresentation = new PresentationEx("d:\\pptx\\testx.pptx"))
{
//Get an Array of TextFrameEx objects from the first slide
TextFrameEx[] textFramesSlideOne = SlideUtil.GetAllTextBoxes(pptxPresentation.Slides[0]);
//Loop through the Array of TextFrames
for(int i=0;i<textFramesSlideOne.Length;i++)
//Loop through paragraphs in current TextFrame
foreach( ParagraphEx para in textFramesSlideOne[i].Paragraphs )
//Loop through portions in the current Paragraph
foreach (PortionEx port in para.Portions)
{
//Display text in the current portion
Console.WriteLine(port.Text);
//Display font height of the text
Console.WriteLine(port.FontHeight);
//Display font name of the text
Console.WriteLine(port.LatinFont.FontName);
}
}
'Instatiate PresentationEx class that represents a PPTX file
Using Dim pptxPresentation As New PresentationEx("d:\pptx\testx.pptx")
'Get an Array of TextFrameEx objects from the first slide
Dim textFramesSlideOne() As TextFrameEx = SlideUtil.GetAllTextBoxes(pptxPresentation.Slides(0))
'Loop through the Array of TextFrames
For i As Integer = 0 To textFramesSlideOne.Length - 1
'Loop through paragraphs in current TextFrame
For Each para As ParagraphEx In textFramesSlideOne(i).Paragraphs
'Loop through portions in the current Paragraph
For Each port As PortionEx In para.Portions
'Display text in the current portion
Console.WriteLine(port.Text)
'Display font height of the text
Console.WriteLine(port.FontHeight)
'Display font name of the text
Console.WriteLine(port.LatinFont.FontName)
Next port
Next para
Next i
End Using
要扫描整个演示文稿的文本,可以使用 PresentationScanner类显示的静态方法GetAllTextFrames。它包含两个参数:
1. 一个PresentationEx对象:显示当前正从中提取文本的PPTX演示文稿
2. 一个布尔值:决定当文本正从演示文稿中扫描时,主幻灯片是否包含在内。
这种方法将返回一组TextFrameEx对象,带有完整的文本格式信息。下面的代码表示扫描来自于演示文稿的文本和格式信息,包括主幻灯片。
//Instatiate PresentationEx class that represents a PPTX file
using(PresentationEx pptxPresentation = new PresentationEx("d:\\pptx\\testx.pptx"))
{
//Get an Array of TextFrameEx objects from all slides in the PPTX
TextFrameEx[] textFramesPPTX = SlideUtil.GetAllTextFrames(pptxPresentation, true);
//Loop through the Array of TextFrames
for (int i = 0; i < textFramesPPTX.Length; i++)
//Loop through paragraphs in current TextFrame
foreach (ParagraphEx para in textFramesPPTX[i].Paragraphs)
//Loop through portions in the current Paragraph
foreach (PortionEx port in para.Portions)
{
//Display text in the current portion
Console.WriteLine(port.Text);
//Display font height of the text
Console.WriteLine(port.FontHeight);
//Display font name of the text
Console.WriteLine(port.LatinFont.FontName);
}
}
'Instatiate PresentationEx class that represents a PPTX file
Using Dim pptxPresentation As New PresentationEx("d:\pptx\testx.pptx")
'Get an Array of TextFrameEx objects from all slides in the PPTX
Dim textFramesPPTX() As TextFrameEx = SlideUtil.GetAllTextBoxes(pptxPresentation.Slides(0))
'Loop through the Array of TextFrames
For i As Integer = 0 To textFramesPPTX.Length - 1
'Loop through paragraphs in current TextFrame
For Each para As ParagraphEx In textFramesPPTX(i).Paragraphs
'Loop through portions in the current Paragraph
For Each port As PortionEx In para.Portions
'Display text in the current portion
Console.WriteLine(port.Text)
'Display font height of the text
Console.WriteLine(port.FontHeight)
'Display font name of the text
Console.WriteLine(port.LatinFont.FontName)
Next port
Next para
Next i
End Using
Aspose.Slides.Util.SlideUtil类显示多个可供选择的动态方法来扫描演示文稿或幻灯片中的文本。格式信息也连同扫描的文件被提取出来。 如果你也遇到需要从演示文稿中提取文本或类似的难题,不妨试试Aspose.Slides,相信它会带给你不一样的体验和收获。
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@evget.com
文章转载自:慧都控件网Datamine成立于1981年,是矿业技术服务领域的领先企业,专注于为矿山设计、地质勘探和生产管理提供专业的软件解决方案。业务遍及20多个国家,拥有25个办事处。其核心产品 MineScape 具备处理海量矿山数据的能力,支持实时三维渲染与交互,助力客户提升设计与规划效率。
那么,BarTender 支持哪些数据库类型?又是如何助力企业实现数据驱动的智能打印?今天,我们来全面拆解!
企业级软件测试方案Parasoft SOAtest推出的AI助手采用代理式AI,自动生成API测试场景,使不同水准的测试团队都能轻松实现API测试自动化。此次更新后,测试人员可以借助自然语言指令,结合服务定义文件,高效生成API测试场景。除此之外,AI助手还利用AI代理生成测试数据,并针对数据循环对测试场景进行参数化。
Parasoft Virtualize通过环境可视化、实时监控和智能虚拟化三大核心能力,帮开发团队提前扫清环境障碍,让测试效率大幅提升,从此告别“测试五分钟,排查两小时”的尴尬。
Aspose.Slides是第一个能在用户的应用程序中对PowerPoint文档进行管理的组件。
Aspose.Slides for Reporting ServicesAspose.Slides for Reporting Services 是惟一的能在Microsoft SQL Server 2005和2008 Reporting Services 中以 Microsoft PowerPoint PPT 和 PPS 格式生成报表的解决方案。
Aspose.Slides for JasperReportsAspose.Slides for JasperReports 是专门为JasperReports用户开发的一种标准组件,以帮助他们将其Java应用程序中的报表能够简单地导出为Microsoft PowerPoint Presentation (PPT)和Microsoft PowerPoint Show (PPS)格式。
Aspose.Slides for SharePointAspose.Slides for SharePoint使您在一个SharePoint应用程序中读取和转换PowerPoint文件而不需要使用Microsoft PowerPoint。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@evget.com
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
慧都科技 版权所有 Copyright 2003-
2025 渝ICP备12000582号-13 渝公网安备
50010702500608号