{file2text:url}

Description

Reads the plain-text content out of an uploaded DOC, DOCX, PDF or ODT file, so the text can be searched or indexed. The url argument is the file path or address - usually a file-field getter. The install must define the matching external converter (CONV_TEXTFILTERS_DOC, _DOCX, _PDF or _ODT); if the converter for that file type is not configured, or the extension is none of those four, the result is empty. Output is runtime-dependent and never cached. Typical use: a Computed field stores the extracted text so an ordinary text search finds words inside attachments.

Parameters

url required

File path or address of the DOC, DOCX, PDF or ODT file to read - usually a file-field getter like {file............}. The file is always downloaded over HTTP, the same way as by include with type http: a relative path is fetched from this server (with the visitor cookies), a full address from anywhere public - addresses in private networks are refused, only a successful (2xx) answer counts, and the download may take up to 300 seconds. The extension at the very end of the url decides which converter runs - a query string after it, as in report.pdf?download=1, matches nothing; an unmatched extension or an unconfigured converter yields empty output.

Examples

test[{file2text:}]
Expected[]
Actual[]
With no file given there is nothing to read, so the result is an empty string. The brackets just make the empty output visible.
virtual{file2text:https://example.org/files/report.pdf}
Expected(the text of report.pdf, e.g. "Annual report 2025 ...")
Give an absolute address and the file is downloaded, then read. Put a call like this in a Computed field so the documents words are stored alongside the item; an ordinary text search then matches content inside the PDF.
virtual{convert:{file2text:{file............}}:utf-8:windows-1250}
Expected(the extracted text, transcoded from utf-8 to windows-1250)
The converter returns UTF-8 text. Wrap it in {convert:..:from:to} when the field that stores the result expects a different character set, for example windows-1250.
virtual{file2text:{file............}}
Expected(the plain text extracted from the uploaded file)
The common pattern: pass a file-field getter so the command reads whichever document the editor uploaded. The actual output is the documents extracted text, which depends on the uploaded file and on the installs configured converter.
test[{file2text:notes.txt}]
Expected[]
Actual[]
Only DOC, DOCX, PDF and ODT are recognised. A .txt (or any other extension) matches no converter, so the output is empty - no file is fetched or run.