文档格式批量转换(doc,txt,pdf等)

此页由Linux Wiki用户Chenxing于2012年12月18日 (星期二) 07:59的最后更改。 在Gadziko的工作基础上。

出自Linux Wiki

提示:此文已超过 11 年(4118 天)未更新,如发现内容过时或有误,欢迎改进:)

在Linux中常常涉及到多种文档格式,如doc、txt、html、rtf等等。为了方便文件传递,就可能需要在各种格式之间进行转换。LibreOfficeApache OpenOffice可以方便的打开多各文档格式并按需进行转换,但要一次处理大量文件或要编写进行转换时,仅用OpenOffice就难以胜任了。

unoconv 利用 LibreOffice 的 UNO 接口实现了命令行文档格式转换功能,支持所有 LibreOffice 支持的文件格式,为文档的批量转换提供了可能。

目录

安装

unoconv存在于很多发行版的软件仓库中,也可通过其网站下载安装。

Note.gif
注意:
该软件依赖于LibreOffice。

使用方法

单个文件转换

举一个例子:要转换一个doc文件为PDF格式,只需在命令中执行:

$ unoconv -f pdf myDoc.doc

即会生成一个名为myDoc.pdf的pdf文件。

批量转换

批量转换需要结合find命令或脚本使用,使用时需注意最好使用C/S模式以加快速度:

unoconv --listener &
unoconv -f pdf some-document.odt
unoconv -f doc other-document.odt
unoconv -f jpg some-image.png
unoconv -f xsl some-spreadsheet.csv

其它功能简介

支持的文件格式

可以执行unoconv --show查看 截止到2008年3月11日,unoconv支持以下几种导出格式(见本文末尾)[1]

服务器/客户端模式

此模式使文档的集中处理成为可能。

附:支持的输出文件格式

 bib      - BibTeX [.bib]
 doc      - Microsoft Word 97/2000/XP [.doc]
 doc6     - Microsoft Word 6.0 [.doc]
 doc95    - Microsoft Word 95 [.doc]
 docbook  - DocBook [.xml]
 html     - HTML Document (OpenOffice.org Writer) [.html]
 odt      - Open Document Text [.odt]
 ott      - Open Document Text [.ott]
 ooxml    - Microsoft Office Open XML [.xml]
 pdb      - AportisDoc (Palm) [.pdb]
 pdf      - Portable Document Format [.pdf]
 psw      - Pocket Word [.psw]
 rtf      - Rich Text Format [.rtf]
 latex    - LaTeX 2e [.ltx]
 sdw      - StarWriter 5.0 [.sdw]
 sdw4     - StarWriter 4.0 [.sdw]
 sdw3     - StarWriter 3.0 [.sdw]
 stw      - Open Office.org 1.0 Text Document Template [.stw]
 sxw      - Open Office.org 1.0 Text Document [.sxw]
 text     - Text Encoded [.txt]
 txt      - Plain Text [.txt]
 vor      - StarWriter 5.0 Template [.vor]
 vor4     - StarWriter 4.0 Template [.vor]
 vor3     - StarWriter 3.0 Template [.vor]
 xhtml    - XHTML Document [.html]

图形格式:

 bmp      - Windows Bitmap [.bmp]
 emf      - Enhanced Metafile [.emf]
 eps      - Encapsulated PostScript [.eps]
 gif      - Graphics Interchange Format [.gif]
 html     - HTML Document (OpenOffice.org Draw) [.html]
 jpg      - Joint Photographic Experts Group [.jpg]
 met      - OS/2 Metafile [.met]
 odd      - OpenDocument Drawing [.odd]
 otg      - OpenDocument Drawing Template [.otg]
 pbm      - Portable Bitmap [.pbm]
 pct      - Mac Pict [.pct]
 pdf      - Portable Document Format [.pdf]
 pgm      - Portable Graymap [.pgm]
 png      - Portable Network Graphic [.png]
 ppm      - Portable Pixelmap [.ppm]
 ras      - Sun Raster Image [.ras]
 std      - OpenOffice.org 1.0 Drawing Template [.std]
 svg      - Scalable Vector Graphics [.svg]
 svm      - StarView Metafile [.svm]
 swf      - Macromedia Flash (SWF) [.swf]
 sxd      - OpenOffice.org 1.0 Drawing [.sxd]
 sxd3     - StarDraw 3.0 [.sxd]
 sxd5     - StarDraw 5.0 [.sxd]
 tiff     - Tagged Image File Format [.tiff]
 vor      - StarDraw 5.0 Template [.vor]
 vor3     - StarDraw 3.0 Template [.vor]
 wmf      - Windows Metafile [.wmf]
 xhtml    - XHTML [.xhtml]
 xpm      - X PixMap [.xpm]

