Linux docx to txt

How to open Microsoft Word documents in Linux

In an office or production environment, sharing documents between different applications and operating systems is a common issue. If you need to create, open, and edit Microsoft Word documents in Linux, you can use LibreOffice Writer or AbiWord. Both are robust word processing applications that read and write files in Word .doc and .docx formats.

If you need command-line tools that extract the text from Word files, Antiword (.doc files) and docx2txt (.docx) are useful programs to have at your disposal.

In this tutorial, we’ll look at these four applications and how you can use them. We’ll walk through installing them on several of the most popular Linux distributions, including Debian, Ubuntu, Fedora, OpenSUSE, CentOS, and Arch Linux. We’ll also help with installing the core Microsoft TrueType fonts on your Linux system.

LibreOffice

LibreOffice is a free, open-source, actively maintained and frequently updated office productivity suite that is compatible with Microsoft Office applications, including Microsoft Word. You can save your LibreOffice Writer documents in .doc or .docx format, and then either opens correctly in Microsoft Word.

Installing LibreOffice

LibreOffice can be installed using your package manager. To install it, open a terminal and use the following command appropriate for your operating system:

Debian 8, Ubuntu 15

Fedora 23

OpenSUSE 10

CentOS 7

Arch Linux 2016

Once LibreOffice is installed, it should appear in the Applications menu of your GUI. You can also run it from a terminal with the command:

AbiWord

AbiWord is another free and open-source word processor. It has a clean, simple interface developed for almost twenty years. Like LibreOffice, it can open, edit, and save Microsoft Word .doc and .docx files. Unlike LibreOffice, Abiword is not a complete office suite, so it has a smaller footprint and consumes fewer system resources.

Installing AbiWord

Debian 8, Ubuntu 15

Fedora 23

OpenSUSE 10

CentOS 7

Arch Linux 2016

Antiword

Antiword is a command-line tool that converts the contents of a .doc file to plain text.

Antiword only converts .doc files. If you need to convert a .docx file, see docx2txt in the next section.

Using Antiword

Running antiword with the name of a Word .doc file outputs the plain text of the file to standard output.

Antiword does a great job of formatting tables. It also has options for including images as PostScript objects and outputting to PDF.

You can redirect the output to a text file:

Or, if you want to open it directly in a text editor, you can pipe the text to vim:

Installing antiword

Debian 8, Ubuntu 15

Fedora 23

OpenSUSE 10

CentOS 7

Docx2txt

Docx2txt is a command-line tool that converts .docx files to plain text. (It does not convert .doc files.)

To print the contents of a .docx file to the terminal screen or a file, call docx2txt and specify a dash as the output file name. In this example, notice the dash at the end of the command.

Читайте также:  Проигрыватель mpc для windows 10

To convert a .docx file and output to a text file, use the command form:

To open the .docx text in vim, use the command form:

To open it in nano:

To install doc2txt, follow the instructions for your version of Linux below:

Debian 8

Ubuntu 15

Fedora 23

Fedora’s repositories do not offer a package for docx2txt, but you can install it manually:

Download the source from SourceForge’s docx2txt page. Extract the archive:

You need to make sure that perl, unzip and make are installed on your system, so install or upgrade those packages now:

Then, run make as the root user to install:

Docx2txt is now installed as docx2txt.sh. For instance, to convert the file word-document.docx to a text file, you can run:

The converted text file automatically saves as word-document.txt.

OpenSUSE 10

SUSE repositories do not offer a package for docx2txt, but you can download it from SourceForge’s docx2txt page. Extract the archive:

You need to make sure that perl, unzip and make are installed on your system, so install or upgrade those packages now:

Then, run make as root to install:

Docx2txt is now installed as docx2txt.sh. For instance, to convert the file word-document.docx to a text file, you can run:

The converted text file is automatically saved as word-document.txt.

CentOS 7

CentOS repositories do not offer a package for docx2txt, but you can download it from SourceForge’s docx2txt page. Extract the archive:

You need to make sure that perl, unzip and make are installed on your system, so install or upgrade those packages now:

