Hello,
Sorry, but we would need to check a PDF sample to know the source of the issue and if it uses a valid internal structure or it could be repaired (https://www.phpdocx.com/documentation/cookbook/repair-PDF).
We have done some quick tests with your change and it's working correctly, but we think the best approach would be to use:
$this->objstreamobjs[$ints[$j-1]] = array($key, ((int)$ints[$j])+$first);
instead of changing the regex, but without a sample PDF file it's not possible to know the best solution and the exact problem.
What PHP version are you using? Do you get a PHP Error, a PHP Warning, or a PHP Notice? We have done some tests with PHP 5.6, PHP 7.4, PHP 8.0, PHP 8.1, PHP 8.2, and PHP 8.3 and the error doesn't appear. Do you get the same error if you run the samples included in the package? Are you using some debugger that may change the default error reporting such as xdebug? In any case, we have included the previous change in the current testing branch of phpdocx.
Regards.