Parcourir la source

【注释】Stamp、Signature图章签名注释属性面板补充(自定义Stamp弹窗功能需对接功能)

wanjun il y a 1 an
Parent
commit
0c7febe0ad

+ 1 - 1
PDF Office/PDF Master/Class/DigtalSignature/ViewControllers/DSignatureCreateInfoViewController.xib

@@ -6,7 +6,7 @@
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="DSignatureCreateInfoViewController" customModule="PDF_Reader_Pro" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="DSignatureCreateInfoViewController" customModule="PDF_Master" customModuleProvider="target">
             <connections>
                 <outlet property="contendView" destination="hY4-zY-c9z" id="ZYH-hi-9Cb"/>
                 <outlet property="continueButton" destination="dSu-Sg-ba6" id="Ka7-RD-2gL"/>

+ 14 - 2
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMAnnotationPropertiesViewController.m

@@ -260,7 +260,13 @@
             self.contentViewController = vc;
         }
         
-    } else if ([annotation isKindOfClass:[CPDFStampAnnotation class]]) {
+    } else if ([annotation isKindOfClass:[KMAnnotationStamp class]]) {
+        KMAnnotationStampViewController *vc = [[KMAnnotationStampViewController alloc] init];
+        vc.pdfView = self.pdfView;
+        vc.annotationModel = annotationModel;
+        vc.view.frame = [self viewControllerRect];
+        [self.view addSubview:vc.view];
+        self.contentViewController = vc;
     } else if ([annotation isKindOfClass:[CPDFListSignatureAnnotation class]]) {
         
     } else if ([annotation isKindOfClass:[CPDFSignatureAnnotation class]]) {
@@ -481,6 +487,12 @@
         self.contentViewController = vc;
     } else if (annotationMode == CAnnotationTypeStamp) {
         self.titleViewHeightConstraint.constant = 0;
+        KMAnnotationStampViewController *vc = [[KMAnnotationStampViewController alloc] init];
+        vc.pdfView = self.pdfView;
+        vc.annotationModel = annotationModel;
+        vc.view.frame = [self viewControllerRect];
+        [self.view addSubview:vc.view];
+        self.contentViewController = vc;
     } else if (annotationMode == CAnnotationTypeSignSignature) {
         KMSignatureAnnotationViewController *vc = [[KMSignatureAnnotationViewController alloc] init];
         self.titleViewHeightConstraint.constant = 0;
@@ -488,7 +500,7 @@
         vc.pdfView = self.pdfView;
         self.propertiesBox.contentView = vc.view;
         self.contentViewController = vc;
-    }
+    } 
 }
 
 - (void)setIsEmptyAnnotation:(BOOL)isEmptyAnnotation

+ 0 - 285
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.swift

@@ -235,21 +235,6 @@ let KMColorPickerViewHeight: CGFloat = 64
             }
         }
 
-//        if let textAnnotation = annotation as? CPDFTextAnnotation, annotationMode == .anchored {
-//            let keys: [String] = ["string", "color", SKAnchoredNoteIconTypeKey]
-//            for key in keys {
-//                textAnnotation.removeObserver(self, forKeyPath: key)
-//            }
-//        } else {
-//            let keys: [String] = ["string", "color", "interiorColor", "border", "font", "fontColor", "alignment"]
-//            for key in keys {
-//                annotation.removeObserver(self, forKeyPath: key)
-//            }
-//        }
-
-//        if let textAnnotation = annotation, textAnnotation.responds(to: #selector(CPDFAnnotation.string)) {
-//            textAnnotation.string = noteTextView.string ?? ""
-//        }
         textColorPickerView.target = nil
         textColorPickerView.action = nil
         borderColorPickerView.target = nil
@@ -581,154 +566,6 @@ let KMColorPickerViewHeight: CGFloat = 64
         }
     }
     
