0

たくさんの docx ファイルがあり、それらを端末で読みたいと思っています。そして、catdoc http://www.wagner.pp.ru/~vitus/software/catdoc/を見つけました

私がそれを使用すると、出力は判読できない文字になります。私の docx ファイルは utf-8 でエンコードされています。「catdoc -u my_file.docx」を試しましたが、うまくいきません。

助けてください。どうもありがとうございました。

4

2 に答える 2

1

通常、ファイルcatdocでのみ使用できるのは私の素朴な理解です。ファイルは、圧縮されたコンテナのようなもので、その中にたくさんの情報が含まれています。その中には、ある種の XML 形式の元のドキュメントがあります。DOCDOCX

そうは言っても、doc2txtツールまたはunoconvツールのいずれかを使用して、ファイルの内容、DOCXさらにはファイルの内容を抽出することに成功しました。後者には OpenOffice または LibreOffice スイートがインストールされている必要があります。DOTX

以下は、私が過去に使用して成功したワークフローの例です。

# This one, contrary to the unoconv case, does not fire up an instance
# of either LibreOffice or OpenOffice.
docx2txt.pl < ./pesky-word-doc.docx > ./pesky-word-doc.txt

# This one, however, does fire up a rather heavy 'headless' OpenOffice
# or LibreOffice instance process per conversion. You can get around this
# using the next approach below.
unoconv -f txt -o ./pesky-word-doc.txt ./pesky-word-doc.docx

# If you need to convert a couple of dozens such documents, you might want
# to run it via a service port (you get the idea):
unoconv --listener --port=2002 &
unoconv -f txt -o outdir *.docx
unoconv -f pdf -o outdir *.docx && open ./outdir/*.pdf # Convenient, if you run MacOSX
kill -15 %-

# Kind of introducing catdoc: The sed was needed for German documents where
# somehow I couldn't find the proper encoding settings.
unoconv -f doc -o ./pesky-word-doc.doc ./pesky-word-doc.docx && \
          catdoc -u ./pesky-word-doc.doc | sed 's/ь/ü/g;s/д/ä/g;s/ц/ö/g'

ここここにある利用可能な Java パーサーのいくつかを使用するなど、他のオプションがあります。出力品質は異なり、使用目的に応じて、いずれかの方法を使用する必要があります。

于 2013-07-11T09:37:16.107 に答える