没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
原创|行业资讯|编辑:郝浩|2013-08-07 12:55:32.000|阅读 2503 次
概述:如何从演示文稿中提取文本?本文以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@wqylolg.cn
文章转载自:慧都控件网产线级 MES 通过与检测设备的深度集成,实现数据的自动采集和智能分析,为企业提供更加精准、高效的质量管理方案。
HOOPS Communicator作为一款强大的工业设计工具,其碰撞检测和运动模拟功能为工程师和设计师提供了invaluable的支持。通过不断的技术创新和功能优化,HOOPS Communicator将助力企业在数字化转型的浪潮中,实现更加高效、智能和精准的工业设计与制造,引领工业设计走向新的高度。
总之,HOOPS Communicator的轻量化格式SC文件,与STEP文件在工业设计与协作中各有其重要地位和作用。理解它们之间的转换关系以及所需的工具和授权,对于有效利用HOOPS Communicator进行3D模型的轻量化展示和协作具有重要意义。
界面控件DevExpress WinForms v25.1将于今年年中更新,新版本将进一步提升AI方面的功能等,欢迎关注我们及时获取最新消息~
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@wqylolg.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