没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
原创|行业资讯|编辑:郝浩|2013-08-07 12:55:32.000|阅读 2532 次
概述:如何从演示文稿中提取文本?本文以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
文章转载自:慧都控件网传统的UI测试往往受限于图形界面渲染,导致执行速度慢、资源占用高,难以适应持续集成/持续交付(CI/CD)管道的需求。自动化UI测试平台TestComplete的智能质量附加组件通过无头测试技术,为开发团队提供了一种更高效、更可靠的解决方案。
水印技术是保护文档安全、声明所有权及防止未经授权复制的关键手段。无论是分发草稿还是为最终交付成果添加品牌标识,使用水印都能有效保护您的内容。本教程将指导您如何使用 Spire.PDF for Python 在 Python 中为 PDF 文件添加水印 。
在传统建模工具中,功能繁杂、界面混乱、窗口频繁切换等问题长期困扰着架构师与开发人员,不仅拖慢设计节奏,更导致模型与文档严重脱节。企业架构与建模平台Sparx EA 直面这些挑战,通过现代化的Ribbon界面与多视图协作机制,重塑高效、直观、一致的建模体验,让用户真正专注于设计本身,而非与工具对抗。
MES制造执行系统恰恰就是衔接计划与执行的“中枢神经”,而其中的生产计划管理功能,更是决定企业生产是否能够高效、稳定和可控的关键。
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号