TCPDF
TCPDF copied to clipboard
Wrong /Length calculation in xobjects
The method _putxobjects calculate the stream length:
1 - $stream = $this->_getrawstream($stream, $data['n']);
2 - $out .= ' /Length '.strlen($stream);
3 - $out .= ' >>';
4 - $out .= ' stream'."\n".$stream."\n".'endstream'; // INCREMENTED MORE BYTES HERE
5 - $out .= "\n".'endobj';
6 - $this->_out($out);
but on line 4 $out .= ' stream'."\n".$stream."\n".'endstream'; is incremented more bytes (\n) resulting in a wrong calculation
Sugestion
Move the break line from line 4 to line 1:
1 - $stream = "\n" . $this->_getrawstream($stream, $data['n']) . "\n";
2 - $out .= ' /Length '.strlen($stream);
3 - $out .= ' >>';
4 - $out .= ' stream' . $stream . 'endstream';