2

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.)

Ralph Bisschops
  • 1,888
  • 1
  • 22
  • 34
  • Does this have anything to do with Rust? – hkBst Jul 11 '22 at 09:38
  • The question, not much, but library is written in Rust. Will remove the tag. – Ralph Bisschops Jul 11 '22 at 09:41
  • In the initial PDF revision the catalog dictionary is in an object stream. In Adobe Acrobat this can cause problems. (In the PDF specification this is only forbidden for linearized PDFs, but Adobe Acrobat seems to rely on the catalog not being in an object stream in other contexts, too.) I don't know whether that causes your issue, but it is likely to cause some issues eventually. – mkl Jul 11 '22 at 11:40

1 Answers1

2

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.

mkl
  • 90,588
  • 15
  • 125
  • 265
  • Thanks mkl! I was running into the same problem and your solution helped! Quick question: *How* do you find out something like that? – gettalong Jun 30 '23 at 21:15
  • *"Quick question: How do you find out something like that?"* - Trial and error ;) . And some years of experience with things Acrobat likes or likes not. – mkl Jun 30 '23 at 22:28
  • Ah, the joys of software engineering ;-) It probably would have taken me ages to find that out by... trial and error. So thank you very much! – gettalong Jul 01 '23 at 08:47