Browse Source

ComPDFKit(RN) - iOS 返回注释信息校对

yangliuhua 6 days ago
parent
commit
b0b07d1b35
1 changed files with 14 additions and 8 deletions
  1. 14 8
      ios/RCTCPDFPageUtil.swift

+ 14 - 8
ios/RCTCPDFPageUtil.swift

@@ -37,7 +37,7 @@ class RCTCPDFPageUtil: NSObject {
             if annoation.type == "Widget" {
                 continue
             }
-            
+             
             switch type {
             case "Highlight", "Squiggly", "Underline", "Strikeout":
                 if let markupAnnotation = annoation as? CPDFMarkupAnnotation {
@@ -95,9 +95,7 @@ class RCTCPDFPageUtil: NSObject {
                 
             case "FreeText":
                 if let freeTextAnnotation = annoation as? CPDFFreeTextAnnotation {
-                    let lowertype = lowercaseFirstLetter(of: type)
-                    
-                    annotaionDict["type"] = lowertype
+                    annotaionDict["type"] = "freetext"
                     annotaionDict["title"] = freeTextAnnotation.userName()
                     annotaionDict["page"] = pageIndex
                     annotaionDict["content"] = freeTextAnnotation.contents
@@ -128,18 +126,26 @@ class RCTCPDFPageUtil: NSObject {
                 
             case "Media":
                 if let mediaAnnotation = annoation as? CPDFSoundAnnotation {
-                    let lowertype = lowercaseFirstLetter(of: type)
-                    
-                    annotaionDict["type"] = lowertype
+                    annotaionDict["type"] = "sound"
                     annotaionDict["title"] = mediaAnnotation.userName()
                     annotaionDict["page"] = pageIndex
                     annotaionDict["content"] = mediaAnnotation.contents
                 }
+            case "":
+                if let signatureAnnotation = annoation as? CPDFSignatureAnnotation {
+                    annotaionDict["type"] = "signature"
+                    annotaionDict["title"] = signatureAnnotation.userName()
+                    annotaionDict["page"] = pageIndex
+                    annotaionDict["content"] = signatureAnnotation.contents
+                }
+                    
             default:
                 print("Unhandled type: \(type)")
             }
             
-            annotaionDicts.append(annotaionDict)
+            if annotaionDict["type"] != nil {
+                annotaionDicts.append(annotaionDict)
+            }
         }
         
         return annotaionDicts