-    func annotationImage() -> NSImage? {
-        var image: NSImage?
-        
-        if annotationType == .freeText {
-            var string = NSLocalizedString("Sample", comment: "")
-
-            var attributes = [NSAttributedString.Key: Any]()
-            attributes[.font] = NSFont(name: (annotationModel?.fontName())!, size: (annotationModel?.fontSize())!)
-            attributes[.foregroundColor] = annotationModel?.fontColor()
-            attributes[.backgroundColor] = annotationModel?.color()
-
-            let size = (string as NSString).size(withAttributes: attributes)
-            if size.equalTo(.zero) {
-                return nil
-            }
-            image = NSImage(size: size)
-            image?.lockFocus()
-            NSGraphicsContext.current?.imageInterpolation = .high
-            (string as NSString).draw(in: NSMakeRect(0, 0, size.width, size.height), withAttributes: attributes)
-            NSGraphicsContext.current?.imageInterpolation = .default
-            image?.unlockFocus()
-        }
-//        if annotation.isKind(of: CPDFSquareAnnotation.self) ||
-//            annotation.isKind(of: CPDFCircleAnnotation.self) ||
-//            annotation.isKind(of: CPDFLineAnnotation.self) {
-//            
-//            var copyAnnotation = annotation
-//
-//            if !isannotationMode {
-//                copyAnnotation = annotation.copy() as! CPDFAnnotation
-//            }
-//
-//            copyAnnotation.bounds = NSMakeRect(0, 0, 50, 50)
-//
-//            if annotation.isKind(of: CPDFLineAnnotation.self) {
-//                let newAnnotation = (annotation as! CPDFLineAnnotation)
-//                copyAnnotation.bounds = NSMakeRect(0, 0, 200, 200)
-//                if newAnnotation.startLineStyle == .none {
-//                    (copyAnnotation as! CPDFLineAnnotation).startPoint = NSMakePoint(0, 0)
-//                } else {
-//                    (copyAnnotation as! CPDFLineAnnotation).startPoint = NSMakePoint(3 * CGFloat(lineWidthSlider.integerValue), 3 * CGFloat(lineWidthSlider.integerValue))
-//                }
-//
-//                if newAnnotation.endLineStyle == .none {
-//                    (copyAnnotation as! CPDFLineAnnotation).endPoint = NSMakePoint(200, 200)
-//                } else {
-//                    (copyAnnotation as! CPDFLineAnnotation).endPoint = NSMakePoint(copyAnnotation.bounds.size.width - 3 * CGFloat(lineWidthSlider.integerValue), copyAnnotation.bounds.size.height - 3 * CGFloat(lineWidthSlider.integerValue))
-//                }
-//            }
-//
-//            image = NSImage(size: copyAnnotation.bounds.size)
-//            image?.lockFocus()
-//            NSGraphicsContext.current?.imageInterpolation = .high
-//            if let context = NSGraphicsContext.current?.cgContext {
-//                copyAnnotation.setBorderStyle(annotation.border?.style ?? .solid)
-//                copyAnnotation.draw(with: .cropBox, in: context)
-//            }
-//            NSGraphicsContext.current?.imageInterpolation = .default
-//            image?.unlockFocus()
-//        } else if annotation is CPDFInkAnnotation {
-//            image = NSImage(size: generalImageView.bounds.size)
-//            image?.lockFocus()
-//            NSGraphicsContext.current?.imageInterpolation = .high
-//            if let context = NSGraphicsContext.current?.cgContext {
-//                let width = image!.size.width / 3.0
-//                let height = image!.size.height / 2.0
-//                context.move(to: CGPoint(x: 0, y: height))
-//                context.addCurve(to: CGPoint(x: width * 3.0, y: height),
-//                                 control1: CGPoint(x: width, y: height + 25),
-//                                 control2: CGPoint(x: width * 2.0, y: height - 25))
-//                context.setLineWidth(annotation.border?.lineWidth ?? 1.0)
-//                context.setStrokeColor((annotation.color ?? NSColor.black).cgColor)
-//
-//                if annotation.border?.style == .dashed {
-//                    if let dashPattern = annotation.border?.dashPattern, dashPattern.count > 0 {
-//                        var lengths = [CGFloat]()
-//                        for length in dashPattern {
-//                            lengths.append(CGFloat(truncating: length as! NSNumber))
-//                        }
-//                        context.setLineDash(phase: 0, lengths: lengths)
-//                    }
-//                }
-//
-//                context.strokePath()
-//            }
-//            NSGraphicsContext.current?.imageInterpolation = .default
-//            image?.unlockFocus()
-//        } else if annotation is CPDFFreeTextAnnotation {
-//            var string = NSLocalizedString("Sample", comment: "")
-//            if annotation is KMSelfSignAnnotationFreeText {
-//                let newAnnotation = (annotation as! KMSelfSignAnnotationFreeText)
-//                string = newAnnotation.string().count > 0 ? newAnnotation.string() : NSLocalizedString("Sample", comment: "")
-//            }
-//
-//            var attributes = [NSAttributedString.Key: Any]()
-//            attributes[.font] = (annotation as! CPDFFreeTextAnnotation).font
-//            attributes[.foregroundColor] = (annotation as! CPDFFreeTextAnnotation).fontColor
-//            attributes[.backgroundColor] = (annotation as! CPDFFreeTextAnnotation).color
-//
-//            let size = (string as NSString).size(withAttributes: attributes)
-//            if size.equalTo(.zero) {
-//                return nil
-//            }
-//            image = NSImage(size: size)
-//            image?.lockFocus()
-//            NSGraphicsContext.current?.imageInterpolation = .high
-//            (string as NSString).draw(in: NSMakeRect(0, 0, size.width, size.height), withAttributes: attributes)
-//            NSGraphicsContext.current?.imageInterpolation = .default
-//            image?.unlockFocus()
-//        } else if annotation.isKind(of: CPDFMarkupAnnotation.self) {
-//            let newAnnotation = (annotation as! CPDFMarkupAnnotation)
-//            var string = NSLocalizedString("Sample", comment: "")
-//            var attributes = [NSAttributedString.Key: Any]()
-//            attributes[.font] = NSFont.systemFont(ofSize: 30)
-//            attributes[.foregroundColor] = KMAppearance.Layout.h0Color()
-//
-//            if newAnnotation.markupType() == .highlight {
-//                attributes[.backgroundColor] = newAnnotation.color
-//            } else if newAnnotation.markupType() == .strikeOut {
-//                attributes[.strikethroughStyle] = 1
-//                attributes[.strikethroughColor] = newAnnotation.color
-//            } else if newAnnotation.markupType() == .underline {
-//                attributes[.underlineStyle] = 1
-//                attributes[.underlineColor] = newAnnotation.color
-//            }
-//
-//            let size = (string as NSString).size(withAttributes: attributes)
-//            image = NSImage(size: size)
-//            image?.lockFocus()
-//            NSGraphicsContext.current?.imageInterpolation = .high
-//            (string as NSString).draw(in: NSMakeRect(0, 0, size.width, size.height), withAttributes: attributes)
-//            NSGraphicsContext.current?.imageInterpolation = .default
-//            image?.unlockFocus()
-//        } else {
-//            image = NSImage(size: annotation.bounds.size)
-//            image?.lockFocus()
-//            NSGraphicsContext.current?.imageInterpolation = .high
-//            if let context = NSGraphicsContext.current?.cgContext {
-//                context.translateBy(x: -annotation.bounds.origin.x, y: -annotation.bounds.origin.y)
-//                annotation.draw(with: .cropBox, in: context)
-//            }
-//            NSGraphicsContext.current?.imageInterpolation = .default
-//            image?.unlockFocus()
-//        }
-
-        return image
-    }
-    
     // MARK: Set & Get
     
     var annotations: [CPDFAnnotation] {
@@ -744,99 +581,6 @@ let KMColorPickerViewHeight: CGFloat = 64
     }
     
     var annotationType: CAnnotationType {
-//        set {
-//            _annotationMode = newValue
-//            isannotationMode = true
-//            let userDefaults = UserDefaults.standard
-//            var newAnnotation: CPDFAnnotation?
-//            let bounds = NSMakeRect(0, 0, 50, 50)
-//            
-//            if newValue == .freeText {
-//                if subType == .none {
-//                    newAnnotation = KMSelfSignAnnotationFreeText(document: (pdfView?.document!)!, subType: subType, string: "", bounds: bounds)
-//                    newAnnotation?.color = userDefaults.color(forKey: CFreeTextNoteColorKey)
-//                    (newAnnotation as! KMSelfSignAnnotationFreeText).fontColor = userDefaults.color(forKey: CFreeTextNoteFontColorKey)
-//                    (newAnnotation as! KMSelfSignAnnotationFreeText).alignment = NSTextAlignment(rawValue: userDefaults.integer(forKey: CFreeTextNoteAlignmentKey))!
-//                    let font = userDefaults.font(forNameKey: CFreeTextNoteFontNameKey, sizeKey: CFreeTextNoteFontSizeKey)
-//                    if font != nil {
-//                        (newAnnotation as! KMSelfSignAnnotationFreeText).font = font
-//                    }
-//                } else {
-//                    newAnnotation = CPDFFreeTextAnnotation(PDFListViewNoteWith: (pdfView?.document!)!)
-//                    newAnnotation?.color = userDefaults.color(forKey: CFreeTextNoteColorKey)
-//                    (newAnnotation as! CPDFFreeTextAnnotation).fontColor = userDefaults.color(forKey: CFreeTextNoteFontColorKey)
-//                    (newAnnotation as! CPDFFreeTextAnnotation).alignment = NSTextAlignment(rawValue: userDefaults.integer(forKey: CFreeTextNoteAlignmentKey))!
-//                    let font = userDefaults.font(forNameKey: CFreeTextNoteFontNameKey, sizeKey: CFreeTextNoteFontSizeKey)
-//                    if font != nil {
-//                        (newAnnotation as! CPDFFreeTextAnnotation).font = font
-//                    }
-//                    newAnnotation?.borderWidth = CGFloat(userDefaults.float(forKey: CFreeTextNoteLineWidthKey))
-//                    newAnnotation?.setDashPattern((userDefaults.array(forKey: CFreeTextNoteDashPatternKey) as? [NSNumber])!)
-//                    newAnnotation?.setBorderStyle(CPDFBorderStyle(rawValue: Int(userDefaults.float(forKey: CFreeTextNoteLineStyleKey)))!)
-//                }
-//            } else if newValue == .circle {
-//                newAnnotation = CPDFCircleAnnotation(PDFListViewNoteWith: (pdfView?.document!)!)
-//                newAnnotation?.color = userDefaults.color(forKey: CCircleNoteColorKey)
-//                (newAnnotation as! CPDFCircleAnnotation).interiorColor = userDefaults.color(forKey: CCircleNoteInteriorColorKey)
-//                newAnnotation?.borderWidth = CGFloat(userDefaults.float(forKey: CCircleNoteLineWidthKey))
-//                newAnnotation?.setDashPattern((userDefaults.array(forKey: CCircleNoteDashPatternKey) as? [NSNumber])!)
-//                newAnnotation?.setBorderStyle(CPDFBorderStyle(rawValue: Int(userDefaults.float(forKey: CCircleNoteLineStyleKey)))!)
-//            } else if newValue == .square {
-//                newAnnotation = CPDFSquareAnnotation(PDFListViewNoteWith: (pdfView?.document!)!)
-//                newAnnotation?.color = userDefaults.color(forKey: CSquareNoteColorKey)
-//                (newAnnotation as! CPDFSquareAnnotation).interiorColor = userDefaults.color(forKey: CSquareNoteInteriorColorKey)
-//                newAnnotation?.borderWidth = CGFloat(userDefaults.float(forKey: CSquareNoteLineWidthKey))
-//                newAnnotation?.setDashPattern((userDefaults.array(forKey: CSquareNoteDashPatternKey) as? [NSNumber])!)
-//                newAnnotation?.setBorderStyle(CPDFBorderStyle(rawValue: Int(userDefaults.float(forKey: CSquareNoteLineStyleKey)))!)
-//            } else if newValue == .highlight {
-//                newAnnotation = CPDFMarkupAnnotation.init(PDFListViewNote: (pdfView?.document!)!, markupType: .highlight)
-//                newAnnotation?.color = userDefaults.color(forKey: CHighlightNoteColorKey)
-//            } else if newValue == .underline {
-//                newAnnotation = CPDFMarkupAnnotation(document: (pdfView?.document!)!, markupType: .underline)
-//                newAnnotation?.color = userDefaults.color(forKey: CUnderlineNoteColorKey)
-//            } else if newValue == .strikeOut {
-//                newAnnotation = CPDFMarkupAnnotation(document: (pdfView?.document!)!, markupType: .strikeOut)
-//                newAnnotation?.color = userDefaults.color(forKey: CStrikeOutNoteColorKey)
-//            } else if newValue == .line || newValue == .arrow {
-//                newAnnotation = CPDFLineAnnotation(PDFListViewNoteWith: (pdfView?.document!)!, annotationType: .line)
-//                (newAnnotation as! CPDFLineAnnotation).startPoint = NSMakePoint(0, 0)
-//                (newAnnotation as! CPDFLineAnnotation).endPoint = NSMakePoint(bounds.size.width, bounds.size.height)
-//                newAnnotation?.color = userDefaults.color(forKey: CLineNoteColorKey)
-//                (newAnnotation as! CPDFLineAnnotation).interiorColor = userDefaults.color(forKey: CLineNoteInteriorColorKey)
-//                newAnnotation?.borderWidth = CGFloat(userDefaults.float(forKey: CLineNoteLineWidthKey))
-//                newAnnotation?.setDashPattern((userDefaults.array(forKey: CLineNoteDashPatternKey) as? [NSNumber])!)
-//                newAnnotation?.setBorderStyle(CPDFBorderStyle(rawValue: Int(userDefaults.float(forKey: CLineNoteLineStyleKey)))!)
-//                if annotationMode == .line {
-//                    (newAnnotation as! CPDFLineAnnotation).startLineStyle = .none
-//                    (newAnnotation as! CPDFLineAnnotation).endLineStyle = .none
-//                } else {
-//                    (newAnnotation as! CPDFLineAnnotation).startLineStyle = CPDFLineStyle(rawValue: Int(userDefaults.integer(forKey: CLineNoteStartLineStyleKey))) ?? .none
-//                    (newAnnotation as! CPDFLineAnnotation).endLineStyle = CPDFLineStyle(rawValue: Int(userDefaults.integer(forKey: CLineNoteEndLineStyleKey))) ?? .none
-//                }
-//            } else if newValue == .ink {
-//                newAnnotation = CPDFInkAnnotation(PDFListViewNoteWith: (pdfView?.document!)!)
-//                newAnnotation?.color = userDefaults.color(forKey: CInkNoteColorKey)
-//                newAnnotation?.borderWidth = CGFloat(userDefaults.float(forKey: CInkNoteLineWidthKey))
-//                newAnnotation?.setDashPattern((userDefaults.array(forKey: CInkNoteDashPatternKey) as? [NSNumber])!)
-//                newAnnotation?.setBorderStyle(CPDFBorderStyle(rawValue: Int(userDefaults.float(forKey: CInkNoteLineStyleKey)))!)
-//            } else if newValue == .anchored {
-////                NSRect anBounds = {NSZeroPoint, SKNPDFAnnotationNoteSize};
-////                annotation = [[[SKNPDFAnnotationNote alloc] initSkimNoteWithBounds:anBounds] autorelease];
-////                annotation.color = [sud colorForKey:SKNPDFAnnotationColorKey];
-////                annotation.iconType = [sud integerForKey:SKAnchoredNoteIconTypeKey];
-//                newAnnotation = CPDFTextAnnotation.init(PDFListViewNoteWith: (pdfView?.document!)!)
-//                newAnnotation?.color = userDefaults.color(forKey: CPDFAnnotationColorKey)
-//                (newAnnotation as! CPDFTextAnnotation).setIconType(CPDFTextAnnotationIconType(rawValue: userDefaults.integer(forKey: CAnchoredNoteIconTypeKey)) ?? .comment)
-//            } else {
-//                newAnnotation = CPDFAnnotation(PDFListViewNoteWith: (pdfView?.document!)!)
-//            }
-//                
-//            if let validAnnotation = newAnnotation {
-//                annotations = [validAnnotation]
-//            }
-//            
-//            annotation = newAnnotation!
-//        }
         get {
             return (annotationModel?.annotationType as? CAnnotationType)!
         }
@@ -2434,35 +2178,6 @@ let KMColorPickerViewHeight: CGFloat = 64
             }
         }
     }
