Aspose.Word从word文档里提取图片
更新时间:2023-09-24 18:59:01 阅读量: 综合文库 文档下载
Aspose.Word从word文档里提取图片
Aspose.Word是一款功能强大的word控件,可以对word文件进行创建、编辑、读取、修改、转换,合并,插入等操作,并且不需要安装任何第三方插件,下面我们简单介绍,Aspose.Word如果从word文件中提取图片并保存。控件中国网是Aspose.Word在中国地区的核心代理商 具体查看下面的代码: C#
public void ExtractImagesToFiles() {
Document doc = new Document(MyDir + \ NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true); int imageIndex = 0; foreach (Shape shape in shapes) {
if (shape.HasImage) {
string imageFileName = string.Format(
\
FileFormatUtil.ImageTypeToExtension(shape.ImageData.ImageType)); shape.ImageData.Save(MyDir + imageFileName); imageIndex++; } }
// Newer Microsoft Word documents (such as DOCX) may contain a different type of image container called DrawingML.
// Repeat the process to extract these if they are present in the loaded document. NodeCollection dmlShapes = doc.GetChildNodes(NodeType.DrawingML, true); foreach (DrawingML dml in dmlShapes) {
if (dml.HasImage) {
string imageFileName = string.Format(
\
FileFormatUtil.ImageTypeToExtension(dml.ImageData.ImageType)); dml.ImageData.Save(MyDir + imageFileName); imageIndex++; } } }
Visual Basic
Public Sub ExtractImagesToFiles()
Dim doc As New Document(MyDir & \
Dim shapes As NodeCollection = doc.GetChildNodes(NodeType.Shape, True) Dim imageIndex As Integer = 0 For Each shape As Shape In shapes If shape.HasImage Then
Dim imageFileName As String = String.Format(\imageIndex, FileFormatUtil.ImageTypeToExtension(shape.ImageData.ImageType)) shape.ImageData.Save(MyDir & imageFileName) imageIndex += 1 End If Next shape
' Newer Microsoft Word documents (such as DOCX) may contain a different type of image container called DrawingML.
' Repeat the process to extract these if they are present in the loaded document. Dim dmlShapes As NodeCollection = doc.GetChildNodes(NodeType.DrawingML, True) For Each dml As DrawingML In dmlShapes If dml.HasImage Then
Dim imageFileName As String = String.Format(\imageIndex, FileFormatUtil.ImageTypeToExtension(dml.ImageData.ImageType)) dml.ImageData.Save(MyDir & imageFileName) imageIndex += 1 End If Next dml End Sub
正在阅读:
(完整版)史上最全的公务员等级划分05-05
-集装箱理货业务信息管理系统 - 图文04-24
2018年山西中考模拟示范卷理科综合(物理)试题(六)03-31
感性与理性主题班会09-27
苏轼赞作文800字06-27
想起这事我就自豪作文500字06-25
ASM铸造缺陷的国际分类7大类(学习版0228)详解 - 图文10-29
当代高校教师评价体系的反思研究10-25
优秀主题班会《虚心成长》-反思模版03-23
- 多层物业服务方案
- (审判实务)习惯法与少数民族地区民间纠纷解决问题(孙 潋)
- 人教版新课标六年级下册语文全册教案
- 词语打卡
- photoshop实习报告
- 钢结构设计原理综合测试2
- 2014年期末练习题
- 高中数学中的逆向思维解题方法探讨
- 名师原创 全国通用2014-2015学年高二寒假作业 政治(一)Word版
- 北航《建筑结构检测鉴定与加固》在线作业三
- XX县卫生监督所工程建设项目可行性研究报告
- 小学四年级观察作文经典评语
- 浅谈110KV变电站电气一次设计-程泉焱(1)
- 安全员考试题库
- 国家电网公司变电运维管理规定(试行)
- 义务教育课程标准稿征求意见提纲
- 教学秘书面试技巧
- 钢结构工程施工组织设计
- 水利工程概论论文
- 09届九年级数学第四次模拟试卷
- Word
- 提取
- 文档
- Aspose
- 图片
- 电能质量监测研究模板
- 亚马逊开店培训之影响listing的类目排名的因素
- 数学分析三试卷及答案
- 11年电工数学建模论文 - 图文
- 环境监理月报
- 关于安徽省石台县旅游资源的调查
- 政工师个人业务工作总结
- 无线电台常用高频发射管参数
- 运输组织学教学大纲
- 燃煤掺配管理办法
- 2018年领导干部理论学习心得体会参考范文
- 大客户营销管理 - 图文
- 驾校营销策划方案
- 江苏省盐城市2018年中考历史真题试题Word版含答案
- 食品发酵技术复习题
- 智慧地球概念的内涵浅析
- 高层建筑地下室不同楼盖方案经济性能分析比较(2012.11.21)
- 校长在市读书会上的表态发言
- 专题27 第一次世界大战和战后初期的世界(第01期)-2019年中考真题历史试题分项汇编(原卷版) - 图文
- 2012年全国中考物理试题分类汇编—电流和电路 - 图文