Then, run make as root to install:

Docx2txt is now installed as docx2txt.sh. For instance, to convert the file word-document.docx to a text file, you can run:

The converted text file is automatically saved as word-document.txt.

Arch Linux 2016

Installing Microsoft-compatible fonts

The core Microsoft fonts are available on Linux. Install them if you are going to be working with Microsoft Word files — especially if they were created on a Windows system. The core fonts include:

  • Andale Mono
  • Arial
  • Arial Black
  • Calabri
  • Cambria
  • Comic
  • Courier
  • Impact
  • Times
  • Trebuchet
  • Verdana
  • Webdings

To install them, follow these steps:

Debian 8, Ubuntu 15

Fedora 23

Install packages required for installation:

Then install the local RPM package:

OpenSUSE 10

Install packages required for installation:

Then install the local RPM package:

CentOS 7

Install packages required for installation:

Then install the local RPM package:

Arch Linux 2016

Install packages required for installation:

Extract the contents of the local RPM package:

This command extracts the raw contents of the RPM file and creates two directories, etc and usr that correspond to your /etc and /usr directories. The font files themselves are located in usr/share/fonts/msttcore.

Источник

Преобразование форматов

GNU a2ps преобразует файлы в PostScript для печати или просмотра.

ANDREW

ANDREW (ANDREW’s Not a DVD Ripping and Encoding Wizard) — консольная утилита, которая в диалоговом режиме поможет из DVD получить файл в формате AVI, Matroska или OGM.

Antiword

Antiword — свободная программа для чтения документов MS-Word под Linux, RISC OS и DOS.

Arista Transcoder

Arista Transcoder — это конвертер видео-файлов, который полностью интегрируется в рабочую среду GNOME.

Calibre

Mенеджер электронных книг, который позволит вам управлять вашей электронной библиотекой.

catdoc

catdoc — это утилита, которая читает MS-Word файл и выводит его содержимое как простой текст на стандартный выход (напр в консоль).

cdparanoia

cdparanoia — CD риппер для UNIX-подобных операционных систем и для BeOS, разработан некоммерческой организацией Xiph.Org. Он планировался быть минималистичным качественным CD риппером.

CuePlayer

Универсальный графический аудио/видео проигрыватель и конвертер.

DivX Converter

DivX Converter — это программа для конвертирования различных видеоформатов в формат avi(кодеки DivX 5, DivX 4, XviD, H.264, и.т.д. ), по сути это PyGTK графический интерфейс к консольному кодировщику mencoder.

dktools

Комплект утилит для преобразования графических файлов из одного формата в другой.

Читайте также:  Не отображается индикатор заряда батареи windows 10

docbook2x

docbook2x конвертирует DocBook/XML документы в формат man-страниц и TeXinfo.

Docmake

Docmake — это инструмент командной строки, предназначенный для преобразования DocBook/XML-кода в различные выходные форматы, такие как XHTML, RTF, PDF, Word/RTF и XSL-FO, используя более низко-уровневые инструменты, такие как xsltproc или Apache fop. Разрабатывается как замена xmlto.

docx2txt

docx2txt — это написанная на perl утилита командной строки, позволяющая конвертировать документы формата Microsoft Office(Tm) Docx в простой текстовый (ASCII) формат, сохраняя некоторые элементы форматирования и информацию о документе.

Источник

How to extract just plain text from .doc & .docx files? [closed]

Want to improve this question? Update the question so it’s on-topic for Stack Overflow.

Closed 6 years ago .

Anyone know of anything they can recommend in order to extract just the plain text from a .doc or .docx ?

I’ve found this — wondered if there were any other suggestions?

7 Answers 7

If you want the pure plain text(my requirement) then all you need is

It unzips the docx file and gets the actual document then strips all the xml tags. Obviously all formatting is lost.

LibreOffice

One option is libreoffice/openoffice in headless mode (make sure all other instances of libreoffice are closed first):

Since the openoffice command line syntax is a bit too complicated, there is a handy wrapper which can make the process easier: unoconv.

Apache POI