-    
-    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {
-        guard let observedObject = object as AnyObject?, observedObject !== annotation else {
-            return
-        }
-
-        let newValue = change?[.newKey] ?? NSNull()
-        let oldValue = change?[.oldKey] ?? NSNull()
-
-        if (newValue as AnyObject).isEqual(oldValue) {
-            return
-        }
-
-        if keyPath == "string" {
-            if let newValue = newValue as? NSNull {
-                return
-            }
-            // 处理编辑时光标后移
-            if !isTextEdit {
-                noteTextView.string = newValue as! String
-            }
-            isTextEdit = false
-        } else {
-            reloadData()
-            if isannotationMode {
-                updateannotationMode()
-            }
-        }
-    }
 
     @objc func themeChanged(_ notification: Notification) {
         DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [self] in

+ 98 - 96
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/CreateStamp/View/KMAnnotationStamp.swift

@@ -76,134 +76,136 @@ let StampStringEdgeSizeScale = 0.1
     var borderScale: Float = 0
     var borderBounds: NSRect?
     var type1: KMAnnotationStampType?
+    private var _customStampType: KMAnnotationStampType = .Notapproved
     var customStampType: KMAnnotationStampType? {
-        willSet{
-            
+        get {
+            return _customStampType
         }
-        didSet {
-            if customStampType != oldValue {
-                self.isStandardStamp = true
-                self.dateString = ""
-                switch self.customStampType {
-                case .Notapproved:
+        set {
+            _customStampType = newValue!
+            
+            self.isStandardStamp = true
+            self.dateString = ""
+            switch _customStampType {
+            case .Notapproved:
 //                    self.setName("SBNotApproved")
-                    self.contentStr = "Not Approved"
-                    self.stampColor = .RedColor
-                case .Approved:
+                self.contentStr = "Not Approved"
+                self.stampColor = .RedColor
+            case .Approved:
 //                    self.setName("SBApproved")
-                    self.contentStr = "Approved"
-                    self.stampColor = .GreenColor
-                case .Completed:
+                self.contentStr = "Approved"
+                self.stampColor = .GreenColor
+            case .Completed:
 //                    self.setName("SBCompleted")
-                    self.contentStr = "Completed"
-                    self.stampColor = .GreenColor
-                case .Final:
+                self.contentStr = "Completed"
+                self.stampColor = .GreenColor
+            case .Final:
 //                    self.setName("SBFinal")
-                    self.contentStr = "Final"
-                    self.stampColor = .GreenColor
-                case .Draft:
+                self.contentStr = "Final"
+                self.stampColor = .GreenColor
+            case .Draft:
 //                    self.setName("SBDraft")
-                    self.contentStr = "Draft"
-                    self.stampColor = .BlueColor
-                case .Confidential:
+                self.contentStr = "Draft"
+                self.stampColor = .BlueColor
+            case .Confidential:
 //                    self.setName("SBConfidential")
-                    self.contentStr = "Confidential"
-                    self.stampColor = .RedColor
-                case .Notforpublicrelease:
+                self.contentStr = "Confidential"
+                self.stampColor = .RedColor
+            case .Notforpublicrelease:
 //                    self.setName("SBNotForPublicRelease")
-                    self.contentStr = "Not For Public Release"
-                    self.stampColor = .BlueColor
-                case .Forpublicrelease:
+                self.contentStr = "Not For Public Release"
+                self.stampColor = .BlueColor
+            case .Forpublicrelease:
 //                    self.setName("SBForPublicRelease")
-                    self.contentStr = "For Public Release"
-                    self.stampColor = .BlueColor
-                case .Forcomment:
+                self.contentStr = "For Public Release"
+                self.stampColor = .BlueColor
+            case .Forcomment:
 //                    self.setName("SBForComment")
-                    self.contentStr = "For Comment"
-                    self.stampColor = .BlueColor
-                case .Void:
+                self.contentStr = "For Comment"
+                self.stampColor = .BlueColor
+            case .Void:
 //                    self.setName("SBVoid")
-                    self.contentStr = "Void"
-                    self.stampColor = .RedColor
-                case .Preliminaryresults:
+                self.contentStr = "Void"
+                self.stampColor = .RedColor
+            case .Preliminaryresults:
 //                    self.setName("SBPreliminaryResults")
-                    self.contentStr = "Preliminary Results"
-                    self.stampColor = .BlueColor
-                case .Informationonly:
+                self.contentStr = "Preliminary Results"
+                self.stampColor = .BlueColor
+            case .Informationonly:
 //                    self.setName("SBInformationOnly")
-                    self.contentStr = "Information Only"
-                    self.stampColor = .BlueColor
-                case .Revised:
+                self.contentStr = "Information Only"
+                self.stampColor = .BlueColor
+            case .Revised:
 //                    self.setName("SHRevised")
-                    self.contentStr = "Revised"
-                    self.stampColor = .RedColor
-                case .Accepted:
+                self.contentStr = "Revised"
+                self.stampColor = .RedColor
+            case .Accepted:
 //                    self.setName("SHAccepted")
-                    self.contentStr = ""
-                    self.stampColor = .DarkGreenColor
-                case .Rejected:
+                self.contentStr = ""
+                self.stampColor = .DarkGreenColor
+            case .Rejected:
 //                    self.setName("SBRejected")
-                    self.contentStr = ""
-                    self.stampColor = .DarkRedColor
-                case .Witness:
+                self.contentStr = ""
+                self.stampColor = .DarkRedColor
+            case .Witness:
 //                    self.setName("SHWitness")
-                    self.contentStr = "Witness"
-                    self.stampColor = .LightRedColor
-                case .Initialhere:
+                self.contentStr = "Witness"
+                self.stampColor = .LightRedColor
+            case .Initialhere:
 //                    self.setName("SHInitialHere")
-                    self.contentStr = "Initial Here"
-                    self.stampColor = .PurpleColor
-                case .Signhere:
+                self.contentStr = "Initial Here"
+                self.stampColor = .PurpleColor
+            case .Signhere:
 //                    self.setName("SHSignHere")
-                    self.contentStr = "Sign Here"
-                    self.stampColor = .LightRedColor
-                case .Cross:
+                self.contentStr = "Sign Here"
+                self.stampColor = .LightRedColor
+            case .Cross:
 //                    self.setName("SHCross")
-                    self.contentStr = ""
-                    self.stampColor = .BlackColor
-                case .Chick:
+                self.contentStr = ""
+                self.stampColor = .BlackColor
+            case .Chick:
 //                    self.setName("SHChick")
-                    self.contentStr = ""
-                    self.stampColor = .BlackColor
-                case .Circle:
+                self.contentStr = ""
+                self.stampColor = .BlackColor
+            case .Circle:
 //                    self.setName("SHCircle")
-                    self.contentStr = ""
-                    self.stampColor = .BlackColor
-                case .Emergency:
+                self.contentStr = ""
+                self.stampColor = .BlackColor
+            case .Emergency:
 //                    self.setName("SBEmergency")
-                    self.contentStr = "EMERGENCY"
-                    self.stampColor = .RedColor
-                case .Expired:
+                self.contentStr = "EMERGENCY"
+                self.stampColor = .RedColor
+            case .Expired:
 //                    self.setName("SBExpired")
-                    self.contentStr = "EXPIRED"
-                    self.stampColor = .RedColor
-                case .Received:
+                self.contentStr = "EXPIRED"
+                self.stampColor = .RedColor
+            case .Received:
 //                    self.setName("SBReceived")
-                    self.contentStr = "RECEIVED"
-                    self.stampColor = .GreenColor
-                case .Reviewed:
+                self.contentStr = "RECEIVED"
+                self.stampColor = .GreenColor
+            case .Reviewed:
 //                    self.setName("SBReviewed")
-                    self.contentStr = "REVIEWED"
-                    self.stampColor = .GreenColor
-                case .Verified:
+                self.contentStr = "REVIEWED"
+                self.stampColor = .GreenColor
+            case .Verified:
 //                    self.setName("SBVerified")
-                    self.contentStr = "VERIFIED"
-                    self.stampColor = .GreenColor
-                case .Accepteder:
+                self.contentStr = "VERIFIED"
+                self.stampColor = .GreenColor
+            case .Accepteder:
 //                    self.setName("SBAccepteder")
-                    self.contentStr = "ACCEPTED"
-                    self.stampColor = .GreenColor
-                case .Rejecteder:
+                self.contentStr = "ACCEPTED"
+                self.stampColor = .GreenColor
+            case .Rejecteder:
 //                    self.setName("SBRejecteder")
-                    self.contentStr = "REJECTED"
-                    self.stampColor = .RedColor
-                default:
+                self.contentStr = "REJECTED"
+                self.stampColor = .RedColor
+            default:
 //                    self.setName("SBApproved")
-                    self.contentStr = "Approved"
-                    self.stampColor = .GreenColor
-                }
+                self.contentStr = "Approved"
+                self.stampColor = .GreenColor
             }
-            if self.customStampType == .Accepted || self.customStampType == .Rejected || self.customStampType == .Cross || self.customStampType == .Chick || self.customStampType == .Circle{
+
+            if _customStampType == .Accepted || _customStampType == .Rejected || _customStampType == .Cross || _customStampType == .Chick || _customStampType == .Circle{
                 self.borderDefaultWidth = 60
                 self.borderScale = 1.0
             }else {

+ 128 - 178
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.swift

@@ -28,13 +28,14 @@ struct KMPDFAnnotationSignatureType: OptionSet {
 let KMPDFDynamicStampDateStyleKey1 = "km_pdfview_dynamic_stamp_date_style"
 let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
 
-@available(macOS 13.0, *)
-@objcMembers class KMAnnotationStampViewController: NSViewController, NSTextViewDelegate, NSComboBoxDelegate {
+@objcMembers class KMAnnotationStampViewController: NSViewController, NSTextViewDelegate, NSComboBoxDelegate, NSTableViewDelegate, NSTableViewDataSource {
     
-    var _annotations: [CPDFAnnotation]?
     weak var pdfView: CPDFListView?
     var isClickSignatureList: Bool = false
-    
+    var isContinuousAddStamp: Bool = false
+    var isImageStamp: Bool = false
+    var annotationModel: CPDFAnnotationModel?
+
     @IBOutlet weak var mainViewBox: NSBox!
     
     @IBOutlet weak var createStampView: NSView!
@@ -100,16 +101,14 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
     @IBOutlet weak var leftImageView: NSImageView!
     @IBOutlet weak var rightImageView: NSImageView!
     
-    var _annotation: KMAnnotationStamp!
-    
     var _stampType: KMCreateStampType!
     
     var annotationStampType: KMAnnotationStampCreateType!
     
-    var selectedStamp: KMAnnotationStamp!
-    var standardStamps: [KMAnnotationStamp]!
-    var customStamps: [KMAnnotationStamp]!
-    var dynamicStamps: [KMAnnotationStamp]!
+    var selectedStamp: CStampObject!
+    var standardStamps: [CStampObject]!
+    var customStamps: [CStampObject]!
+    var dynamicStamps: [CStampObject]!
     var dynamicStampNeedsAuthor: Bool!
     var dateFormatterString: String!
     var dateStyleArray: [String]!
@@ -125,12 +124,12 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
         NotificationCenter.default.removeObserver(self)
         DistributedNotificationCenter.default.removeObserver(self)
 
-        // Remove observers for specific key paths
-        let keys = ["string", "rotation", "imageAlpha"]
-        for key in keys {
-            self.annotation.removeObserver(self, forKeyPath: key)
+        if ((annotationModel?.annotation) != nil) && annotationModel?.annotations.count == 1 {
+            let keys = ["string", "rotation", "imageAlpha"]
+            for key in keys {
+                self.annotation.removeObserver(self, forKeyPath: key)
+            }
         }
-
         dateComboBox.delegate = nil
         contentTextView.delegate = nil
 
@@ -147,50 +146,9 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
         super.viewDidLoad()
         // Do view setup here.
         
-        if pdfView!.isCreatAnnotation {
-            mainViewBox.contentView = createStampView
-            noCustomStampLabel.textColor = KMAppearance.Layout.h1Color()
-            leftImageView.wantsLayer = true
-            rightImageView.wantsLayer = true
-            leftImageView.layer?.backgroundColor = KMAppearance.Layout.b15_1Color().cgColor
-            rightImageView.layer?.backgroundColor = KMAppearance.Layout.b15_1Color().cgColor
-            
-            if let image = annotation.image {
-                annotationStampType = .signature
-                
-                emptyImageView.image = NSImage(named: KMImageNameEmptySign)
-                emptyLabel.stringValue = NSLocalizedString("Click \"New Signature\" button below to create a signature.", comment: "")
-                emptyLabel.textColor = KMAppearance.Layout.h2Color()
-                noCustomStampLabel.stringValue = NSLocalizedString("No Signatures", comment: "")
-                initCreateSignatureView()
-            } else {
-                dateComboBox.type = .none
-                dateComboBox.comboxRect = dateComboBox.bounds
-                
-                authorTextField.backgroundColor = KMAppearance.Layout.l1Color()
-                authorTextField.wantsLayer = true
-                dateComboBox.wantsLayer = true
-                authorTextField.layer?.borderWidth = 1.0
-                authorTextField.layer?.cornerRadius = 1.0
-                
-                dateBox.borderColor = KMAppearance.Interactive.s0Color()
-                dateBox.fillColor = KMAppearance.Layout.l1Color()
-                
-                annotationStampType = .type_default
-                
-                emptyImageView.image = NSImage(named: KMImageNameEmptyStamp)
-                initCreateStampView()
-                
-                switch pdfView!.toolBarCreateAnnotationMenuItem {
-                case Int(KMCreateStampType.standard.rawValue):
-                    stampType = .standard
-                case Int(KMCreateStampType.custom.rawValue):
-                    stampType = .custom
-                case Int(KMCreateStampType.dynamic.rawValue):
-                    stampType = .dynamic
-                default: break
-                }
-            }
+        if annotationModel?.annotations != nil {
+            mainViewBox.contentView = clickStampView
+            initClickStampView()
         } else {
             if isClickSignatureList {
                 mainViewBox.contentView = createStampView
@@ -204,8 +162,49 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
                 noCustomStampLabel.stringValue = NSLocalizedString("No Signatures", comment: "")
                 initCreateSignatureView()
             } else {
-                mainViewBox.contentView = clickStampView
-                initClickStampView()
+                mainViewBox.contentView = createStampView
+                noCustomStampLabel.textColor = KMAppearance.Layout.h1Color()
+                leftImageView.wantsLayer = true
+                rightImageView.wantsLayer = true
+                leftImageView.layer?.backgroundColor = KMAppearance.Layout.b15_1Color().cgColor
+                rightImageView.layer?.backgroundColor = KMAppearance.Layout.b15_1Color().cgColor
+                
+                if isImageStamp {
+                    annotationStampType = .signature
+                    
+                    emptyImageView.image = NSImage(named: KMImageNameEmptySign)
+                    emptyLabel.stringValue = NSLocalizedString("Click \"New Signature\" button below to create a signature.", comment: "")
+                    emptyLabel.textColor = KMAppearance.Layout.h2Color()
+                    noCustomStampLabel.stringValue = NSLocalizedString("No Signatures", comment: "")
+                    initCreateSignatureView()
+                } else {
+                    dateComboBox.type = .none
+                    dateComboBox.comboxRect = dateComboBox.bounds
+                    
+                    authorTextField.backgroundColor = KMAppearance.Layout.l1Color()
+                    authorTextField.wantsLayer = true
+                    dateComboBox.wantsLayer = true
+                    authorTextField.layer?.borderWidth = 1.0
+                    authorTextField.layer?.cornerRadius = 1.0
+                    
+                    dateBox.borderColor = KMAppearance.Interactive.s0Color()
+                    dateBox.fillColor = KMAppearance.Layout.l1Color()
+                    
+                    annotationStampType = .type_default
+                    
+                    emptyImageView.image = NSImage(named: KMImageNameEmptyStamp)
+                    initCreateStampView()
+                    
+                    switch pdfView!.toolBarCreateAnnotationMenuItem {
+                    case Int(KMCreateStampType.standard.rawValue):
+                        stampType = .standard
+                    case Int(KMCreateStampType.custom.rawValue):
+                        stampType = .custom
+                    case Int(KMCreateStampType.dynamic.rawValue):
+                        stampType = .dynamic
+                    default: break
+                    }
+                }
             }
         }
         
@@ -223,32 +222,15 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
     
     // MARK: Set & Get
     
-    var annotations: [CPDFAnnotation] {
-        set {
-            _annotations = newValue
-            
-            _annotation = (_annotations?.first as? KMAnnotationStamp) ?? KMAnnotationStamp()
-        }
+    var annotations: [KMAnnotationStamp] {
         get {
-            return _annotations!
+            return annotationModel?.annotations as! [KMAnnotationStamp]
         }
     }
     
     var annotation: KMAnnotationStamp {
-        set {
-            if _annotation.isEqual(newValue) {
-                let keys = ["string", "rotation", "imageAlpha"]
-                for key in keys {
-                    _annotation.removeObserver(self, forKeyPath: key)
-                }
-                _annotation = newValue
-                for key in keys {
-                    _annotation.addObserver(self, forKeyPath: key, options: [.new, .old], context: nil)
-                }
-            }
-        }
         get {
-            return _annotation
+            return annotationModel?.annotation as! KMAnnotationStamp
         }
     }
     
@@ -405,7 +387,12 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
         annotationLabel.stringValue = NSLocalizedString("Note", comment: "")
         annotationLabel.textColor = KMAppearance.Layout.h0Color()
         
-        let opacity = annotation.imageAlpha
+        var opacity = 1.0
+        if annotationModel?.annotations != nil {
+            if annotation is KMAnnotationStamp {
+                opacity = Double((annotation as! KMAnnotationStamp).imageAlpha)
+            }
+        }
         opacitySlider.floatValue = Float(opacity)
         opacityComboBox.stringValue = String(format: "%d%%", Int(opacity * 100))
         
@@ -454,16 +441,20 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
         }
         
         contentTextView.wantsLayer = true
-        contentTextView.string = annotation.contentStr
+        if annotationModel?.annotations != nil {
+            contentTextView.string = annotation.contentStr
+        }
         contentTextView.textColor = NSColor.labelColor
         contentTextView.layer?.borderWidth = 0.5
         contentTextView.layer?.cornerRadius = 1.0
         contentTextView.delegate = self
         contentTextView.isEditable = false
         
-        sampleImageView.image = annotationImage()
+        sampleImageView.image = annotationModel?.annotationImage
         
-        opacityBox.isHidden = annotation.image == nil
+        if annotationModel?.annotations != nil {
+            opacityBox.isHidden = annotation.image == nil
+        }
         opacityBoxTopLayoutConstraint.constant = opacityBox.isHidden ? 16 : 96
         
         updateViewColor()
@@ -492,6 +483,9 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
     }
     
     func createStandardTypeStamp() {
+        createStampTableView.delegate = self
+        createStampTableView.dataSource = self
+
         leftImageView.isHidden = true
         rightImageView.isHidden = false
         
@@ -507,7 +501,6 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
         footBox.isHidden = true
         
         loadStandardStamps()
-        
         createStampTableView.reloadData()
     }
     
@@ -604,13 +597,13 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
         if standardStamps != nil {
             standardStamps.removeAll()
         } else {
-            self.standardStamps = []
+            standardStamps = []
         }
         
-        for i in 0..<28 {
-            let stamp = KMAnnotationStamp(withBounds: NSMakeRect(0, 0, 480, 90))
-            stamp.customStampType = KMAnnotationStampType(rawValue: i)
-            self.standardStamps?.append(stamp)
+        KMStampManager.defaultManager.stamps.enumerated().forEach { (index, obj) in
+            if (obj.stampCategoryType == .standard) {
+                standardStamps?.append(obj)
+            }
         }
     }
 
@@ -618,22 +611,15 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
         if self.customStamps != nil  {
             customStamps.removeAll()
         } else {
-            self.customStamps = []
+            customStamps = []
         }
         
-        for s in KMStampManagerNew.shareManager.stamps {
-            let stamp = KMAnnotationStamp(withBounds: NSRect(x: 0, y: 0, width: 480, height: 90))
-            
-            if s.isImageStamp {
-                stamp.image = NSImage(contentsOfFile: s.imagePath)
-            } else {
-                stamp.setCustomStampString(s.string, dateString: s.subString)
-                stamp.stampColor = KMAnnotationStampColorType(rawValue: s.color)
+        KMStampManager.defaultManager.stamps.enumerated().forEach { (index, obj) in
+            if (obj.stampCategoryType == .text || obj.stampCategoryType == .image) {
+                self.customStamps?.append(obj)
             }
-            
-            self.customStamps?.append(stamp)
         }
-        
+
         if let customStamps = self.customStamps, customStamps.count > 0 {
             reloadCustomEmptyState(false)
         } else {
@@ -648,35 +634,11 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
             dynamicStamps.removeAll()
         }
 
-        let tRevisedStamp = KMAnnotationStamp(withBounds: NSMakeRect(0, 0, 480, 90))
-        tRevisedStamp.dateString = setDynamicStampDateString(withDateStyle: dateFormatterString)
-        tRevisedStamp.setCustomStampString("REVISED", dateString: tRevisedStamp.dateString)
-        tRevisedStamp.stampColor = .RedColor
-        dynamicStamps.append(tRevisedStamp)
-
-        let tReviewedStamp = KMAnnotationStamp(withBounds: NSMakeRect(0, 0, 480, 90))
-        tReviewedStamp.dateString = setDynamicStampDateString(withDateStyle: dateFormatterString)
-        tReviewedStamp.setCustomStampString("REVIEWED", dateString: tReviewedStamp.dateString)
-        tRevisedStamp.stampColor = .GreenColor
-        dynamicStamps.append(tReviewedStamp)
-
-        let tReceivedStamp = KMAnnotationStamp(withBounds: NSMakeRect(0, 0, 480, 90))
-        tReceivedStamp.dateString = setDynamicStampDateString(withDateStyle: dateFormatterString)
-        tReceivedStamp.setCustomStampString("RECEIVED", dateString: tReceivedStamp.dateString)
-        tReceivedStamp.stampColor = .GreenColor
-        dynamicStamps.append(tReceivedStamp)
-
-        let tApprovedStamp = KMAnnotationStamp(withBounds: NSMakeRect(0, 0, 480, 90))
-        tApprovedStamp.dateString = setDynamicStampDateString(withDateStyle: dateFormatterString)
-        tApprovedStamp.setCustomStampString("APPROVED", dateString: tApprovedStamp.dateString)
-        tApprovedStamp.stampColor = .GreenColor
-        dynamicStamps.append(tApprovedStamp)
-
-        let tConfidentialStamp = KMAnnotationStamp(withBounds: NSMakeRect(0, 0, 480, 90))
-        tConfidentialStamp.needExchangeFontSize = true
-        tConfidentialStamp.setCustomStampString(dynamicStampNeedsAuthor ? authorTextField.stringValue : "", dateString: "CONFIDENTIAL")
-        tConfidentialStamp.stampColor = .RedColor
-        dynamicStamps.append(tConfidentialStamp)
+        KMStampManager.defaultManager.stamps.enumerated().forEach { (index, obj) in
+            if (obj.stampCategoryType == CPDFStampType.init(rawValue: CPDFStampTypeDynamic)!) {
+                dynamicStamps?.append(obj)
+            }
+        }
     }
     
     func setDynamicStampDateString(withDateStyle dateStyleString: String) -> String {
@@ -800,7 +762,9 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
         imageStampButtonLayer.isHidden = true
         textStampButtonLayer.isHidden = true
         
-        addButtonLayer.isHidden = true
+        if addButtonLayer != nil {
+            addButtonLayer.isHidden = true
+        }
     }
     
     func isDamageImage(_ image: NSImage, imagePath path: String) -> Bool {
@@ -906,14 +870,14 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
     @IBAction func opacitySliderAction(_ sender: Any) {
         for tAnnotation in self.annotations {
             let opacity = self.opacitySlider.floatValue
-            self.pdfView?.setStampAnnotation((tAnnotation as! KMAnnotationStamp), forImageAlpha: CGFloat(opacity))
+            self.pdfView?.setStampAnnotation((tAnnotation), forImageAlpha: CGFloat(opacity))
         }
     }
 
     @IBAction func opacityComboBoxAction(_ sender: Any) {
         for tAnnotation in self.annotations {
             let opacity = CGFloat(self.opacityComboBox.intValue) / 100
-            self.pdfView?.setStampAnnotation((tAnnotation as! KMAnnotationStamp), forImageAlpha: CGFloat(opacity))
+            self.pdfView?.setStampAnnotation((tAnnotation ), forImageAlpha: CGFloat(opacity))
         }
     }
     
@@ -978,28 +942,17 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
 //            }
 //        }
         
-        if let annotationImage = self.annotation.image {
-            let selectSignature: KMSignature = self.signatures[index] as! KMSignature
-            if selectSignature != nil {
-                self.pdfView?.isCreatAnnotation = false
-                self.pdfView?.addAnnotation(with: selectSignature)
-            }
-        } else {
-            switch stampType {
-            case .standard:
-                self.selectedStamp = self.standardStamps[index]
-            case .dynamic:
-                self.loadDynamicStamps()
-                self.selectedStamp = self.dynamicStamps[index]
-            case .custom:
-                self.selectedStamp = self.customStamps[index]
-            }
-            
-            if let selectedStamp = self.selectedStamp {
-                pdfView?.isCreatAnnotation = false
-                pdfView?.addAnnotation(with: selectedStamp)
-            }
-        }
+        var stampLists: [CStampObject] = []
+        switch stampType {
+        case .standard:
+            stampLists = standardStamps
+        case .dynamic:
+            stampLists = dynamicStamps
+        case .custom:
+            stampLists = customStamps
+        }
+        let stamp: CStampObject = stampLists[index]
+        pdfView?.setAddStamp(stamp, keepToolModel: false)
     }
     
     @IBAction func addButtonAction(_ sender: NSButton) {
@@ -1052,7 +1005,11 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
                     if filePath.pathExtension.lowercased() == "pdf" {
                         if let pdf = CPDFDocument(url: url), pdf.isEncrypted {
                             let passwordWC = PasswordWindowController(windowNibName: "PasswordWindowController")
-                            passwordWC.fileURL = URL(filePath: filePath)
+                            if #available(macOS 13.0, *) {
+                                passwordWC.fileURL = URL(filePath: filePath)
+                            } else {
+                                
+                            }
                             passwordWC.beginSheetModal(for: myself.view.window!) { [weak self] password in
                                 self!.addImageStamp(withSecurityPDFFilePath: filePath, password: password, removeBGColor: (accessoryCtr.selectedButton.state == .on))
                             }
@@ -1229,7 +1186,7 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
         }
 
         if annotationStampType == .type_default {
-            var stamp: KMAnnotationStamp?
+            var stamp: CStampObject?
             switch stampType {
             case .standard:
                 stamp = standardStamps[row]
@@ -1258,7 +1215,7 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
                     }
                 }
             }
-            cellView.sampleImageButton.image = stamp?.stampImage()
+            cellView.sampleImageButton.image = stamp?.stampPreImage()
             cellView.closeButton.tag = row
             cellView.closeButton.target = self
             cellView.closeButton.action = #selector(tableCellCloseButton_Click(_:))
@@ -1300,24 +1257,17 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
     }
     
     @objc func tableViewSelectionDidChange(_ notification: Notification) {
-        if let image = annotation.image {
-            let selectSignature = self.signatures[createStampTableView.selectedRow] as! KMSignature
-            pdfView!.isCreatAnnotation = false
-            pdfView!.addAnnotation(with: selectSignature)
-        } else {
-            if stampType == .standard {
-                selectedStamp = standardStamps[createStampTableView.selectedRow]
-            } else if stampType == .dynamic {
-                loadDynamicStamps()
-                selectedStamp = self.dynamicStamps[createStampTableView.selectedRow]
-            } else if stampType == .custom {
-                selectedStamp = self.customStamps[createStampTableView.selectedRow]
-            }
-            if let selectedStamp = self.selectedStamp {
-                pdfView!.isCreatAnnotation = false
-                pdfView!.addAnnotation(with: selectedStamp)
-            }
-        }
+        var stampLists: [CStampObject] = []
+        switch stampType {
+        case .standard:
+            stampLists = standardStamps
+        case .dynamic:
+            stampLists = dynamicStamps
+        case .custom:
+            stampLists = customStamps
+        }
+        let stamp: CStampObject = stampLists[createStampTableView.selectedRow]
+        pdfView?.setAddStamp(stamp, keepToolModel: false)
     }
     
     func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? {

+ 4 - 4
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.xib

@@ -232,7 +232,7 @@
                     <rect key="frame" x="0.0" y="60" width="234" height="507"/>
                     <clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="QFb-tg-EJh">
                         <rect key="frame" x="0.0" y="0.0" width="234" height="507"/>
-                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <autoresizingMask key="autoresizingMask"/>
                         <subviews>
                             <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" tableStyle="fullWidth" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="64" viewBased="YES" id="bps-jM-pPg">
                                 <rect key="frame" x="0.0" y="0.0" width="234" height="507"/>
@@ -399,7 +399,7 @@
                         <subviews>
                             <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wtD-Vt-js7" customClass="KMComboBox" customModule="PDF_Master" customModuleProvider="target">
                                 <rect key="frame" x="-1" y="-2" width="164" height="23"/>
-                                <comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" buttonBordered="NO" completes="NO" numberOfVisibleItems="5" id="oR8-Eg-1Mn" customClass="KMStampComboBoxCell">
+                                <comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" buttonBordered="NO" completes="NO" numberOfVisibleItems="5" id="oR8-Eg-1Mn" customClass="KMStampComboBoxCell" customModule="PDF_Master" customModuleProvider="target">
                                     <font key="font" metaFont="system"/>
                                     <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
                                     <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -503,7 +503,7 @@
             <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES"/>
             <clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="NDK-ok-tvh">
                 <rect key="frame" x="1" y="1" width="260" height="597"/>
-                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <view id="Aj7-0M-710">
                         <rect key="frame" x="0.0" y="0.0" width="245" height="582"/>
@@ -631,7 +631,7 @@
                                             <rect key="frame" x="0.0" y="176" width="213" height="110"/>
                                             <clipView key="contentView" drawsBackground="NO" id="wcx-5m-Dzd">
                                                 <rect key="frame" x="0.0" y="0.0" width="213" height="110"/>
-                                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                                <autoresizingMask key="autoresizingMask"/>
                                                 <subviews>
                                                     <textView importsGraphics="NO" verticallyResizable="YES" usesFontPanel="YES" findStyle="panel" continuousSpellChecking="YES" allowsUndo="YES" usesRuler="YES" allowsNonContiguousLayout="YES" quoteSubstitution="YES" dashSubstitution="YES" spellingCorrection="YES" smartInsertDelete="YES" id="lq6-MU-1hZ">
                                                         <rect key="frame" x="0.0" y="0.0" width="213" height="110"/>

+ 4 - 4
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMDynamicStampViewController.xib

@@ -24,7 +24,7 @@
             <rect key="frame" x="0.0" y="0.0" width="391" height="141"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
-                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hDL-yw-0LU">
+                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hDL-yw-0LU">
                     <rect key="frame" x="13" y="110" width="37" height="16"/>
                     <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="Oe9-9H-SuI">
                         <font key="font" usesAppearanceFont="YES"/>
@@ -42,7 +42,7 @@
                         <action selector="selectAuthorButton_Click:" target="-2" id="Bvq-Dm-qUu"/>
                     </connections>
                 </button>
-                <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="h04-zJ-ESh">
+                <textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="h04-zJ-ESh">
                     <rect key="frame" x="76" y="66" width="96" height="21"/>
                     <constraints>
                         <constraint firstAttribute="width" constant="96" id="hQm-5b-VGC"/>
@@ -53,7 +53,7 @@
                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                     </textFieldCell>
                 </textField>
-                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Gp9-c5-GxZ">
+                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Gp9-c5-GxZ">
                     <rect key="frame" x="214" y="68" width="34" height="16"/>
                     <textFieldCell key="cell" lineBreakMode="clipping" title="Time" id="kru-3C-8Dj">
                         <font key="font" metaFont="system"/>
@@ -90,7 +90,7 @@ Gw
                         <action selector="cancelButton_Click:" target="-2" id="RD5-nw-nr5"/>
                     </connections>
                 </button>
-                <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="NB2-m7-l19" customClass="KMComboBox" customModule="PDF_Master" customModuleProvider="target">
+                <comboBox verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="NB2-m7-l19" customClass="KMComboBox" customModule="PDF_Master" customModuleProvider="target">
                     <rect key="frame" x="255" y="64" width="124" height="23"/>
                     <constraints>
                         <constraint firstAttribute="width" constant="120" id="usv-QX-7LK"/>