如何在Linux系统中利用node.js提取Word及PDF文本内容的案例介绍


当前第2页 返回上一页

用antiword提取 .doc 的内容

我们这里使用了 antiword 开源软件,来提取word2003以前版本的内容,安装同样非常简单:

1

apt-get install antiword

查看帮助:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

root@raspberrypi:/var/www# antiword

 Name: antiword

 Purpose: Display MS-Word files

 Author: (C) 1998-2005 Adri van Os

 Version: 0.37 (21 Oct 2005)

 Status: GNU General Public License

 Usage: antiword [switches] wordfile1 [wordfile2 ...]

 Switches: [-f|-t|-a papersize|-p papersize|-x dtd][-m mapping][-w #][-i #][-Ls]

  -f formatted text output

  -t text output (default)

  -a <paper size name> Adobe PDF output

  -p <paper size name> PostScript output

   paper size like: a4, letter or legal

  -x <dtd> XML output

   like: db (DocBook)

  -m <mapping> character mapping file

  -w <width> in characters of text output

  -i <level> image level (PostScript only)

  -L use landscape mode (PostScript only)

  -r Show removed text

  -s Show hidden (by Word) text


antiword直接将word内容输出到了console中:


1

2

3

4

5

root@raspberrypi:/var/www# antiword spec.doc

 

SYNC Mobile ?C Ford APA

Project Number: DFYST

Requirements Specification


同样在node.js用child_process调用此命令即可。

解析提取.docx 的内容

对于 docx 文档来说,因基本身就是一个zip文件,只需要在node.js先将其解压,再解析 text.docx\word\document.xml 文件即可。

总结

以上就是如何在Linux系统中利用node.js提取Word及PDF文本内容的案例介绍的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

linux 如何查看版本

如何使用升级配置功能升级预付费的实例规格

linux如何查看系统版本信息

怎么查看linux版本信息

如何确认已经卸载数据盘并可以新建自定义镜像

linux不能访问怎么办

详解linux利用read命令获取变量中的值的操作方法

三分钟了解linux与windows的区别

ecs 如何利用快照创建磁盘实现无损扩容数据盘

linux中xargs的用法详解

更多相关阅读请进入《javascript》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...