Another option is Apache POI — a well supported Java library which unlike antiword can read, create and convert .doc , .docx , .xls , .xlsx , .ppt , .pptx files.

Here is the simplest possible Java code for converting a .doc or .docx document to plain text:

NOTE: You will need to add the apache poi libraries to the classpath. On ubuntu/debian the libraries can be installed with sudo apt-get install libapache-poi-java — this will install them under /usr/share/java . For other systems you’ll need to download the library and unpack the archive to a folder that you should use instead of /usr/share/java . If you use maven/gradle (the recommended option), then include the org.apache.poi dependencies as shown in the code snippet.

The same code will work for both .doc and .docx as the required converter implementation will be chosen by inspecting the binary stream.

Compile the class above (assuming it’s in the default package, and the apache poi jars are under /usr/share/java ):

Run the conversion:

A clonable gradle project which pulls all necessary dependencies and generates the wrapper shell script (with gradle installDist ).

Источник

ZapTech

В офисной или производственной среде общий доступ к документам между различными приложениями и операционными системами. Если вам нужно создавать, открывать и редактировать документы Microsoft Word в Linux, вы можете использовать LibreOffice Writer или AbiWord. Оба являются надежными текстовыми приложениями, которые могут читать и записывать файлы в форматах Word .doc и .docx.

Если вам нужны инструменты командной строки, которые извлекают текст из файлов Word, Antiword (файлы .doc) и docx2txt (.docx) являются полезными программами, которые вы можете использовать.

В этом уроке мы рассмотрим эти четыре приложения и то, как вы можете их использовать. Мы рассмотрим их установку в нескольких самых популярных дистрибутивах Linux, включая Debian, Ubuntu, Fedora, OpenSUSE, CentOS и Arch Linux. Мы также поможем с установкой основных шрифтов Microsoft TrueType в вашей системе Linux.

LibreOffice — это бесплатный, активно поддерживаемый и часто обновляемый пакет офисной производительности с открытым исходным кодом, совместимый с приложениями Microsoft Office, включая Microsoft Word. Вы можете сохранить свои документы LibreOffice Writer в формате .doc или .docx, а затем либо правильно открыть в Microsoft Word.

Установка LibreOffice

LibreOffice может быть установлен с помощью вашего менеджера пакетов. Чтобы установить его, откройте терминал и используйте следующую команду, соответствующую вашей операционной системе:

Debian 8, Ubuntu 15

Fedora 23

OpenSUSE 10

CentOS 7

Arch Linux 2016

После установки LibreOffice он должен появиться в меню «Приложения» вашего графического интерфейса. Вы также можете запустить его из терминала с помощью команды:

AbiWord

AbiWord — еще один бесплатный текстовый процессор с открытым исходным кодом. Он имеет простой и понятный интерфейс и разрабатывается почти двадцать лет. Как и LibreOffice, он может открывать, редактировать и сохранять файлы Microsoft Word .doc и .docx. В отличие от LibreOffice, Abiword не является полным офисным пакетом, поэтому он занимает меньше места и потребляет меньше системных ресурсов.

Читайте также:  Rus linux net ��������������� ������ �������

Установка AbiWord

Debian 8, Ubuntu 15

Fedora 23

OpenSUSE 10

CentOS 7

Arch Linux 2016

Antiword

Antiword — это инструмент командной строки, который может преобразовать содержимое файла .doc в обычный текст.

Примечание. Antiword конвертирует только файлы .doc. Если вам нужно конвертировать файл .docx, см. Docx2txt в следующем разделе.

Использование Antiword

Запуск анти-слова с именем файла Word .doc выведет обычный текст файла в стандартный вывод.

Antiword отлично справляется с форматированием таблиц. Он также имеет опции для включения изображений в качестве объектов PostScript и вывода в PDF.

Вы можете перенаправить вывод в текстовый файл:

или, если вы хотите открыть его непосредственно в текстовом редакторе, вы можете передать текст в vim:

Установка антислов

Debian 8, Ubuntu 15

Fedora 23

OpenSUSE 10

CentOS 7

