Forum


Replies: 4   Views: 364
Pdf merge returns unsupported operand types: string + int
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by test39000  · 03-06-2024 - 10:32

Hello 

I'm using PHPDocx 13 and I have a problem when I try to merge 3 PDFs. I get the error “Unsupported operand types: string + int”, The problem seems to come from the function extractObjectStream() of the TCPDF library (TCPDF_autoconfig.php) which makes a regex 

$ints = preg_split('/\s/', substr($stream[0], 0, $first));

and returns an empty string in the return array, leading to the error at line 

$this->objstreamobjs[$ints[$j-1]] = array($key, $ints[$j]+$first);

where $ints[$j] is an empty string and $first is an integer and this is the reason for my error. 

The library is installed locally and changing the regex to '/\s+/' seems to correct the problem, but I don't have enough solid knowledge of the library and TCPDF to be sure that this won't cause side effects.

Has anyone come across this situation before? Where does the problem come from? And how did you fix it? Is my solution possible? 

Thanks

Posted by admin  · 03-06-2024 - 10:40

Hello,

Your username doesn't have any license tied. Please send to contact[at]phpdocx.com the username or email of the user that purchased the license you are using.

Also please send the PDF samples that illustrate your issue and the PHP version you are using.

Regards.

Posted by test39000  · 03-06-2024 - 14:36

Deleted by test39000 · 03-06-2024 - 14:36

Posted by e.delebecque  · 03-06-2024 - 14:37

Thank you for your reply.

This is the account the customer uses. I can't send you the PDF documents because they contain sensitive data.

Do you have any idea? 

Posted by admin  · 03-06-2024 - 14:58

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.