Extract text from a Word Doc

v2.0.0 2020-10-12 09:59 UTC

This package is auto-updated.

Last update: 2024-05-16 03:22:53 UTC


Latest Version on Packagist Software License Build Status Quality Score Total Downloads

This package provides a class to extract text from a Word Doc.


use Jaybizzle\DocToText\Doc;

echo Doc::getText('book.doc'); // returns the text from the doc


Behind the scenes this package leverages antiword. You can verify if the binary is installed on your system by issuing this command:

which antiword

If it is installed it will return the path to the binary.

To install the binary you can use this command on Ubuntu or Debian:

apt-get install antiword


You can install the package via composer:

composer require jaybizzle/doc-to-text


Extracting text from a Doc is easy.

$text = (new Doc())

Or easier:

echo Doc::getText('book.doc');

By default the package will assume that the antiword command is located at /usr/bin/antiword. If it is located elsewhere pass its binary path to the constructor

$text = (new Doc('/custom/path/to/antiword'))

or as the second parameter to the getText static method:

echo Doc::getText('book.doc', '/custom/path/to/antiword');

Sometimes you may want to use antiword options. To do so you can set them up using the setOptions method.

$text = (new Doc())
    ->setOptions(['f', 'w 80'])

or as the third parameter to the getText static method:

echo Doc::getText('book.doc', null, ['f', 'w 80']);

Change log

Please see CHANGELOG for more information about what has changed recently.


 composer test


If you discover any security related issues, please email mbeech@mark-beech.co.uk instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.