演示文稿:

 bmp      - Windows Bitmap [.bmp]
 emf      - Enhanced Metafile [.emf]
 eps      - Encapsulated PostScript [.eps]
 gif      - Graphics Interchange Format [.gif]
 html     - HTML Document (OpenOffice.org Impress) [.html]
 jpg      - Joint Photographic Experts Group [.jpg]
 met      - OS/2 Metafile [.met]
 odd      - OpenDocument Drawing (Impress) [.odd]
 odg      - OpenOffice.org 1.0 Drawing (OpenOffice.org Impress) [.odg]
 odp      - OpenDocument Presentation [.odp]
 otp      - OpenDocument Presentation Template [.otp]
 pbm      - Portable Bitmap [.pbm]
 pct      - Mac Pict [.pct]
 pdf      - Portable Document Format [.pdf]
 pgm      - Portable Graymap [.pgm]
 png      - Portable Network Graphic [.png]
 pot      - Microsoft PowerPoint 97/2000/XP Template [.pot]
 ppm      - Portable Pixelmap [.ppm]
 ppt      - Microsoft PowerPoint 97/2000/XP [.ppt]
 pwp      - PlaceWare [.pwp]
 ras      - Sun Raster Image [.ras]
 sda      - StarDraw 5.0 (OpenOffice.org Impress) [.sda]
 sdd      - StarImpress 5.0 [.sdd]
 sdd3     - StarDraw 3.0 (OpenOffice.org Impress) [.sdd]
 sdd4     - StarImpress 4.0 [.sdd]
 sti      - OpenOffice.org 1.0 Presentation Template [.sti]
 stp      - OpenDocument Presentation Template [.stp]
 svg      - Scalable Vector Graphics [.svg]
 svm      - StarView Metafile [.svm]
 swf      - Macromedia Flash (SWF) [.swf]
 sxi      - OpenOffice.org 1.0 Presentation [.sxi]
 tiff     - Tagged Image File Format [.tiff]
 vor      - StarImpress 5.0 Template [.vor]
 vor3     - StarDraw 3.0 Template (OpenOffice.org Impress) [.vor]
 vor4     - StarImpress 4.0 Template [.vor]
 vor5     - StarDraw 5.0 Template (OpenOffice.org Impress) [.vor]
 wmf      - Windows Metafile [.wmf]
 xhtml    - XHTML [.xml]
 xpm      - X PixMap [.xpm]

电子表格:

 csv      - Text CSV [.csv]
 dbf      - dBase [.dbf]
 dif      - Data Interchange Format [.dif]
 html     - HTML Document (OpenOffice.org Calc) [.html]
 ods      - Open Document Spreadsheet [.ods]
 ooxml    - Microsoft Excel 2003 XML [.xml]
 pdf      - Portable Document Format [.pdf]
 pts      - OpenDocument Spreadsheet Template [.pts]
 pxl      - Pocket Excel [.pxl]
 sdc      - StarCalc 5.0 [.sdc]
 sdc4     - StarCalc 4.0 [.sdc]
 sdc3     - StarCalc 3.0 [.sdc]
 slk      - SYLK [.slk]
 stc      - OpenOffice.org 1.0 Spreadsheet Template [.stc]
 sxc      - OpenOffice.org 1.0 Spreadsheet [.sxc]
 vor3     - StarCalc 3.0 Template [.vor]
 vor4     - StarCalc 4.0 Template [.vor]
 vor      - StarCalc 5.0 Template [.vor]
 xhtml    - XHTML [.xhtml]
 xls      - Microsoft Excel 97/2000/XP [.xls]
 xls5     - Microsoft Excel 5.0 [.xls]
 xls95    - Microsoft Excel 95 [.xls]
 xlt      - Microsoft Excel 97/2000/XP Template [.xlt]
 xlt5     - Microsoft Excel 5.0 Template [.xlt]
 xlt95    - Microsoft Excel 95 Template [.xlt]

相关资料

  1. http://dag.wieers.com/home-made/unoconv/

本文对您有帮助?分享给更多朋友!

反馈与讨论

发现文档不全面、有错误却没时间编辑文档?想分享自己的经验或见解?欢迎在此留言、讨论。
个人工具
简体繁体转换