FPDI icon indicating copy to clipboard operation
FPDI copied to clipboard

setSourceFile from stream - Error "Object (id:24) not found at location (93829)"

Open franck-grenier opened this issue 2 years ago • 1 comments

Hello FPDI, I'm trying to instantiate a \setasign\Fpdi\Fpdi object from a stream and I get the below error:

Object (id:24) not found at location (93829).

  at vendor/setasign/fpdi/src/PdfParser/CrossReference/CrossReference.php:176
    172▕         try {
    173▕             /** @var PdfIndirectObject $object */
    174▕             $object = $parser->readValue(null, PdfIndirectObject::class);
    175▕         } catch (PdfTypeException $e) {
  ➜ 176▕             throw new CrossReferenceException(
    177▕                 \sprintf('Object (id:%s) not found at location (%s).', $objectNumber, $offset),
    178▕                 CrossReferenceException::OBJECT_NOT_FOUND,
    179▕                 $e
    180▕             );

This stream has a specificity. It has a registered "filter" (see PHP stream_filter_append) to decrypt the content while reading.

If I pass a stream to a fully decrypted file, instantiation works fine.

Do you know any limitations with FPDI (or PDF in general) around that ?

franck-grenier avatar Jan 23 '23 14:01 franck-grenier

Interesting issue. I guess by this the offsets are out of control. I must admit that I don't know how filters internally work but that's my simple guessing.

Are you able to provide an example with both simple encryption and decryption filters?

JanSlabon avatar Jan 23 '23 15:01 JanSlabon