Hopding / pdf-lib

Create and modify PDF documents in any JavaScript environment
https://pdf-lib.js.org
MIT License
6.92k stars 660 forks source link

Retrieve V() field of a Signature. #851

Closed vicpara closed 3 years ago

vicpara commented 3 years ago

When I access the /Sig fields of an acroform, like the V() field, it comes back as a PDFRef to a PDFDict. I can see the content when calling toString() but how can I actually get the actual Dict behind the reference?

The object itself that I obtain as the result of calling field.acrofield.V() , doesn't allow me to iterate through the map or retrieve any other sub object. What is the correct way of accessing it?

<ref *1> PDFDict {
  dict: Map(9) {
    PDFName { encodedName: '/Type' } => PDFName { encodedName: '/Sig' },
    PDFName { encodedName: '/Filter' } => PDFName { encodedName: '/Adobe.PPKLite' },
    PDFName { encodedName: '/SubFilter' } => PDFName { encodedName: '/adbe.pkcs7.detached' }
...
Hopding commented 3 years ago

You can resolve a PDFRef instance to the underlying value with pdfDoc.context.lookup(ref).