API Documentation
Word content
Format conversion
CryptoPHPDOCX
Digital Signature package
DOCX2TXT
Extracts the text contents from a Word document.
PRO, PRO+ and CORPORATE PHPDocX >= 2.6
Description
public DOCX2TXT (string $source, string $target [, array $options])
This method allows to extract the text from a docx document with a few styling options:
- indent lists,
- tables as tabbed text,
- footnotes and endnotes,
- etcetera.
Parameters
source
The path to the docx from which we want to extract the text.
target
The path to the txt destination file.
options
The posible keys and values are:
| key | Type | Description |
|---|---|---|
| table | bool | True (default) if you want to parse tables as tabbed paragraps. |
| list | bool | True (default) if you want to parse lists as txt lists. |
| paragraph | bool | True (default) if you want to preserve the paragraph structure. |
| footnote | bool | True (default) if you want to include the footnotes. |
| endnote | bool | True (default) if you want to include the footnotes. |
| chart | int | Posible values are:
|
Return values
Void.
Code samples
Example #1: docx to txt with different styling options
require_once '../../classes/CreateDocx.inc';
$options = array('paragraph' => false, 'list' => false,'table' => false, 'footnote' => false, 'endnote' => false, 'chart' => 0);
CreateDocx::DOCX2TXT('../files/ExampleDoc.docx', '../docx/Document_1.txt', $options);
$options['paragraph'] = true;
CreateDocx::DOCX2TXT('../files/ExampleDoc.docx', '../docx/Document_2.txt', $options);
$options['list'] = true;
CreateDocx::DOCX2TXT('../files/ExampleDoc.docx', '../docx/Document_3.txt', $options);
$options['table'] = true;
CreateDocx::DOCX2TXT('../files/ExampleDoc.docx', '../docx/Document_4.txt', $options);
$options['footnote'] = true;
CreateDocx::DOCX2TXT('../files/ExampleDoc.docx', '../docx/Document_5.txt', $options);
$options['endnote'] = true;
CreateDocx::DOCX2TXT('../files/ExampleDoc.docx', '../docx/Document_6.txt', $options);
$options['chart'] = 1;
CreateDocx::DOCX2TXT('../files/ExampleDoc.docx', '../docx/Document_7.txt', $options);
$options['chart'] = 2;
CreateDocx::DOCX2TXT('../files/ExampleDoc.docx', '../docx/Document_8.txt', $options);

Change log
- Available since 2.6
Available examples
See also
PHPDocx. Dinamic generation of reports in .docx format 

