Repository navigation
Releases
Releases · ottosmops/pdftotext
2.2.0: hyphenation and ligatures
Adds optional text clean-ups; the output of text() does not change unless they are switched on. Includes the security fix of 2.1.0.
Added
TextCleaner::joinHyphenation()andExtract::joinHyphenation(): join words hyphenated at the end of a line («Familien-↵anlass» → «Familienanlass»; before an upper-case letter the hyphen stays, digits, blank lines and page breaks are left alone) and remove soft hyphens. Knows the plain and the Unicode hyphen, the Fraktur double hyphen «⸗» and «¬».TextCleaner::expandLigatures()andExtract::expandLigatures(): replace the ligatures U+FB00–U+FB06 (ff fi fl ffi ffl ſt st) with their letters.- Both are off by default; the output of
text()does not change unless they are switched on.
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.
2.0.1
Security: 2.0.1 and earlier are affected by command injection through a file name containing
'. Upgrade to 2.1.0 or later.
- Remove PHP 5.6 reference from docs
- Add GitHub Actions workflow for CI and code coverage
- Add codecov badge to README
- Improve documentation and security notes
- Minor Markdown and PHPDoc improvements
- PHPUnit 12 compatibility (test methods, config, autoloading)
- Test setup and config modernized (phpunit.xml, composer, coverage)
Version 2.0.0
php >= 7.2
symfony/process >=4.2
phpunit >=8.2
Set the upper version for symphony processor to 4.1.
Merge pull request #2 from ceckobecko/improvement/limit-symphony-version Set the upper version for symphony processor to 4.1.*