如何在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如何删除php7

如何使用createcommand新建一条云助手命令

如何释放一台按量付费实例或者到期的预付费的实例

linux is找不到怎么办

lnmp搭建zabbix运维监控系统

ps ef grep命令详解

linux运维之ftp服务器功能介绍

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



打赏

取消

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

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

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

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

评论

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