Docx2txt

Docx2txt — это инструмент командной строки, который преобразует файлы .docx в обычный текст. (Он не конвертирует файлы .doc.)

Чтобы распечатать содержимое файла .docx на экране терминала или перенаправить вывод в файл, вызовите docx2txt и укажите дефис в качестве имени выходного файла. В этом примере обратите внимание на тире в конце команды:

Чтобы преобразовать файл .docx и вывести его в текстовый файл, используйте форму команды:

Чтобы открыть текст .docx в vim, используйте форму команды:

Чтобы открыть его в нано:

Чтобы установить doc2txt, следуйте инструкциям для вашей версии Linux ниже:

Debian 8

Ubuntu 15

Fedora 23

Репозитории Fedora не предлагают пакет для docx2txt, но вы можете установить его вручную:

Загрузите исходный код из SourceForge по адресу //sourceforge.net/projects/docx2txt/. Распакуйте архив:

Вы должны убедиться, что perl, unzip и make установлены в вашей системе, поэтому установите или обновите эти пакеты сейчас:

Затем запустите make от имени пользователя root для установки:

Docx2txt теперь установлен как docx2txt.sh . Например, чтобы преобразовать файл word-document.docx в текстовый файл, вы можете запустить:

Преобразованный текстовый файл будет автоматически сохранен как word-document.txt .

OpenSUSE 10

Репозитории SUSE не предлагают пакет для docx2txt, но вы можете скачать его с SourceForge по адресу //sourceforge.net/projects/docx2txt/. Распакуйте архив:

Вы должны убедиться, что perl, unzip и make установлены в вашей системе, поэтому установите или обновите эти пакеты сейчас:

Затем запустите make от имени root для установки:

Docx2txt теперь установлен как docx2txt.sh . Например, чтобы преобразовать файл word-document.docx в текстовый файл, вы можете запустить:

Преобразованный текстовый файл будет автоматически сохранен как word-document.txt .

CentOS 7

В репозиториях CentOS нет пакета для docx2txt, но вы можете скачать его с SourceForge по адресу //sourceforge.net/projects/docx2txt/. Распакуйте архив:

Вы должны убедиться, что perl, unzip и make установлены в вашей системе, поэтому установите или обновите эти пакеты сейчас:

Затем запустите make от имени root для установки:

Docx2txt теперь установлен как docx2txt.sh . Например, чтобы преобразовать файл word-document.docx в текстовый файл, вы можете запустить:

Преобразованный текстовый файл будет автоматически сохранен как word-document.txt .

Arch Linux 2016

Установка Microsoft-совместимых шрифтов

Основные шрифты Microsoft доступны в Linux, и вам следует установить их, если вы собираетесь работать с файлами Microsoft Word — особенно, если они были созданы в системе Windows. Основные шрифты включают в себя:

  • Андале Моно
  • Arial
  • Arial Black
  • Calabri
  • Камбрия
  • комический
  • курьер
  • Влияние
  • раз
  • Требушет
  • Verdana
  • Webdings

Чтобы установить их, выполните следующие действия:

Debian 8, Ubuntu 15

Fedora 23

Загрузите RPM-пакет установщика msttcore из SourceForge.

Установите пакеты, необходимые для установки:

Затем установите локальный пакет RPM:

OpenSUSE 10

Загрузите RPM-пакет установщика msttcore из SourceForge.

Установите пакеты, необходимые для установки:

Затем установите локальный пакет RPM:

CentOS 7

Загрузите RPM-пакет установщика msttcore из SourceForge.

Установите пакеты, необходимые для установки:

Затем установите локальный пакет RPM:

Arch Linux 2016

Загрузите RPM-пакет установщика msttcore из SourceForge.

Установите пакеты, необходимые для установки:

Извлеките содержимое локального пакета RPM:

Эта команда извлекает необработанное содержимое файла RPM и создает два каталога, etc и usr, которые соответствуют вашим каталогам / etc и / usr . Сами файлы шрифтов находятся в usr / share / fonts / msttcore .

Источник

Оцените статью