Repository navigation
2.1.0: no shell, configurable timeout
Keeps the 2.0 API. Requires PHP >= 8.1 and symfony/process ^5.4 || ^6.4 || ^7.0 || ^8.0; Composer keeps older installations on 2.0.1. See Upgrading from 2.0.
Security
- pdftotext is run with a list of arguments instead of a shell command. In 2.0 the file name was put in single quotes, so a name containing
'broke the command and allowed command injection.
Added
- Options as an array, one argument per entry;
addOptions()appends. - Fluent settings:
layout(),raw(),encoding(),eol(),firstPage(),lastPage(),pages(),page(),password(),ownerPassword(). timeout(): configurable timeout (default 60 seconds as before,nullfor none); a timeout throwsProcessTimedOut, which extends Symfony'sProcessTimedOutException.sanitizeUtf8(): replace invalid UTF-8 with U+FFFD.command(): the command as a list of arguments.Extract::findExecutable()andExtract::normalizeOptions().PdftotextExceptioninterface, implemented by all exceptions;InvalidOptionfor invalid settings.CouldNotExtractText::getErrorTail().
Changed
- Requires PHP >= 8.1 and symfony/process ^5.4 || ^6.4 || ^7.0 || ^8.0. Composer keeps older installations on 2.0.1.
- Option strings are still accepted; they are split like a shell would split them (quotes, backslashes), but no shell runs them.
- The executable is found with Symfony's
ExecutableFinder(PATH, then common directories) instead ofwhich/type -Pin a shell. A path is checked as given. - Exception messages name the file, the exit code and the last lines of stderr instead of the command line and the full output, so passwords do not end up in logs.
BinaryNotFoundandCouldNotExtractTextstill extendProcessFailedException. pdf()throwsFileNotFoundfor a directory, too.- A relative path starting with
-is passed as./-…, so it is not read as an option. - The protected property
$optionsholds an array. - CI on GitHub Actions for PHP 8.1 to 8.5; Travis CI removed. Tests and CI files are no longer part of the dist archive.