Procházet zdrojové kódy

fix: 数字签名 bug 修复

liutian před 10 měsíci
rodič
revize
ff51d93141

+ 6 - 6
packages/core/src/index.js

@@ -551,14 +551,14 @@ class ComPDFKitViewer {
           const blob = await response.blob()
           const certFile = new File([blob], 'result_sign.pfx', { type: blob.type })
           this.certFile = certFile
-          const a = await this.messageHandler.sendWithPromise('AddSignature', {
-            doc: this.doc,
-            pagePtr: this.pagesPtr[0],
-            certFile,
-          })
+          // const a = await this.messageHandler.sendWithPromise('AddSignature', {
+          //   doc: this.doc,
+          //   pagePtr: this.pagesPtr[0],
+          //   certFile,
+          // })
 
           // console.log(a)
-          saveAs(a, 'test.pdf')
+          // saveAs(a, 'test.pdf')
 
           if (this.webviewerServer) {
             if (this.controller) {

+ 8 - 7
packages/core/src/worker/compdfkit_worker.js

@@ -370,10 +370,10 @@ class CPDFWorker {
       //   annotPtr,
       //   date: new Date()
       // })
-      // setWidgetFieldName({
-      //   annotPtr,
-      //   fieldName: 'sign11'
-      // })
+      setWidgetFieldName({
+        annotPtr,
+        fieldName: 'sign11'
+      })
 
       setAnnotRect({
         pagePtr,
@@ -386,7 +386,7 @@ class CPDFWorker {
       const signaturePtr = Module._InitSignature2(annotPtr)
 
       const addResult = Module._AddSignSaveDocument(doc, signaturePtr, certPtr)
-      // console.log(addResult)
+      console.log(addResult)
 
       let pdfData = []
       for (let i = 0; i < DataArray.length; i++) {
@@ -2634,7 +2634,8 @@ async function getSignatures({
             ComPDFKitJS.opened_cert[i] = CertArray[0]
 
             const certLength = ComPDFKitJS.opened_cert[i].length
-            const result = Module._VerifyGetChain(signerPtr, certPtr, i, certLength)
+            const result = Module._VerifyGetChain(signaturePtr, certPtr, i, certLength)
+            console.log(result)
             if (result === 1) {
               signer.isCertTrusted = true
               for (let f = 0; f < signer.certificateList.length; f++) {
@@ -2704,7 +2705,7 @@ async function getSignatures({
         signature.reason = U8StringData
         Module._GetSignatureLocation(signaturePtr)
         signature.location = U8StringData
-        signature.pageIndex = Module._GetSignaturePageIndex(signaturePtr)
+        signature.pageIndex = Module._GetSignaturePageIndex(doc, signaturePtr)
         signature.isDigital = 1
       } else {
         signature.isDigital = 0