PDF Signature: "Expected a dict object"

Viewed 128

I'm creating a library for digitally signing a PDF document. During my quest I stumbled upon an other problem.

In Acrobat I'm getting the error:

Error during signature verification.  

Adobe Acrobat error.
Expected a dict object.

I know it expects a dictionary object somewhere. But I have no idea where. This problem shows up when I add the image to the AP of the signature. For this I'm basing my implementation on the spec, and " Insert multiple digital approval signatures without invalidating the previous one "

Most of this seems to work correctly, but when the image is present it results in the error. The image is correctly visible.

Current working:

(This is a very short overview of the part where the error is, it might be slightly different, but hope this helps)

  • I update the signature annotation. Add link to object that contains normal appearance.
16 0 obj
<<
  /Type/Annot
  /Subtype/Widget
  ...snip...
  /AP<<
    /N 21 0 R
  >>
>>
  • Add image as XObject
20 0 obj
<<
  /Type/XObject
  /Subtype/Image
  ...snip...
  /Length 29569
>>
stream
...snip...
endstream 
endobj
  • Add XObject (Normal appearance)
21 0 obj
<<
  /Type/XObject
  /Subtype/Form
  /Resources<<
    /XObject<<
      /UserSignature272 20 0 R
    >>
  >>
  /BBox[0 0 135 37.5]
  /Length 44
>>stream
q
135 0 0 37.5 0 0 cm
/UserSignature272 Do
Q
endstream 
endobj

I think the problem happens somewhere in obj (21 0), but I'm not sure.

Here is a minimal file that can be used for testing. https://drive.google.com/file/d/17sdz2xJy3VhN6i9YiuPrJ6x2s5kU2sra/view?usp=sharing

Any help, or hints would be welcome.

(This post is a continuation of PDF Digital Signature has "Bad parameter" in Acrobat, but is about a different problem, same subject area.)

1 Answers

You're running into a bug of Adobe Acrobat here: If you display a XObject from inside your signature appearance stream, it expects that XObject to have a Resources entry. This may make sense in case of form XObjects but it doesn't for image XObjects like in your case.

A work around is to add an empty Resources dictionary to your image XObject.

I checked this by replacing the /BBox[1 0 0 1 0 0] in your image XObject (which is not needed there anyways) by /Resources<< >>.


When Adobe Acrobat creates its own signature appearances, it creates a hierarchy of form XObjects here with Resource dictionaries all over including those for the "layers". I assume Adobe Reader, seeing the Do operator attempts to collect information on such "layers", not expecting to immediately be confronted with an image XObject.

Related