Explorar el Código

Merge branch 'develop' of git.kdan.cc:Mac_PDF/PDF_Office into develop

* 'develop' of git.kdan.cc:Mac_PDF/PDF_Office:
  【PDFListView】- 签名注释接口调整
  【右键菜单】- 注释,选择空白右键菜单功能补充
  【右边栏】签名:注释-签名模块添加
  【PDF工具 - 打印】添加文件入口
tangchao hace 2 años
padre
commit
abc2451419
Se han modificado 37 ficheros con 3745 adiciones y 109 borrados
  1. 102 0
      PDF Office/PDF Office.xcodeproj/project.pbxproj
  2. 23 7
      PDF Office/PDF Office.xcodeproj/xcuserdata/lizhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  3. 9 0
      PDF Office/PDF Office/Class/PDFTools/Print/KMPrintWindowController.swift
  4. 5 6
      PDF Office/PDF Office/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/Signature/CPDFListSignatureAnnotation.m
  5. 31 3
      PDF Office/PDF Office/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/Stamp/CStampSignatureObject.h
  6. 74 29
      PDF Office/PDF Office/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/Stamp/CStampSignatureObject.m
  7. 20 0
      PDF Office/PDF Office/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m
  8. 7 8
      PDF Office/PDF Office/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Extension.m
  9. BIN
      PDF Office/PDF Office/Class/PDFWindowController/PDFSDK/ComPDFKit.framework/Versions/A/ComPDFKit
  10. 5 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/BookMarks/KMBookMarkViewController.swift
  11. 2 2
      PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift
  12. 38 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMDrawView.h
  13. 424 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMDrawView.m
  14. 15 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMImageAccessoryController.h
  15. 33 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMImageAccessoryController.m
  16. 37 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMImageAccessoryController.xib
  17. 19 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureImageView.h
  18. 362 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureImageView.m
  19. 29 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureTextView.h
  20. 213 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureTextView.m
  21. 38 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignature.h
  22. 61 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignature.m
  23. 285 2
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureAnnotationViewController.m
  24. 50 27
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureAnnotationViewController.xib
  25. 21 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureManager.h
  26. 56 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureManager.m
  27. 16 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.h
  28. 701 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.m
  29. 821 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.xib
  30. 15 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/NSImage+CustomImage.h
  31. 42 0
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/NSImage+CustomImage.m
  32. 3 3
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.m
  33. 2 2
      PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.xib
  34. 2 2
      PDF Office/PDF Office/Class/PDFWindowController/Toolbar/KMMainToolbarController.xib
  35. 126 0
      PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift
  36. 23 18
      PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift
  37. 35 0
      PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController.swift

+ 102 - 0
PDF Office/PDF Office.xcodeproj/project.pbxproj

@@ -13,6 +13,36 @@
 		89316825296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316821296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib */; };
 		89316826296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316821296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib */; };
 		89316827296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316821296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib */; };
+		89316837296E436B0073EA59 /* NSImage+CustomImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316828296E436A0073EA59 /* NSImage+CustomImage.m */; };
+		89316838296E436B0073EA59 /* NSImage+CustomImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316828296E436A0073EA59 /* NSImage+CustomImage.m */; };
+		89316839296E436B0073EA59 /* NSImage+CustomImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316828296E436A0073EA59 /* NSImage+CustomImage.m */; };
+		8931683A296E436B0073EA59 /* KMSignatureWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316829296E436A0073EA59 /* KMSignatureWindowController.m */; };
+		8931683B296E436B0073EA59 /* KMSignatureWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316829296E436A0073EA59 /* KMSignatureWindowController.m */; };
+		8931683C296E436B0073EA59 /* KMSignatureWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316829296E436A0073EA59 /* KMSignatureWindowController.m */; };
+		8931683D296E436B0073EA59 /* KMPDFSignatureTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8931682A296E436A0073EA59 /* KMPDFSignatureTextView.m */; };
+		8931683E296E436B0073EA59 /* KMPDFSignatureTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8931682A296E436A0073EA59 /* KMPDFSignatureTextView.m */; };
+		8931683F296E436B0073EA59 /* KMPDFSignatureTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8931682A296E436A0073EA59 /* KMPDFSignatureTextView.m */; };
+		89316840296E436B0073EA59 /* KMSignature.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316830296E436B0073EA59 /* KMSignature.m */; };
+		89316841296E436B0073EA59 /* KMSignature.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316830296E436B0073EA59 /* KMSignature.m */; };
+		89316842296E436B0073EA59 /* KMSignature.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316830296E436B0073EA59 /* KMSignature.m */; };
+		89316843296E436B0073EA59 /* KMDrawView.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316831296E436B0073EA59 /* KMDrawView.m */; };
+		89316844296E436B0073EA59 /* KMDrawView.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316831296E436B0073EA59 /* KMDrawView.m */; };
+		89316845296E436B0073EA59 /* KMDrawView.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316831296E436B0073EA59 /* KMDrawView.m */; };
+		89316846296E436B0073EA59 /* KMPDFSignatureImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316832296E436B0073EA59 /* KMPDFSignatureImageView.m */; };
+		89316847296E436B0073EA59 /* KMPDFSignatureImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316832296E436B0073EA59 /* KMPDFSignatureImageView.m */; };
+		89316848296E436B0073EA59 /* KMPDFSignatureImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316832296E436B0073EA59 /* KMPDFSignatureImageView.m */; };
+		89316849296E436B0073EA59 /* KMSignatureManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316835296E436B0073EA59 /* KMSignatureManager.m */; };
+		8931684A296E436B0073EA59 /* KMSignatureManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316835296E436B0073EA59 /* KMSignatureManager.m */; };
+		8931684B296E436B0073EA59 /* KMSignatureManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316835296E436B0073EA59 /* KMSignatureManager.m */; };
+		8931684C296E436B0073EA59 /* KMSignatureWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316836296E436B0073EA59 /* KMSignatureWindowController.xib */; };
+		8931684D296E436B0073EA59 /* KMSignatureWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316836296E436B0073EA59 /* KMSignatureWindowController.xib */; };
+		8931684E296E436B0073EA59 /* KMSignatureWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316836296E436B0073EA59 /* KMSignatureWindowController.xib */; };
+		89316852296E45CA0073EA59 /* KMImageAccessoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316850296E45CA0073EA59 /* KMImageAccessoryController.m */; };
+		89316853296E45CA0073EA59 /* KMImageAccessoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316850296E45CA0073EA59 /* KMImageAccessoryController.m */; };
+		89316854296E45CA0073EA59 /* KMImageAccessoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316850296E45CA0073EA59 /* KMImageAccessoryController.m */; };
+		89316855296E45CA0073EA59 /* KMImageAccessoryController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316851296E45CA0073EA59 /* KMImageAccessoryController.xib */; };
+		89316856296E45CA0073EA59 /* KMImageAccessoryController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316851296E45CA0073EA59 /* KMImageAccessoryController.xib */; };
+		89316857296E45CA0073EA59 /* KMImageAccessoryController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316851296E45CA0073EA59 /* KMImageAccessoryController.xib */; };
 		8942F7B22921D28200389627 /* Quick Start Guide.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 8942F7B12921D28200389627 /* Quick Start Guide.pdf */; };
 		8942F7B32921D28200389627 /* Quick Start Guide.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 8942F7B12921D28200389627 /* Quick Start Guide.pdf */; };
 		8942F7B42921D28200389627 /* Quick Start Guide.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 8942F7B12921D28200389627 /* Quick Start Guide.pdf */; };
@@ -1841,6 +1871,24 @@
 		8931681F296D73CC0073EA59 /* KMSignatureAnnotationViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KMSignatureAnnotationViewController.h; sourceTree = "<group>"; };
 		89316820296D73CC0073EA59 /* KMSignatureAnnotationViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KMSignatureAnnotationViewController.m; sourceTree = "<group>"; };
 		89316821296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMSignatureAnnotationViewController.xib; sourceTree = "<group>"; };
+		89316828296E436A0073EA59 /* NSImage+CustomImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSImage+CustomImage.m"; sourceTree = "<group>"; };
+		89316829296E436A0073EA59 /* KMSignatureWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMSignatureWindowController.m; sourceTree = "<group>"; };
+		8931682A296E436A0073EA59 /* KMPDFSignatureTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMPDFSignatureTextView.m; sourceTree = "<group>"; };
+		8931682B296E436A0073EA59 /* NSImage+CustomImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSImage+CustomImage.h"; sourceTree = "<group>"; };
+		8931682C296E436A0073EA59 /* KMSignature.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMSignature.h; sourceTree = "<group>"; };
+		8931682D296E436A0073EA59 /* KMPDFSignatureImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMPDFSignatureImageView.h; sourceTree = "<group>"; };
+		8931682E296E436B0073EA59 /* KMSignatureManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMSignatureManager.h; sourceTree = "<group>"; };
+		8931682F296E436B0073EA59 /* KMSignatureWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMSignatureWindowController.h; sourceTree = "<group>"; };
+		89316830296E436B0073EA59 /* KMSignature.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMSignature.m; sourceTree = "<group>"; };
+		89316831296E436B0073EA59 /* KMDrawView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMDrawView.m; sourceTree = "<group>"; };
+		89316832296E436B0073EA59 /* KMPDFSignatureImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMPDFSignatureImageView.m; sourceTree = "<group>"; };
+		89316833296E436B0073EA59 /* KMDrawView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMDrawView.h; sourceTree = "<group>"; };
+		89316834296E436B0073EA59 /* KMPDFSignatureTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMPDFSignatureTextView.h; sourceTree = "<group>"; };
+		89316835296E436B0073EA59 /* KMSignatureManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMSignatureManager.m; sourceTree = "<group>"; };
+		89316836296E436B0073EA59 /* KMSignatureWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMSignatureWindowController.xib; sourceTree = "<group>"; };
+		8931684F296E45CA0073EA59 /* KMImageAccessoryController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMImageAccessoryController.h; sourceTree = "<group>"; };
+		89316850296E45CA0073EA59 /* KMImageAccessoryController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMImageAccessoryController.m; sourceTree = "<group>"; };
+		89316851296E45CA0073EA59 /* KMImageAccessoryController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMImageAccessoryController.xib; sourceTree = "<group>"; };
 		8942F7B12921D28200389627 /* Quick Start Guide.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = "Quick Start Guide.pdf"; sourceTree = "<group>"; };
 		8942F7BA29222C7E00389627 /* KMBookCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBookCellView.swift; sourceTree = "<group>"; };
 		8942F7BE2923670F00389627 /* KMBOTAManagerClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBOTAManagerClass.swift; sourceTree = "<group>"; };
@@ -2682,6 +2730,24 @@
 				8931681F296D73CC0073EA59 /* KMSignatureAnnotationViewController.h */,
 				89316820296D73CC0073EA59 /* KMSignatureAnnotationViewController.m */,
 				89316821296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib */,
+				89316833296E436B0073EA59 /* KMDrawView.h */,
+				89316831296E436B0073EA59 /* KMDrawView.m */,
+				8931682D296E436A0073EA59 /* KMPDFSignatureImageView.h */,
+				89316832296E436B0073EA59 /* KMPDFSignatureImageView.m */,
+				89316834296E436B0073EA59 /* KMPDFSignatureTextView.h */,
+				8931682A296E436A0073EA59 /* KMPDFSignatureTextView.m */,
+				8931682C296E436A0073EA59 /* KMSignature.h */,
+				89316830296E436B0073EA59 /* KMSignature.m */,
+				8931682E296E436B0073EA59 /* KMSignatureManager.h */,
+				89316835296E436B0073EA59 /* KMSignatureManager.m */,
+				8931682F296E436B0073EA59 /* KMSignatureWindowController.h */,
+				89316829296E436A0073EA59 /* KMSignatureWindowController.m */,
+				89316836296E436B0073EA59 /* KMSignatureWindowController.xib */,
+				8931682B296E436A0073EA59 /* NSImage+CustomImage.h */,
+				89316828296E436A0073EA59 /* NSImage+CustomImage.m */,
+				8931684F296E45CA0073EA59 /* KMImageAccessoryController.h */,
+				89316850296E45CA0073EA59 /* KMImageAccessoryController.m */,
+				89316851296E45CA0073EA59 /* KMImageAccessoryController.xib */,
 			);
 			path = Signature;
 			sourceTree = "<group>";
@@ -5096,6 +5162,7 @@
 				BBC3481F295593F0008D2CD1 /* KMBackgroundListController.xib in Resources */,
 				9F1F82E62934D5240092C4B4 /* KMHomeExtractActionViewController.xib in Resources */,
 				89E4E77C2967B370002DBA6F /* KMDynamicStampViewController.xib in Resources */,
+				89316855296E45CA0073EA59 /* KMImageAccessoryController.xib in Resources */,
 				89752E072939DB42003FF08E /* KMToolbarViewController.xib in Resources */,
 				BBC3483E2955A60B008D2CD1 /* KMBackgroundPropertyInfoController.xib in Resources */,
 				BBFE6E822930EBD400142C01 /* KMCompressWindowController.xib in Resources */,
@@ -5150,6 +5217,7 @@
 				9F1F82DD292F84D60092C4B4 /* KMHomeInsertActionViewController.xib in Resources */,
 				9F78EFBE28F7C1CC001E66F4 /* KMHomeViewController.xib in Resources */,
 				9FDD0F9F2952FF4D000C4DAD /* global.json in Resources */,
+				8931684C296E436B0073EA59 /* KMSignatureWindowController.xib in Resources */,
 				8942F7FB2926089200389627 /* KMSignatureViewController.xib in Resources */,
 				9FDD0FBA295D5230000C4DAD /* KMToolbarController.xib in Resources */,
 				899700E228F3A9F2009AF911 /* KMHomeWindowController.xib in Resources */,
@@ -5263,6 +5331,7 @@
 				ADD1B6F92946C0CA00C3FFF7 /* KMPrintChoosePageSizeMultipageView.xib in Resources */,
 				ADD1B6CC2942E85300C3FFF7 /* KMPrintBottomView.xib in Resources */,
 				9F0CB4732967E63100007028 /* KMPropertiesPanelNameSubVC.xib in Resources */,
+				89316856296E45CA0073EA59 /* KMImageAccessoryController.xib in Resources */,
 				BBC3483F2955A60B008D2CD1 /* KMBackgroundPropertyInfoController.xib in Resources */,
 				899700E328F3A9F2009AF911 /* KMHomeWindowController.xib in Resources */,
 				BB8F4543295A98960037EA22 /* KMHeaderFooterPropertyController.xib in Resources */,
@@ -5326,6 +5395,7 @@
 				89D2D2FF294C806000BFF5FE /* KMPDFThumbnailItem.xib in Resources */,
 				89E4E70C2963D62B002DBA6F /* KMAnnotationFontWindowController.xib in Resources */,
 				ADC25DFD2923BA710080A3F6 /* KMImageToPDFWindowController.xib in Resources */,
+				8931684D296E436B0073EA59 /* KMSignatureWindowController.xib in Resources */,
 				9F8539DB294318D600DF644E /* TabsImage.xcassets in Resources */,
 				BBEC00DD295C39FD00A26C98 /* KMBatesPropertyInfoController.xib in Resources */,
 				BBA8B7B4293635D80097D183 /* KMPasswordInputWindow.xib in Resources */,
@@ -5562,6 +5632,8 @@
 				BBC3481129558DC1008D2CD1 /* KMBackgroundController.xib in Resources */,
 				89316827296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib in Resources */,
 				BB8B17382907B64D001C5EA5 /* CipherTextView.xib in Resources */,
+				8931684E296E436B0073EA59 /* KMSignatureWindowController.xib in Resources */,
+				89316857296E45CA0073EA59 /* KMImageAccessoryController.xib in Resources */,
 				9FBA0EEB28FFC2FE001117AF /* Image.xcassets in Resources */,
 				8997010B28F4082C009AF911 /* KMFromViewController.xib in Resources */,
 				9F0CB4642966C9E200007028 /* KMFormPropertPanelViewController.xib in Resources */,
@@ -5611,6 +5683,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				BB8F453F295A98960037EA22 /* KMHeaderFooterPropertyController.swift in Sources */,
+				89316840296E436B0073EA59 /* KMSignature.m in Sources */,
 				BB8F4565295AA3ED0037EA22 /* KMHeaderFooterManager.swift in Sources */,
 				ADCB990B292B6ADC00B51A03 /* KMImageToPDFChoosePresenter.swift in Sources */,
 				F34BF926295303E8002C25A2 /* NSCursor+PDFListView.m in Sources */,
@@ -5672,7 +5745,11 @@
 				BBA8B7AA2935DC120097D183 /* KMRemovePasswordResultTipView.swift in Sources */,
 				AD9527CA295297B70039D2BC /* KMPrintModel.swift in Sources */,
 				ADCB9971292C65EE00B51A03 /* KMGOCROperation.m in Sources */,
+
 				BBD1F77C296F9BE000343885 /* KMPageEditSettingBaseWindowController.swift in Sources */,
+
+				8931683A296E436B0073EA59 /* KMSignatureWindowController.m in Sources */,
+
 				BBF38A5A294F2B760086D025 /* KMWatermarkPositionView.swift in Sources */,
 				BB8F4586295B19AC0037EA22 /* KMHeaderFooterDateInfoView.swift in Sources */,
 				BB1EC8112967EB5A00EC0BC3 /* KMPageEditThumbnailViewKMPageEditThumbnailView_OC.m in Sources */,
@@ -5715,6 +5792,7 @@
 				9F8539DE29470A0700DF644E /* KMTabStripView.swift in Sources */,
 				AD9527EE295578BD0039D2BC /* KMBaseTextFieldPresenter.swift in Sources */,
 				F37322F6292DF9410013862C /* CSelfSignAnnotation.m in Sources */,
+				89316843296E436B0073EA59 /* KMDrawView.m in Sources */,
 				BB49ED1D293F4FB200C82CA2 /* KMConvertPPTsSettingView.swift in Sources */,
 				F37322ED292DF9410013862C /* CPDFMarkupAnnotation+PDFListView.m in Sources */,
 				ADCB98E12924776F00B51A03 /* KMBatchProcessingSizeTableCell.swift in Sources */,
@@ -5839,8 +5917,10 @@
 				ADD1B6BB29420B4A00C3FFF7 /* KMPrintPreviewView.swift in Sources */,
 				9F1F82B4292DEF370092C4B4 /* KMCloudDocumentsViewController.swift in Sources */,
 				9F1F82F7293D8F9D0092C4B4 /* KMDocumentController.swift in Sources */,
+				89316846296E436B0073EA59 /* KMPDFSignatureImageView.m in Sources */,
 				F3732308292DF9410013862C /* CPDFLineAnnotation+PDFListView.m in Sources */,
 				9F1F82CA292F6CF90092C4B4 /* KMPDFInsertPageWindow.swift in Sources */,
+				8931683D296E436B0073EA59 /* KMPDFSignatureTextView.m in Sources */,
 				9FBA0EE128FEC253001117AF /* KMProductPromotionViewController.swift in Sources */,
 				AD9527BE295294E20039D2BC /* KMPrintPageModel.swift in Sources */,
 				BBC348022955403D008D2CD1 /* KMWatermarkFilePropertyInfoController.swift in Sources */,
@@ -5853,6 +5933,7 @@
 				9FDD0F842952FC9C000C4DAD /* KMAliasLightParser.swift in Sources */,
 				BBFE6E5D2930809A00142C01 /* KMMergeCollectionPageViewItem.swift in Sources */,
 				89E4E7132963D7FF002DBA6F /* NSFont_SKExtensions.m in Sources */,
+				89316849296E436B0073EA59 /* KMSignatureManager.m in Sources */,
 				F3732305292DF9410013862C /* CPDFSquareAnnotation+PDFListView.m in Sources */,
 				89D2D2BD29486D2400BFF5FE /* KMSignatureCellView.swift in Sources */,
 				9F1FE49629406E4700E952CA /* common.c in Sources */,
@@ -5869,6 +5950,7 @@
 				9FBA0EEE28FFC716001117AF /* KMHomeFastToolViewController.swift in Sources */,
 				ADD1B6C72942E83000C3FFF7 /* KMPrintBottomView.swift in Sources */,
 				BB8F457E295B00130037EA22 /* KMWatermarkAdjectiveTools.swift in Sources */,
+				89316837296E436B0073EA59 /* NSImage+CustomImage.m in Sources */,
 				ADD1B7022946C8AD00C3FFF7 /* KMBaseTextField.swift in Sources */,
 				F37322DE292DF9410013862C /* CPDFFreeTextAnnotation+PDFListView.m in Sources */,
 				BB89724D294C1DCE0045787C /* KMWatermarkAdjectiveListTableCellView.swift in Sources */,
@@ -5930,6 +6012,7 @@
 				8942F7FF29260EC700389627 /* KMLeftMethodMode.swift in Sources */,
 				9FDD0FB7295D5230000C4DAD /* KMToolbarController.swift in Sources */,
 				9F1FE4F929406E4700E952CA /* CTTabStripView.m in Sources */,
+				89316852296E45CA0073EA59 /* KMImageAccessoryController.m in Sources */,
 				F3732323292DFFFE0013862C /* CPDFListView+Extension.m in Sources */,
 				9F1FE4C029406E4700E952CA /* NSWindow+CTThemed.m in Sources */,
 				F37322E1292DF9410013862C /* CPDFChoiceWidgetAnnotation+PDFListView.m in Sources */,
@@ -6054,6 +6137,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				BB8F4540295A98960037EA22 /* KMHeaderFooterPropertyController.swift in Sources */,
+				89316841296E436B0073EA59 /* KMSignature.m in Sources */,
 				BB8F4566295AA3ED0037EA22 /* KMHeaderFooterManager.swift in Sources */,
 				BB99ACC3292DE22E0048AFD9 /* KMMergeViewController.swift in Sources */,
 				9F78EFC728F7E965001E66F4 /* KMHomeViewController+UI.swift in Sources */,
@@ -6115,7 +6199,11 @@
 				F373230F292DF9410013862C /* CPDFInkAnnotation+PDFListView.m in Sources */,
 				9F1F82F329373D6E0092C4B4 /* String+KMExtensions.swift in Sources */,
 				F3B7DF9B2948565000333201 /* CPDFListHoverAnnotationViewController.m in Sources */,
+
 				BBD1F77D296F9BE000343885 /* KMPageEditSettingBaseWindowController.swift in Sources */,
+
+				8931683B296E436B0073EA59 /* KMSignatureWindowController.m in Sources */,
+
 				9FDD0FB329534FEA000C4DAD /* KMGlobal.swift in Sources */,
 				BB8F4587295B19AC0037EA22 /* KMHeaderFooterDateInfoView.swift in Sources */,
 				BB1EC8122967EB5A00EC0BC3 /* KMPageEditThumbnailViewKMPageEditThumbnailView_OC.m in Sources */,
@@ -6158,6 +6246,7 @@
 				9F8539DF29470A0700DF644E /* KMTabStripView.swift in Sources */,
 				AD9527EF295578BD0039D2BC /* KMBaseTextFieldPresenter.swift in Sources */,
 				8942F80029260EC700389627 /* KMLeftMethodMode.swift in Sources */,
+				89316844296E436B0073EA59 /* KMDrawView.m in Sources */,
 				BB49ED1E293F4FB200C82CA2 /* KMConvertPPTsSettingView.swift in Sources */,
 				9FA607DA28F8227500B46586 /* KMBox.swift in Sources */,
 				AD9527BF295294E20039D2BC /* KMPrintPageModel.swift in Sources */,
@@ -6282,8 +6371,10 @@
 				9F78EFBC28F7C1CC001E66F4 /* KMHomeViewController.swift in Sources */,
 				9FBA0EEF28FFC716001117AF /* KMHomeFastToolViewController.swift in Sources */,
 				BB86C1FE28F54923005AD968 /* NSEvent_SKExtensions.m in Sources */,
+				89316847296E436B0073EA59 /* KMPDFSignatureImageView.m in Sources */,
 				BB49ECF7293F44DC00C82CA2 /* KMConvertExcelWindowController.swift in Sources */,
 				9F1FE4EB29406E4700E952CA /* NSBezierPath+MCAdditions.m in Sources */,
+				8931683E296E436B0073EA59 /* KMPDFSignatureTextView.m in Sources */,
 				BBFE6E762930E53000142C01 /* KMMergePopoverViewController.swift in Sources */,
 				ADD1B6BC29420B4A00C3FFF7 /* KMPrintPreviewView.swift in Sources */,
 				BBC348032955403D008D2CD1 /* KMWatermarkFilePropertyInfoController.swift in Sources */,
@@ -6296,6 +6387,7 @@
 				F34BF927295303E8002C25A2 /* NSCursor+PDFListView.m in Sources */,
 				ADB2D6EE2947415E0029D2B3 /* KMPrintPaperSetView.swift in Sources */,
 				89E4E7142963D7FF002DBA6F /* NSFont_SKExtensions.m in Sources */,
+				8931684A296E436B0073EA59 /* KMSignatureManager.m in Sources */,
 				BB3EAEAE293E3D6000D92407 /* KMConvertBaseWindowController.swift in Sources */,
 				9F1FE4A629406E4700E952CA /* CTToolbarView.m in Sources */,
 				BB162E9C295073B50088E9D1 /* KMWatermarkManager.swift in Sources */,
@@ -6312,6 +6404,7 @@
 				ADD1B6E02946BFD500C3FFF7 /* KMPrintChoosePageSizeSizeView.swift in Sources */,
 				BBFE6E5E2930809A00142C01 /* KMMergeCollectionPageViewItem.swift in Sources */,
 				BB8F457F295B00130037EA22 /* KMWatermarkAdjectiveTools.swift in Sources */,
+				89316838296E436B0073EA59 /* NSImage+CustomImage.m in Sources */,
 				BBA8B7AB2935DC120097D183 /* KMRemovePasswordResultTipView.swift in Sources */,
 				ADCB9972292C65EE00B51A03 /* KMGOCROperation.m in Sources */,
 				9FDD0F78294FEF64000C4DAD /* KMConvertPDFManager.swift in Sources */,
@@ -6373,6 +6466,7 @@
 				9F8539CC29430BF300DF644E /* KMBrowserWindowController.swift in Sources */,
 				9FDD0FB8295D5230000C4DAD /* KMToolbarController.swift in Sources */,
 				BB162E98295062CD0088E9D1 /* KMPageRangeTools.swift in Sources */,
+				89316853296E45CA0073EA59 /* KMImageAccessoryController.m in Sources */,
 				BBA8B7A42935CD740097D183 /* KMRemovePasswordAlertWindowController.swift in Sources */,
 				F37322EE292DF9410013862C /* CPDFMarkupAnnotation+PDFListView.m in Sources */,
 				9F1FE4FA29406E4700E952CA /* CTTabStripView.m in Sources */,
@@ -6498,6 +6592,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				BBC745F9296178BD0072C2ED /* KMCropTools.swift in Sources */,
+				89316839296E436B0073EA59 /* NSImage+CustomImage.m in Sources */,
 				89E4E7072963D588002DBA6F /* KMBox.m in Sources */,
 				9F0CB48929683DC400007028 /* KMPropertiesPanelPresetColorSubVC.swift in Sources */,
 				BB99ACC4292DE22E0048AFD9 /* KMMergeViewController.swift in Sources */,
@@ -6551,6 +6646,7 @@
 				BB99ACD1292E2AEF0048AFD9 /* KMMergeCollectionViewItem.swift in Sources */,
 				BB86C1EF28F544F4005AD968 /* CPDFListView+Event.m in Sources */,
 				BB86C1EF28F544F4005AD968 /* CPDFListView+Event.m in Sources */,
+				8931684B296E436B0073EA59 /* KMSignatureManager.m in Sources */,
 				89D9896E28FD50EF003A3E87 /* KMAnnotationCollectionViewItem.swift in Sources */,
 				BB86C1EF28F544F4005AD968 /* CPDFListView+Event.m in Sources */,
 				9F1F82F429373D6E0092C4B4 /* String+KMExtensions.swift in Sources */,
@@ -6607,6 +6703,7 @@
 				89752E1F2942CB04003FF08E /* KMSearchMode.swift in Sources */,
 				BBD1F785296F9DB500343885 /* KMPageEditExtractWindowController.swift in Sources */,
 				BB5DF1EB2959C5CB0025CDA1 /* KMHeaderFooterPreviewController.swift in Sources */,
+				89316854296E45CA0073EA59 /* KMImageAccessoryController.m in Sources */,
 				AD3A3589294C11ED00D72802 /* KMPrintPreviewPresenter.swift in Sources */,
 				BB49ED1B293F4D4E00C82CA2 /* KMConvertCSVSettingView.swift in Sources */,
 				89752E1B2941FD48003FF08E /* KMSearchCellView.swift in Sources */,
@@ -6631,6 +6728,7 @@
 				BB2C6ACF28F41BA000478A33 /* CPDFListView.m in Sources */,
 				BB2EDF6C296ECE17003BCF58 /* KMPageEditInsertTypeItemView.swift in Sources */,
 				9F1FE4D729406E4700E952CA /* NSPasteboard+Utils.m in Sources */,
+				89316842296E436B0073EA59 /* KMSignature.m in Sources */,
 				9F1FE4B329406E4700E952CA /* CTTabWindowController.m in Sources */,
 				BBFE6E812930EBD400142C01 /* KMCompressWindowController.swift in Sources */,
 				ADCB996D292C65EE00B51A03 /* KMGOCRManager.m in Sources */,
@@ -6699,6 +6797,7 @@
 				9FAAA327290A69920046FFCE /* KMToolSetScroller.swift in Sources */,
 				F373231B292DF97D0013862C /* CPDFSelection+PDFListView.m in Sources */,
 				BBFE6E89293210AB00142C01 /* KMCompressCellView.swift in Sources */,
+				8931683C296E436B0073EA59 /* KMSignatureWindowController.m in Sources */,
 				9F1F82EC2935D02E0092C4B4 /* KMComboBox.swift in Sources */,
 				8997012128F41AB8009AF911 /* KMLeftSideViewController.swift in Sources */,
 				89D2D2CC2949D4C900BFF5FE /* KMNoteTypeImageView.m in Sources */,
@@ -6756,6 +6855,7 @@
 				89E4E77B2967B370002DBA6F /* KMDynamicStampViewController.m in Sources */,
 				9F78EFBD28F7C1CC001E66F4 /* KMHomeViewController.swift in Sources */,
 				BBC745EC295F067B0072C2ED /* KMCropSettingWindowController.swift in Sources */,
+				89316848296E436B0073EA59 /* KMPDFSignatureImageView.m in Sources */,
 				ADD1B6C92942E83000C3FFF7 /* KMPrintBottomView.swift in Sources */,
 				ADD1B7042946C8AD00C3FFF7 /* KMBaseTextField.swift in Sources */,
 				9FBA0EF028FFC716001117AF /* KMHomeFastToolViewController.swift in Sources */,
@@ -6771,6 +6871,7 @@
 				F3732335292F7B8D0013862C /* CStampSignatureObject.m in Sources */,
 				F3732304292DF9410013862C /* CPDFLinkAnnotation+PDFListView.m in Sources */,
 				BB897222294AF9080045787C /* KMWatermarkAdjectiveTopBarView.swift in Sources */,
+				8931683F296E436B0073EA59 /* KMPDFSignatureTextView.m in Sources */,
 				9F8DDF362924DA6B006CDC73 /* KMPDFToolsCollectionView.swift in Sources */,
 				ADB2D6FB294882AE0029D2B3 /* KMTextFieldStepperView.swift in Sources */,
 				AD9527F0295578BD0039D2BC /* KMBaseTextFieldPresenter.swift in Sources */,
@@ -6792,6 +6893,7 @@
 				89D2D2C329495D2100BFF5FE /* KMFormModel.swift in Sources */,
 				BBFE6E67293097A600142C01 /* KMPageRangePickerWindowController.swift in Sources */,
 				BB88E43D294023CB002B3655 /* KMDocumentModel.swift in Sources */,
+				89316845296E436B0073EA59 /* KMDrawView.m in Sources */,
 				BB897267294C724D0045787C /* KMWatermarkAdjectiveOutsideView.swift in Sources */,
 				AD9527EC2955520C0039D2BC /* KMBaseTextFieldModel.swift in Sources */,
 				BBF38A5C294F2B760086D025 /* KMWatermarkPositionView.swift in Sources */,

+ 23 - 7
PDF Office/PDF Office.xcodeproj/xcuserdata/lizhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -286,8 +286,8 @@
             filePath = "PDF Office/Class/PDFTools/Print/KMPrintWindowController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "113"
-            endingLineNumber = "113"
+            startingLineNumber = "122"
+            endingLineNumber = "122"
             landmarkName = "printAction()"
             landmarkType = "7">
          </BreakpointContent>
@@ -359,8 +359,8 @@
             filePath = "PDF Office/Class/PDFTools/Print/KMPrintWindowController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "96"
-            endingLineNumber = "96"
+            startingLineNumber = "105"
+            endingLineNumber = "105"
             landmarkName = "printerAction()"
             landmarkType = "7">
          </BreakpointContent>
@@ -473,7 +473,7 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "241"
             endingLineNumber = "241"
-            landmarkName = "insertPageAction(_:_:_:_:)"
+            landmarkName = "openHistoryFilePath(url:)"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
@@ -521,8 +521,8 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "436"
             endingLineNumber = "436"
-            landmarkName = "drawPageToContext(context:pages:data:)"
-            landmarkType = "7">
+            landmarkName = "unknown"
+            landmarkType = "0">
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
@@ -669,5 +669,21 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "5D0BD960-2B7B-4B27-9747-F4C9DEBE322D"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Office/Class/Home/ViewController/KMHomeViewController+Action.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "379"
+            endingLineNumber = "379"
+            landmarkName = "fastTool_Batch()"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 9 - 0
PDF Office/PDF Office/Class/PDFTools/Print/KMPrintWindowController.swift

@@ -77,6 +77,15 @@ class KMPrintWindowController: NSWindowController, NetServiceBrowserDelegate {
             }
         }
     }
+    
+    //MARK: 打开文件
+    static func openFile(url: URL) {
+        let printWindowController: KMPrintWindowController = KMPrintWindowController.init(windowNibName: "KMPrintWindowController")
+        NSApp.mainWindow?.beginCriticalSheet(printWindowController.window!)
+        printWindowController.inputData = url
+        printWindowController.inputType = .Print
+    }
+
 }
 
 extension NetService {

+ 5 - 6
PDF Office/PDF Office/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/Signature/CPDFListSignatureAnnotation.m

@@ -46,7 +46,7 @@
         self.bounds = bounds;
     }
     
-    if (CPDFStampTypeImage == self.stamp.stampCategoryType && self.stamp.isSignatureAnnotation) {
+    if (self.stamp.isSignatureAnnotation) {
         [self updateAppearanceStreamWithImage:self.pImage rotation:rotation];
     }
 }
@@ -54,12 +54,11 @@
 - (void)setBorderBoundsWithStamp:(CStampSignatureObject *)stamp {
     self.stamp = stamp;
     self.borderBounds = self.bounds;
-    if(CPDFStampTypeImage == stamp.stampCategoryType) {
-        NSImage * image = [[NSImage alloc] initWithContentsOfFile:stamp.imagePath];
-        self.pImage = image;
+    if(self.stamp.isSignatureAnnotation) {
+        self.pImage = self.stamp.signatureImage;
         
-        CGFloat borderDefaultWidth = image.size.width;
-        CGFloat borderScale = borderDefaultWidth/image.size.height;
+        CGFloat borderDefaultWidth = self.pImage.size.width;
+        CGFloat borderScale = borderDefaultWidth/self.pImage.size.height;
         CGPoint center = CGPointMake(self.bounds.origin.x+self.bounds.size.width/2, self.bounds.origin.y+self.bounds.size.height/2);
         NSRect bounds = NSMakeRect(self.bounds.origin.x, self.bounds.origin.y, 0, 0);
         if (self.bounds.size.width/self.bounds.size.height > borderScale) {

+ 31 - 3
PDF Office/PDF Office/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/Stamp/CStampSignatureObject.h

@@ -45,7 +45,10 @@ typedef NS_ENUM(NSUInteger, CStandardStampType) {
 };
 
 enum {
-    CPDFStampTypeDynamic = 4
+    CPDFStampTypeDynamic = 4,
+    CPDFSignatureTypeInk ,
+    CPDFSignatureTypeText ,
+    CPDFSignatureTypeImage
 };
 
 @interface CStampSignatureObject : NSObject
@@ -76,12 +79,20 @@ enum {
 
 @property (nonatomic,readonly) BOOL needExchangeFontSize;
 
+@property (nonatomic,readonly) NSImage * signatureImage;
+
+@property (nonatomic,readonly) NSDictionary<NSAttributedStringKey, id> * attributed;
+
+@property (nonatomic,readonly) NSString * signatureText;
+
+@property (nonatomic,readonly) NSArray<NSBezierPath *> * paths;
+
+@property (nonatomic,readonly) NSColor * drawColor;
+
 - (instancetype)initStandardStampWithType:(CStandardStampType)stampType;
 
 - (instancetype)initImageStampWithFilePath:(NSString *)imagePath;
 
-- (instancetype)initImageSignatureWithFilePath:(NSString *)imagePath;
-
 - (instancetype)initWithText:(NSString *)text
                   detailText:(NSString *)detailText
                        style:(CPDFStampStyle)style
@@ -98,6 +109,23 @@ enum {
                     dateText:(NSString *)dateText
                        color:(NSColor *)color;
 
+//暂时建议只用这个
+- (instancetype)initSignatureWithImage:(NSImage *)image;
+
+//- (instancetype)initSignatureWithText:(NSString *)signatureText attributed:(NSDictionary<NSAttributedStringKey, id> *)attributed;
+//
+//- (instancetype)initSignatureWithPaths:(NSArray<NSBezierPath *> *)paths signatureColor:(NSColor *)color;
+//
+////文字签名图章
+//-(void)updateSignatureAttributed:(NSDictionary<NSAttributedStringKey, id> *)attributed;
+//
+//- (void)addSignaturePath:(NSBezierPath*)path;
+//
+////ink签名图章
+//- (void)updateSignatureDrawColor:(NSColor *)color;
+//
+//- (void)removeSignaturePath:(NSBezierPath*)path;
+
 - (NSImage *)stampPreImage;
 
 @end

+ 74 - 29
PDF Office/PDF Office/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/Stamp/CStampSignatureObject.m

@@ -45,6 +45,16 @@
 
 @property (nonatomic,assign) BOOL needExchangeFontSize;
 
+@property (nonatomic,retain) NSImage * signatureImage;
+
+@property (nonatomic,retain) NSDictionary<NSAttributedStringKey, id> * attributed;
+
+@property (nonatomic,retain) NSString * signatureText;
+
+@property (nonatomic,retain) NSArray<NSBezierPath *> * paths;
+
+@property (nonatomic,retain) NSColor * drawColor;
+
 @end
 
 @implementation CStampSignatureObject
@@ -135,15 +145,6 @@
     return self;
 }
 
-- (instancetype)initImageSignatureWithFilePath:(NSString *)imagePath {
-    if(self = [super init]) {
-        self.stampCategoryType = CPDFStampTypeImage;
-        self.imagePath = imagePath;
-        self.isSignatureAnnotation = YES;
-    }
-    return self;
-}
-
 - (instancetype)initWithText:(NSString *)text
                   detailText:(NSString *)detailText
                        style:(CPDFStampStyle)style
@@ -188,6 +189,35 @@
     return self;
 }
 
+- (instancetype)initSignatureWithImage:(NSImage *)image {
+    if(self = [super init]) {
+        self.stampCategoryType = CPDFSignatureTypeImage;
+        self.signatureImage = image;
+        self.isSignatureAnnotation = YES;
+    }
+    return self;
+}
+
+- (instancetype)initSignatureWithText:(NSString *)signatureText attributed:(NSDictionary<NSAttributedStringKey, id> *)attributed {
+    if(self = [super init]) {
+        self.stampCategoryType = CPDFSignatureTypeText;
+        self.signatureText = signatureText;
+        self.attributed = attributed;
+        self.isSignatureAnnotation = YES;
+    }
+    return self;
+}
+
+- (instancetype)initSignatureWithPaths:(NSArray<NSBezierPath *> *)paths signatureColor:(NSColor *)color {
+    if(self = [super init]) {
+        self.stampCategoryType = CPDFSignatureTypeInk;
+        self.paths = paths;
+        self.drawColor = color;
+        self.isSignatureAnnotation = YES;
+    }
+    return self;
+}
+
 -(NSRect)annotationBounds {
     CGRect rect = CGRectMake(0, 0, 160.0, 40.0);
     CGFloat defaultWidth = 160.0;
@@ -251,6 +281,27 @@
     return rect;
 }
 
+-(void)updateSignatureAttributed:(NSDictionary<NSAttributedStringKey, id> *)attributed {
+    self.attributed = attributed;
+}
+
+- (void)addSignaturePath:(NSBezierPath*)path {
+    NSMutableArray *links = [NSMutableArray arrayWithArray:self.paths];
+    [links addObject:path];
+    self.paths = links;
+}
+
+- (void)updateSignatureDrawColor:(NSColor *)color {
+    self.drawColor = color;
+}
+
+- (void)removeSignaturePath:(NSBezierPath*)path {
+    NSMutableArray *links = [NSMutableArray arrayWithArray:self.paths];
+    [links removeObject:path];
+    self.paths = links;
+
+}
+
 - (NSImage *)stampPreImage {
     NSImage *image = nil;
     CPDFDocument *document = [[CPDFDocument alloc] init];
@@ -275,20 +326,19 @@
         }
     } else if (CPDFStampTypeImage == self.stampCategoryType) {
         image = [[NSImage alloc] initWithContentsOfFile:self.imagePath];
-        if(self.isSignatureAnnotation) {
-            CPDFListSignatureAnnotation *annotation = [[CPDFListSignatureAnnotation alloc] initWithDocument:document];
-            [(CPDFListSignatureAnnotation *)annotation setImage:image];
-            annotation.bounds = [self annotationBounds];
-            CPDFPage *page = [document pageAtIndex:0];
-            [page addAnnotation:annotation];
-            image = annotation.pImage;
-        } else {
-            CPDFStampAnnotation *annotation = [[CPDFListStampAnnotation alloc] initWithDocument:document image:image];
-            annotation.bounds = [self annotationBounds];
-            CPDFPage *page = [document pageAtIndex:0];
-            [page addAnnotation:annotation];
-            image = annotation.stampImage;
-        }
+        CPDFStampAnnotation *annotation = [[CPDFListStampAnnotation alloc] initWithDocument:document image:image];
+        annotation.bounds = [self annotationBounds];
+        CPDFPage *page = [document pageAtIndex:0];
+        [page addAnnotation:annotation];
+        image = annotation.stampImage;
+    } else if (self.isSignatureAnnotation) {
+        image = self.signatureImage;
+        CPDFListSignatureAnnotation *annotation = [[CPDFListSignatureAnnotation alloc] initWithDocument:document];
+        [(CPDFListSignatureAnnotation *)annotation setImage:image];
+        annotation.bounds = [self annotationBounds];
+        CPDFPage *page = [document pageAtIndex:0];
+        [page addAnnotation:annotation];
+        image = annotation.pImage;
     } else if (CPDFStampTypeDigital == self.stampCategoryType) {
         CPDFStampAnnotation *stamp = [[CPDFStampAnnotation alloc] initWithDocument:document text:self.text detailText:self.detailText dateText:self.dateText color:self.color];
         stamp.bounds = [self annotationBounds];
@@ -307,12 +357,7 @@
         CPDFPage *page = [document pageAtIndex:0];
         [page addAnnotation:annotation];
         image = annotation.stampImage;
-    } else {
-        CPDFStampAnnotation *stamp = [[CPDFStampAnnotation alloc] initWithDocument:document type:1];
-        stamp.bounds = [self annotationBounds];
-        CPDFPage *page = [document pageAtIndex:0];
-        [page addAnnotation:stamp];
-        image = stamp.stampImage;
+    
     }
     return image;
 }

+ 20 - 0
PDF Office/PDF Office/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m

@@ -2951,6 +2951,26 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
 }
 
 - (IBAction)menuItemClick_HidenorShowNote:(id)sender {
+    NSOpenPanel *openPanel = [NSOpenPanel openPanel];
+    [openPanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result){
+        if (result == NSFileHandlingPanelOKButton) {
+            CPDFDocument *docyem = [[CPDFDocument alloc]initWithURL:openPanel.URL];
+            NSMutableArray *pages = [NSMutableArray array];
+            for(NSUInteger i = 0;i<docyem.pageCount;i++) {
+                CPDFPage *page = [docyem pageAtIndex:i];
+                [pages addObject:page];
+            }
+            
+            [self.document insertPageObject:pages.firstObject atIndex:0];
+            [self layoutDocumentView];
+
+        }
+        
+        
+    }];
+    
+    return;
+    
     self.hideNotes = !self.hideNotes;
     for(NSInteger i = 0;i<self.document.pageCount;i++) {
         CPDFPage *page = [self.document pageAtIndex:i];

+ 7 - 8
PDF Office/PDF Office/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Extension.m

@@ -73,14 +73,13 @@
     
     if (CPDFStampTypeImage == self.stampObject.stampCategoryType) {
         NSImage * image = [[NSImage alloc] initWithContentsOfFile:self.stampObject.imagePath];
-        if(self.stampObject.isSignatureAnnotation) {
-            annotation = [[CPDFListSignatureAnnotation alloc] initWithDocument:self.document];
-            [(CPDFListSignatureAnnotation *)annotation setImage:image];
-            annotation.bounds = bounds;
-        } else {
-            annotation = [[CPDFListStampAnnotation alloc] initWithDocument:self.document image:image];
-            annotation.bounds = bounds;
-        }
+        annotation = [[CPDFListStampAnnotation alloc] initWithDocument:self.document image:image];
+        annotation.bounds = bounds;
+    } else if(self.stampObject.isSignatureAnnotation) {
+        NSImage * image = self.stampObject.signatureImage;
+        annotation = [[CPDFListSignatureAnnotation alloc] initWithDocument:self.document];
+        [(CPDFListSignatureAnnotation *)annotation setImage:image];
+        annotation.bounds = bounds;
     } else if (CPDFStampTypeText == self.stampObject.stampCategoryType) {
         annotation = [[CPDFListStampAnnotation alloc] initWithDocument:self.document text:self.stampObject.text detailText:self.stampObject.detailText style:self.stampObject.style shape:self.stampObject.shape];
         annotation.bounds = NSMakeRect(pagePoint.x, pagePoint.y-annotation.bounds.size.height, annotation.bounds.size.width, annotation.bounds.size.height);

BIN
PDF Office/PDF Office/Class/PDFWindowController/PDFSDK/ComPDFKit.framework/Versions/A/ComPDFKit


+ 5 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/BookMarks/KMBookMarkViewController.swift

@@ -28,6 +28,11 @@ class KMBookMarkViewController: NSViewController, NSTextFieldDelegate,NSMenuItem
         self.addMenuTitle()
     }
     
+    func reloadData() {
+        self.dataSource = self.listView.document.bookmarks() ?? [CPDFBookmark]()
+        self.bookTableView.reloadData()
+    }
+    
     private func addMenuTitle() {
         let menus : NSMenu = NSMenu(title: "")
         let addItem = self.menuItemWithTitle(title: NSLocalizedString("Rename", comment: ""), action: #selector(renameBookAction))

+ 2 - 2
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift

@@ -42,7 +42,7 @@ class KMLeftSideViewController: NSViewController {
     
     var dataSource : [KMLeftMethodMode] = [KMLeftMethodMode]()
     
-    private var type : KMLeftMethodMode = KMLeftMethodMode()
+    var type : KMLeftMethodMode = KMLeftMethodMode()
     
     convenience init(type : KMLeftMethodMode) {
         self.init()
@@ -101,7 +101,7 @@ class KMLeftSideViewController: NSViewController {
         }
     }
     
-    private func refreshShowMethod() {
+    func refreshShowMethod() {
         self.dataSource = [KMLeftMethodMode]()
         if KMBOTAManagerClass.shard.getMethodShow(key: thumbnailMethodKey) {
             let mode = KMLeftMethodMode()

+ 38 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMDrawView.h

@@ -0,0 +1,38 @@
+//
+//  KMDrawView.h
+//  PDF Reader
+//
+//  Created by wangshuai on 13-3-12.
+//  Copyright (c) 2013年 zhangjie. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@class KMDrawView;
+
+@protocol KMDrawViewDelegate <NSObject>
+
+@optional
+- (void)drawViewDidFinishTouchMode:(KMDrawView *)view;
+
+@end
+
+@interface KMDrawView : NSView
+
+@property (nonatomic,assign) id<KMDrawViewDelegate> delegate;
+
+@property (nonatomic,retain) NSColor *drawColor;
+@property (nonatomic,retain) NSImage *drawImage;
+@property (nonatomic,assign) float strokeRadius;
+
+@property (nonatomic,assign) BOOL isAcceptsTouch;
+
+@property (nonatomic,retain) NSBezierPath *drawBezierPath;
+
+- (void)clearImage;
+
+- (NSImage *)signatureImage;
+
+@property (nonatomic,copy) void (^changeDrawCallback) (BOOL isTure);
+
+@end

+ 424 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMDrawView.m

@@ -0,0 +1,424 @@
+//
+//  KMDrawView.m
+//  PDF Reader
+//
+//  Created by lxy on 2023/1/10.
+//
+
+#import "KMDrawView.h"
+
+static NSInteger _index;
+static CGPoint _points[5];
+
+@interface KMDrawView ()
+
+@property (nonatomic,assign) BOOL cursorIsHidden;
+@property (nonatomic,assign) BOOL mouseIsInView;
+
+@property (nonatomic,retain) NSTouch *activeTouch;
+
+@property (nonatomic,retain) NSBezierPath *bezierPath;
+
+@end
+
+@implementation KMDrawView
+
+- (void)dealloc
+{
+    _delegate = nil;
+}
+
+- (id)initWithFrame:(NSRect)frameRect
+{
+    if (self = [super initWithFrame:frameRect]) {
+        self.drawImage = [[NSImage alloc] initWithSize:self.frame.size];
+        self.drawColor = [NSColor colorWithDeviceRed:0 green:0 blue:0 alpha:1];
+        self.strokeRadius = 0.3;
+        
+        _bezierPath = [[NSBezierPath alloc] init];
+        
+        self.wantsLayer = YES;
+        self.layer.borderWidth = 1.0;
+        self.layer.borderColor =[NSColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.05].CGColor;
+
+    }
+    return self;
+}
+
+- (NSBezierPath *)drawBezierPath {
+    _drawBezierPath = _bezierPath;
+    
+    CGRect rect = self.bezierPath.bounds;
+    NSAffineTransform *transform = [NSAffineTransform transform];
+    [transform translateXBy:- rect.origin.x + +self.bezierPath.lineWidth/2.0 yBy:-rect.origin.y + self.bezierPath.lineWidth/2.0];
+    [_drawBezierPath transformUsingAffineTransform:transform];
+    
+    return _drawBezierPath;
+}
+
+/*
+ ** - (BOOL) acceptsFirstResponder
+ **
+ ** Make sure the view will receive
+ ** events.
+ **
+ ** Input: none
+ **
+ ** Output: YES to accept, NO to reject
+ */
+- (BOOL)acceptsFirstResponder
+{
+    return YES;
+}
+
+- (void)setIsAcceptsTouch:(BOOL)isAcceptsTouch
+{
+    _isAcceptsTouch = isAcceptsTouch;
+    
+    // Accept trackpad events
+    [self setAcceptsTouchEvents:isAcceptsTouch];
+    
+    size_t screenHeight = CGDisplayPixelsHigh(CGMainDisplayID());
+    NSRect frameToWindow = [self convertRect:self.bounds toView:nil];
+    NSRect frameToScreen = [self.window convertRectToScreen:frameToWindow];
+    if (isAcceptsTouch) {
+        // If the mouse cursor is not already hidden,
+        if (!self.cursorIsHidden) {
+            frameToScreen.origin.x = frameToScreen.origin.x+5;
+            frameToScreen.origin.y = screenHeight-frameToScreen.origin.y-5;
+            CGWarpMouseCursorPosition(frameToScreen.origin);
+
+            // Detach the mouse cursor from the mouse
+            // hardware so that moving the mouse (or a
+            // single finger) will not move the cursor
+            CGAssociateMouseAndMouseCursorPosition(false);
+            
+            // Hide the mouse cursor
+            [NSCursor hide];
+            
+            // Remember that we detached and hid the
+            // mouse cursor
+            self.cursorIsHidden = YES;
+        }
+    } else {
+        frameToScreen.origin.y = screenHeight-frameToScreen.origin.y;
+        CGWarpMouseCursorPosition(frameToScreen.origin);
+
+        // Attach the mouse cursor to the mouse
+        // hardware so that moving the mouse (or a
+        // single finger) will move the cursor
+        CGAssociateMouseAndMouseCursorPosition(true);
+        
+        // Show the mouse cursor
+        [NSCursor unhide];
+        
+        // Remember that we attached and unhid the
+        // mouse cursor so that the next touch that
+        // begins will detach and hide it
+        self.cursorIsHidden = NO;
+    }
+}
+
+- (void)clearImage
+{
+    self.drawImage = nil;
+    [self.bezierPath removeAllPoints];
+    [self setNeedsDisplay:YES];
+}
+
+- (void)setDrawColor:(NSColor *)drawColor
+{
+    _drawColor = drawColor;
+    [self setNeedsDisplay:YES];
+}
+
+- (void)setStrokeRadius:(float)strokeRadius
+{
+    _strokeRadius = strokeRadius;
+    [self setNeedsDisplay:YES];
+}
+
+
+- (NSImage *)signatureImage {
+    CGRect rect = CGRectZero;
+
+    if (self.bezierPath.empty) {
+        return nil;
+    } else {
+        rect = self.bezierPath.bounds;
+    }
+    
+    CGSize size = CGSizeMake(rect.size.width+self.bezierPath.lineWidth,
+                             rect.size.height+self.bezierPath.lineWidth);
+    //修改崩溃 “签名,触摸板,再选中左下角触摸板,崩溃了”
+    if (size.width <= 0 && size.height <= 0) {
+        return nil;
+    }
+    NSImage *image = [[NSImage alloc] initWithSize:size];
+    [image lockFocus];
+    
+    [self.drawColor set];
+    [self.drawBezierPath setLineWidth:self.strokeRadius * 2];
+    [self.drawBezierPath setLineCapStyle:kCGLineCapRound];
+    [self.drawBezierPath setLineJoinStyle:kCGLineJoinRound];
+    [self.drawBezierPath stroke];
+
+    [image unlockFocus];
+
+    return image;
+}
+
+#pragma mark Draw
+- (void)drawRect:(NSRect)dirtyRect {
+    [super drawRect:dirtyRect];
+    
+    [NSGraphicsContext saveGraphicsState];
+    [[NSColor clearColor] set];
+
+    if (([[self window] firstResponder] == self) && self.mouseIsInView) {
+        NSSetFocusRingStyle(NSFocusRingAbove);
+    }
+    [[NSBezierPath bezierPathWithRect:[self bounds]] fill];
+    
+    [NSGraphicsContext restoreGraphicsState];
+
+    if (self.drawImage) {
+        CGRect imageFrame = [self imageFrameInRect:dirtyRect];
+        [self.drawImage drawInRect:imageFrame];
+    }
+    
+    [self.drawColor set];
+    [self.bezierPath setLineWidth:self.strokeRadius * 2];
+    [self.bezierPath setLineCapStyle:kCGLineCapRound];
+    [self.bezierPath setLineJoinStyle:kCGLineJoinRound];
+    [self.bezierPath stroke];
+}
+
+- (CGRect)imageFrameInRect:(CGRect)rect {
+    CGRect imageRect;
+    if (self.drawImage.size.width < rect.size.width &&
+        self.drawImage.size.height < rect.size.height) {
+        imageRect.origin.x = (rect.size.width-self.drawImage.size.width)/2.0;
+        imageRect.origin.y = (rect.size.height-self.drawImage.size.height)/2.0;
+        imageRect.size = self.drawImage.size;
+    } else {
+        if (self.drawImage.size.width/self.drawImage.size.height >
+            rect.size.width/rect.size.height) {
+            imageRect.size.width = rect.size.width;
+            imageRect.size.height = rect.size.width*self.drawImage.size.height/self.drawImage.size.width;
+        } else {
+            imageRect.size.height = rect.size.height;
+            imageRect.size.width = rect.size.height*self.drawImage.size.width/self.drawImage.size.height;
+        }
+        imageRect.origin.x = (rect.size.width-imageRect.size.width)/2.0;
+        imageRect.origin.y = (rect.size.height-imageRect.size.height)/2.0;
+    }
+    return imageRect;
+}
+
+#pragma mark Touch
+
+- (void)touchesBeganWithEvent:(NSEvent *)event
+{
+    [super touchesBeganWithEvent:event];
+    
+    NSSet *touches = [event touchesMatchingPhase:NSTouchPhaseBegan inView:self];
+    self.activeTouch = [touches anyObject];
+    
+    CGPoint point = [self.activeTouch normalizedPosition];
+    point.x = point.x * self.bounds.size.width;
+    point.y = point.y * self.bounds.size.height;
+    _index = 0;
+    _points[0] = point;
+    [self setNeedsDisplay:YES];
+    
+    if (!self.cursorIsHidden) {
+        CGAssociateMouseAndMouseCursorPosition(false);
+        
+        [NSCursor hide];
+        self.cursorIsHidden = YES;
+    }
+    
+    if (self.changeDrawCallback) {
+        self.changeDrawCallback(YES);
+    }
+}
+
+- (void)touchesMovedWithEvent:(NSEvent *)event
+{
+    [super touchesMovedWithEvent:event];
+    
+    NSSet *touches = [event touchesMatchingPhase:NSTouchPhaseMoved inView:self];
+    
+    BOOL isTouch = NO;
+    for (NSTouch *touch in touches) {
+        if (touch.identity == self.activeTouch.identity) {
+            isTouch = YES;
+            self.activeTouch = touch;
+        }
+    }
+    
+    if (!isTouch) {
+        return;
+    }
+    
+    NSPoint point = [self.activeTouch normalizedPosition];
+    point.x = point.x * self.bounds.size.width;
+    point.y = point.y * self.bounds.size.height;
+    
+    _index++;
+    _points[_index] = point;
+    
+    if (_index == 4) {
+        _points[3] = CGPointMake((_points[2].x + _points[4].x)/2.0,
+                                 (_points[2].y + _points[4].y)/2.0);
+        [self.bezierPath moveToPoint:_points[0]];
+        
+        [self.bezierPath curveToPoint:_points[3]
+                        controlPoint1:_points[1]
+                        controlPoint2:_points[2] ];
+        _points[0] = _points[3];
+        _points[1] = _points[4];
+        _index = 1;
+        [self setNeedsDisplay:YES];
+    }
+}
+
+- (void)touchesEndedWithEvent:(NSEvent *)event
+{
+    [super touchesEndedWithEvent:event];
+    
+    NSSet *touches = [event touchesMatchingPhase:NSTouchPhaseMoved inView:self];
+    
+    for (NSTouch *touch in touches) {
+        if (touch.identity == self.activeTouch.identity) {
+            self.activeTouch = nil;
+        }
+    }
+    
+    if (_index < 4) {
+        for (int i=0; i<_index; i++) {
+            [self.bezierPath moveToPoint:_points[i]];
+        }
+        [self setNeedsDisplay:YES];
+    }
+    
+//    NSImage *image = [self signatureImage];
+//    if (self.changeDrawCallback) {
+//        self.changeDrawCallback(image);
+//    }
+}
+
+- (void)touchesCancelledWithEvent:(NSEvent *)event
+{
+    [super touchesCancelledWithEvent:event];
+    
+    for (int i=0; i<_index; i++) {
+        [self.bezierPath moveToPoint:_points[i]];
+    }
+    self.activeTouch = nil;
+    [self setNeedsDisplay:YES];
+}
+
+#pragma mark Mouse
+- (void)viewDidMoveToWindow
+{
+    if ([self window] != nil) {
+        [self addTrackingRect:[self bounds]
+                        owner:self
+                     userData:NULL
+                 assumeInside:NO];
+    }
+}
+
+- (void)mouseEntered:(NSEvent *)theEvent
+{
+    [[self window] makeFirstResponder:self];
+
+    self.mouseIsInView = YES;
+    [self setNeedsDisplay:YES];
+}
+
+- (void)mouseExited:(NSEvent *)theEvent
+{
+    self.mouseIsInView = NO;
+    
+    [self setNeedsDisplay:YES];
+}
+
+- (void)mouseDown:(NSEvent *)theEvent
+{
+    if ([self acceptsTouchEvents]) {
+        return;
+    }
+
+    CGPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
+    _index = 0;
+    _points[0] = point;
+}
+
+- (void)mouseDragged:(NSEvent *)theEvent
+{
+    if ([self acceptsTouchEvents]) {
+        return;
+    }
+    
+    NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
+    
+    _index++;
+    _points[_index] = point;
+
+    if (_index == 4) {
+        _points[3] = CGPointMake((_points[2].x + _points[4].x)/2.0,
+                                 (_points[2].y + _points[4].y)/2.0);
+        [self.bezierPath moveToPoint:_points[0]];
+        
+        [self.bezierPath curveToPoint:_points[3]
+                        controlPoint1:_points[1]
+                        controlPoint2:_points[2] ];
+        _points[0] = _points[3];
+        _points[1] = _points[4];
+        _index = 1;
+        [self setNeedsDisplay:YES];
+        
+        if (self.changeDrawCallback) {
+            self.changeDrawCallback(YES);
+        }
+    }
+}
+
+- (void)mouseUp:(NSEvent *)theEvent
+{
+    if ([self acceptsTouchEvents]) {
+        return;
+    }
+    
+    if (_index < 4) {
+        for (int i=0; i<_index; i++) {
+            [self.bezierPath moveToPoint:_points[i]];
+        }
+        [self setNeedsDisplay:YES];
+    }
+}
+
+- (void)keyDown:(NSEvent *)theEvent
+{
+    NSString *chars = [theEvent characters];
+    if(chars.length > 0) {
+        unichar character = [chars characterAtIndex:0];
+        
+        if (character == 27) {
+            if (self.isAcceptsTouch) {
+                self.isAcceptsTouch = NO;
+                if ([self.delegate respondsToSelector:@selector(drawViewDidFinishTouchMode:)]) {
+                    [self.delegate drawViewDidFinishTouchMode:self];
+                }
+                return;
+            }
+        }
+    }
+    
+    [super keyDown:theEvent];
+}
+
+@end

+ 15 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMImageAccessoryController.h

@@ -0,0 +1,15 @@
+//
+//  KMImageAccessoryController.h
+//  PDF Reader Pro Edition
+//
+//  Created by 王帅 on 2017/10/13.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@interface KMImageAccessoryController : NSViewController
+
+@property (nonatomic,assign) IBOutlet NSButton *selectedButton;
+
++ (NSArray *)supportedImageTypes;
+@end

+ 33 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMImageAccessoryController.m

@@ -0,0 +1,33 @@
+//
+//  KMImageAccessoryController.m
+//  PDF Reader Pro Edition
+//
+//  Created by 王帅 on 2017/10/13.
+//
+
+#import "KMImageAccessoryController.h"
+
+@interface KMImageAccessoryController ()
+
+@end
+
+@implementation KMImageAccessoryController
+#pragma mark Public Methods
++ (NSArray *)supportedImageTypes{
+    return [NSArray arrayWithObjects:@"jpg",@"cur",@"bmp",@"jpeg",@"gif",@"png",@"tiff",@"tif",/*@"pic",*/@"ico",@"icns",@"tga",@"psd",@"eps",@"hdr",@"jp2",@"jpc",@"pict",@"sgi",@"pdf", nil];
+}
+
+- (instancetype)init {
+    if (self = [super initWithNibName:@"KMImageAccessoryController" bundle:nil]) {
+        
+    }
+    return self;
+}
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    // Do view setup here.
+    self.selectedButton.title = NSLocalizedString(@"Remove white background from image", nil);
+}
+
+@end

+ 37 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMImageAccessoryController.xib

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13196" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+    <dependencies>
+        <deployment identifier="macosx"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13196"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="KMImageAccessoryController">
+            <connections>
+                <outlet property="selectedButton" destination="qSM-rO-5YK" id="5wp-fD-c58"/>
+                <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
+            </connections>
+        </customObject>
+        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+        <customView id="Hz6-mo-xeY">
+            <rect key="frame" x="0.0" y="0.0" width="362" height="54"/>
+            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+            <subviews>
+                <button translatesAutoresizingMaskIntoConstraints="NO" id="qSM-rO-5YK">
+                    <rect key="frame" x="54" y="18" width="255" height="18"/>
+                    <buttonCell key="cell" type="check" title="Remove white background from image" bezelStyle="regularSquare" imagePosition="left" inset="2" id="hiE-Tr-91o">
+                        <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+                        <font key="font" metaFont="system"/>
+                    </buttonCell>
+                </button>
+            </subviews>
+            <constraints>
+                <constraint firstItem="qSM-rO-5YK" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="20" id="M4M-he-Zs2"/>
+                <constraint firstAttribute="bottom" secondItem="qSM-rO-5YK" secondAttribute="bottom" constant="20" id="QDQ-Ab-hV6"/>
+                <constraint firstItem="qSM-rO-5YK" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="zmx-vP-nse"/>
+            </constraints>
+            <point key="canvasLocation" x="68" y="58"/>
+        </customView>
+    </objects>
+</document>

+ 19 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureImageView.h

@@ -0,0 +1,19 @@
+//
+//  KMPDFSignatureImageView.h
+//  PDF Reader
+//
+//  Created by 丁林圭 on 2018/6/8.
+//  Copyright © 2018年 Kdan Mobile. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@interface KMPDFSignatureImageView : NSView
+
+- (void)clearImage;
+
+- (NSImage *)signatureImage;
+
+@property (nonatomic,copy) void (^changeSignatureImageCallback) (BOOL isTure);
+
+@end

+ 362 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureImageView.m

@@ -0,0 +1,362 @@
+//
+//  KMPDFSignatureImageView.m
+//  PDF Reader
+//
+//  Created by 丁林圭 on 2018/6/8.
+//  Copyright © 2018年 Kdan Mobile. All rights reserved.
+//
+
+#import "KMPDFSignatureImageView.h"
+#import <Quartz/Quartz.h>
+#import "KMImageAccessoryController.h"
+#import "NSButton+TitleColor.h"
+
+#define KMSignatureMaxWidth 400
+#define KMSignatureMaxHeight 300
+
+@interface KMPDFSignatureImageView()
+
+@property (nonatomic,retain) NSImage * picImage;
+@property (nonatomic) IBOutlet NSView *pictureView;
+@property (nonatomic) IBOutlet NSTextField *heraLabel;
+@property (nonatomic) IBOutlet NSTextField *orLabel;
+@property (nonatomic) IBOutlet NSButton *dragButton;
+
+@end
+
+
+@implementation KMPDFSignatureImageView
+
+- (id)initWithFrame:(NSRect)frameRect
+{
+    if (self = [super initWithFrame:frameRect])
+    {
+        self.wantsLayer = YES;
+        self.layer.borderWidth = 1.0;
+        self.layer.borderColor = [NSColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.05].CGColor;
+        self.layer.backgroundColor = [NSColor colorWithRed:1 green:1 blue:1 alpha:0.9].CGColor;;
+        
+        [self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
+        
+    }
+    return self;
+}
+
+-(void)awakeFromNib
+{
+    [super awakeFromNib];
+    
+    self.heraLabel.stringValue  = NSLocalizedString(@"Drop image here", nil);
+    self.heraLabel.textColor = [NSColor labelColor];
+    self.orLabel.stringValue = NSLocalizedString(@"or", nil);
+    self.orLabel.textColor = [NSColor labelColor];
+    self.dragButton.wantsLayer = YES;
+    self.dragButton.title = NSLocalizedString(@"Select a File", nil);
+    [self.dragButton setTitleColor:[NSColor labelColor]];
+//    [self.dragButton.layer addSublayer:[self setGradualChanging]];
+//    self.dragButton.layer.cornerRadius = 3.5;
+}
+
+- (NSArray *)supportedImageTypes
+{
+    return [NSArray arrayWithObjects:@"jpg",@"cur",@"bmp",@"jpeg",@"gif",@"png",@"tiff",@"tif",@"ico",@"icns",@"tga",@"psd",@"eps",@"hdr",@"jp2",@"jpc",@"pict",@"sgi",@"pdf", nil];
+}
+
+-(void)drawRect:(NSRect)dirtyRect
+{
+    [super drawRect:dirtyRect];
+    if (self.pictureView) {
+        
+        CGRect rect = NSZeroRect;
+        CIImage *imageCIImage = [CIImage imageWithData:self.picImage.TIFFRepresentation];
+        NSSize size = [imageCIImage extent].size;
+        
+        CGFloat scale = MIN((dirtyRect.size.width - 30)/size.width, (dirtyRect.size.height - 30)/size.height);
+        if (scale > 1) {
+            rect = CGRectMake(0, 0, size.width, size.height);
+        } else {
+            rect = CGRectMake(0, 0, size.width * scale, size.height *scale);
+        }
+        [self.picImage drawInRect:CGRectMake((dirtyRect.size.width - rect.size.width)/2,
+                                             (dirtyRect.size.height - rect.size.height)/2,
+                                             rect.size.width,rect.size.height)
+                         fromRect:NSZeroRect
+                        operation:NSCompositeSourceOver
+                         fraction:1.0];
+    }
+}
+
+#pragma mark Public
+-(void)clearImage
+{
+    self.picImage = nil;
+    self.pictureView.hidden = NO;
+    [self setNeedsDisplay:YES];
+}
+
+- (NSImage *)signatureImage
+{
+    CGRect rect = CGRectZero;
+    
+    if (!self.picImage) {
+        return nil;
+    } else {
+        CIImage *imageCIImage = [CIImage imageWithData:self.picImage.TIFFRepresentation];
+        NSSize size = [imageCIImage extent].size;
+        CGFloat scale = MIN(KMSignatureMaxWidth/size.width, KMSignatureMaxHeight/size.height);
+        if (scale > 1) {
+            rect = CGRectMake(0, 0, size.width, size.height);
+        } else {
+            rect = CGRectMake(0, 0, size.width * scale, size.height *scale);
+        }
+    }
+    
+    NSImage *image = [[NSImage alloc] initWithSize:rect.size];
+    [image lockFocus];
+    [self.picImage drawInRect:rect
+             fromRect:NSZeroRect
+            operation:NSCompositeSourceOver
+             fraction:1.0];
+
+    [image unlockFocus];
+    return image;
+}
+
+- (void)loadImageViewPath:(NSURL *)url isRemoveBGColor:(BOOL)isRemove
+{
+    NSString * filePath = url.path;
+
+    if ([filePath.pathExtension.lowercaseString isEqualToString:@"pdf"]) {
+        PDFDocument *pdf = [[PDFDocument alloc] initWithURL:url];
+        if (pdf.isEncrypted) {
+            return;
+        }
+    }
+    NSImage *image = [[NSImage alloc] initWithContentsOfFile:filePath];
+    
+    if (isRemove) {
+        NSData *imageData = [image TIFFRepresentation];
+        CGImageRef imageRef;
+        if (imageData) {
+            CGImageSourceRef imageSource = CGImageSourceCreateWithData((CFDataRef)imageData, NULL);
+            imageRef = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL);
+        }
+        
+        const int imageWidth = image.size.width;
+        const int imageHeight = image.size.height;
+        size_t bytesPerRow = imageWidth * 4;
+        uint32_t* rgbImageBuf = (uint32_t*)malloc(bytesPerRow * imageHeight);
+        
+        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+        CGContextRef context = CGBitmapContextCreate(rgbImageBuf,
+                                                     imageWidth,
+                                                     imageHeight,
+                                                     8,
+                                                     bytesPerRow,
+                                                     colorSpace,
+                                                     kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipLast);
+        CGContextDrawImage(context, CGRectMake(0, 0, imageWidth, imageHeight), imageRef);
+        
+        int pixelNum = imageWidth * imageHeight;
+        uint32_t* pCurPtr = rgbImageBuf;
+        for (int i = 0; i < pixelNum; i++, pCurPtr++) {
+            uint8_t* ptr = (uint8_t*)pCurPtr;
+            if (ptr[1] > 240 && ptr[2] > 240 && ptr[3] > 240) {
+                ptr[0] = 0;
+            }
+        }
+        
+        CGDataProviderRef dataProvider = CGDataProviderCreateWithData(NULL, rgbImageBuf, bytesPerRow * imageHeight, nil);
+        imageRef = CGImageCreate(imageWidth,
+                                 imageHeight,
+                                 8,
+                                 32,
+                                 bytesPerRow,
+                                 colorSpace,
+                                 kCGImageAlphaLast |kCGBitmapByteOrder32Little,
+                                 dataProvider,
+                                 NULL,
+                                 true,
+                                 kCGRenderingIntentDefault);
+        CGDataProviderRelease(dataProvider);
+        
+        NSImage *newImage = nil;
+        if (imageRef) {
+            NSRect imageRect = NSMakeRect(0.0, 0.0, 0.0, 0.0);
+            CGContextRef imageContext = nil;
+            
+            // Get the image dimensions.
+            imageRect.size.height = CGImageGetHeight(imageRef);
+            imageRect.size.width = CGImageGetWidth(imageRef);
+            
+            // Create a new image to receive the Quartz image data.
+            newImage = [[NSImage alloc] initWithSize:imageRect.size];
+            [newImage lockFocus];
+            
+            // Get the Quartz context and draw.
+            imageContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
+            CGContextDrawImage(imageContext, *(CGRect*)&imageRect, imageRef);
+            [newImage unlockFocus];
+            CGImageRelease(imageRef);
+        }
+        
+        if (newImage) {
+            image = newImage;
+        }
+    }
+    
+    if (image) {
+        self.picImage = image;
+        self.pictureView.hidden = YES;
+        [self setNeedsDisplay:YES];
+    }
+}
+
+- (CAGradientLayer *)setGradualChanging {
+
+    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
+    gradientLayer.frame = _dragButton.bounds;
+    gradientLayer.colors = @[(__bridge id)[NSColor lightGrayColor].CGColor,(__bridge id)[NSColor whiteColor].CGColor];
+    gradientLayer.startPoint = CGPointMake(0, 0);
+    gradientLayer.endPoint = CGPointMake(1, 1);
+    gradientLayer.locations = @[@0,@1];
+    return gradientLayer;
+}
+
+- (BOOL)isDamageImage:(NSImage *)image imagePath:(NSString *)path {
+    NSString *addImageAnnotation = [[[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier] stringByAppendingPathComponent:@"addImageAnnotation"];
+    if (![[NSFileManager defaultManager] fileExistsAtPath:addImageAnnotation]) {
+        [[NSFileManager defaultManager] createDirectoryAtPath:addImageAnnotation withIntermediateDirectories:NO attributes:nil error:nil];
+    }
+    NSData *data = [image TIFFRepresentation];
+    NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:data];
+    [imageRep setSize:[image size]];
+    NSData *imageData  = nil;
+    if ([path.lowercaseString isEqualToString:@"png"]) {
+        imageData = [imageRep representationUsingType:NSBitmapImageFileTypePNG properties:@{}];
+    } else {
+        imageData = [imageRep representationUsingType:NSJPEGFileType properties:@{}];
+    }
+    
+    NSString *rPath = [addImageAnnotation stringByAppendingPathComponent:[[self tagString] stringByAppendingPathExtension:@"png"]];
+    if (![imageData writeToFile:rPath atomically:YES]) {
+        return YES;
+    } else {
+        return NO;
+    }
+}
+
+- (NSString *)tagString {
+    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
+    dateFormatter.dateFormat    = @"yyMMddHHmmss";
+    return [NSString stringWithFormat:@"%@%04d", [dateFormatter stringFromDate:[NSDate date]], rand()%10000];
+}
+
+
+#pragma mark - Button Action
+- (IBAction)buttonItemClick_SelectPhoto:(id)sender
+{
+    NSOpenPanel *openPanel = [NSOpenPanel openPanel];
+    
+    [openPanel setAllowedFileTypes:[self supportedImageTypes]];
+    KMImageAccessoryController *accessoryCtr = [[KMImageAccessoryController alloc] init];
+    [openPanel setAllowedFileTypes:[KMImageAccessoryController supportedImageTypes]];
+    [openPanel setAccessoryView:accessoryCtr.view];
+    if ([openPanel respondsToSelector:@selector(setAccessoryViewDisclosed:)]) {
+        [openPanel setAccessoryViewDisclosed:YES];
+    }
+    [openPanel setAllowsMultipleSelection:NO];
+    [openPanel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger result) {
+        if (result == NSFileHandlingPanelOKButton) {
+            
+            BOOL isRemoveBGColor = ([accessoryCtr.selectedButton state] == NSOnState);
+
+            NSURL *url = [openPanel URL];
+            
+            //判断PDF文件是否已损坏
+            NSString * filePath = url.path;
+            if ([filePath.pathExtension.lowercaseString isEqualToString:@"pdf"]) {
+                PDFDocument *pdf = [[PDFDocument alloc] initWithURL:url];
+                if (!pdf) {
+                    NSAlert *alert = [[NSAlert alloc] init];
+                    [alert setAlertStyle:NSCriticalAlertStyle];
+                    [alert setMessageText:[NSString stringWithFormat:@"%@",NSLocalizedString(@"An error occurred while opening this document. The file is damaged and could not be repaired.", nil)]];
+                    [alert runModal];
+                    return;
+                }
+            }
+            
+            NSImage *image = [[NSImage alloc] initWithContentsOfFile:url.path];
+            if ([self isDamageImage:image imagePath:url.path]) {
+                NSAlert *alert = [[NSAlert alloc] init];
+                [alert setAlertStyle:NSCriticalAlertStyle];
+                [alert setMessageText: [NSString stringWithFormat:NSLocalizedString(@"The file \"%@\" could not be opened.", nil), url.path.lastPathComponent]];
+                [alert setInformativeText:NSLocalizedString(@"It may be damaged or use a file format that PDF Reader Pro doesn’t recognize.", nil)];
+                [alert addButtonWithTitle:NSLocalizedString(@"Cancel", nil)];
+                [alert beginSheetModalForWindow:[NSApp mainWindow] completionHandler:^(NSModalResponse returnCode) {
+                        if (returnCode == NSAlertFirstButtonReturn) {
+
+                        }
+                }];
+
+                return;
+            }
+            
+            [self loadImageViewPath:url isRemoveBGColor:isRemoveBGColor];
+            if (self.changeSignatureImageCallback) {
+                self.changeSignatureImageCallback(YES);
+            }
+        }
+    }];
+}
+
+- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender
+{
+    NSPasteboard *pboard = [sender draggingPasteboard];
+    if ([pboard availableTypeFromArray:[NSArray arrayWithObject:NSFilenamesPboardType]]) {
+        NSArray *fileNames = [pboard propertyListForType:NSFilenamesPboardType];
+        if (fileNames.count == 1) {
+            NSArray *supportArray= [self supportedImageTypes];
+            NSString* path  = fileNames.firstObject;
+            if ([supportArray containsObject:[path.pathExtension lowercaseString]]) {
+                return NSDragOperationEvery;
+            }
+        }
+    }
+    return NSDragOperationNone;
+}
+
+- (BOOL)prepareForDragOperation:(id<NSDraggingInfo>)sender
+{
+    NSPasteboard *pboard = [sender draggingPasteboard];
+    if ([pboard availableTypeFromArray:[NSArray arrayWithObject:NSFilenamesPboardType]]) {
+        NSMutableArray *fileNames = [pboard propertyListForType:NSFilenamesPboardType];
+        
+        if (fileNames.count == 1) {
+            NSArray *supportArray= [self supportedImageTypes];
+            NSString* path  = fileNames.firstObject;
+            
+            //判断PDF文件是否已损坏
+            NSString * filePath = path;
+            if ([filePath.pathExtension.lowercaseString isEqualToString:@"pdf"]) {
+                PDFDocument *pdf = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:path]];
+                if (!pdf) {
+                    NSAlert *alert = [[NSAlert alloc] init];
+                    [alert setAlertStyle:NSCriticalAlertStyle];
+                    [alert setMessageText:[NSString stringWithFormat:@"%@",NSLocalizedString(@"An error occurred while opening this document. The file is damaged and could not be repaired.", nil)]];
+                    [alert runModal];
+                    return NO;
+                }
+            }
+            if ([supportArray containsObject:[path.pathExtension lowercaseString]]) {
+                [self loadImageViewPath:[NSURL fileURLWithPath:path] isRemoveBGColor:NO];
+                if (self.changeSignatureImageCallback) {
+                    self.changeSignatureImageCallback(YES);
+                }
+            }
+        }
+    }
+    return YES;
+}
+
+@end

+ 29 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureTextView.h

@@ -0,0 +1,29 @@
+//
+//  KMPDFSignatureTextView.h
+//  PDF Reader
+//
+//  Created by 丁林圭 on 2018/6/8.
+//  Copyright © 2018年 Kdan Mobile. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+@protocol KMChangeSignatureTextDelegate <NSObject>
+@optional
+- (void)changeSignatureText:(BOOL)isTure;
+
+@end
+
+
+@interface KMPDFSignatureTextView : NSView
+
+@property (nonatomic,retain) NSColor * keyboardColor;
+@property (nonatomic,retain) NSString * fontName;
+@property (nonatomic,assign) id<KMChangeSignatureTextDelegate> delegate;
+
+- (NSImage *)signatureImage;
+
+- (void)clearImage;
+
+@property (nonatomic,copy) void (^changeSignatureTextCallback) (BOOL isTure);
+
+@end

+ 213 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureTextView.m

@@ -0,0 +1,213 @@
+//
+//  KMPDFSignatureTextView.m
+//  PDF Reader
+//
+//  Created by 丁林圭 on 2018/6/8.
+//  Copyright © 2018年 Kdan Mobile. All rights reserved.
+//
+
+#import "KMPDFSignatureTextView.h"
+#import "NSImage+CustomImage.h"
+
+#define kKMSignayureTextMaxFontSize 28.0
+#define kKMSignayureTextMaxWidth 300
+#define kKMSignayureTextEdgeOffset 5
+
+#pragma mark KMVerticallyCenteredSecureTextFieldCell
+
+@interface KMVerticallyCenteredSecureTextFieldCell : NSTextFieldCell
+@end
+@implementation KMVerticallyCenteredSecureTextFieldCell
+
+- (NSRect)adjustedFrameToVerticallyCenterText:(NSRect)frame
+{
+//    NSInteger offset = floor((NSHeight(frame)/2 - ([[self font] ascender] + [[self font] descender])));
+    NSInteger offset = floor((NSHeight(frame)/2 - ([[self font] ascender])));
+    return NSInsetRect(frame, 0.0, offset);
+}
+- (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)editor delegate:(id)delegate event:(NSEvent *)event
+{
+    [super editWithFrame:[self adjustedFrameToVerticallyCenterText:aRect] inView:controlView editor:editor delegate:delegate event:event];
+}
+- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)editor delegate:(id)delegate start:(NSInteger)start length:(NSInteger)length
+{
+    [super selectWithFrame:[self adjustedFrameToVerticallyCenterText:aRect] inView:controlView editor:editor delegate:delegate start:start length:length];
+}
+- (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)view
+{
+    [super drawInteriorWithFrame:
+    [self adjustedFrameToVerticallyCenterText:frame] inView:view];
+}
+
+@end
+
+@interface KMSignayureTextField : NSTextField
+
+@property (nonatomic, retain) NSColor *originalTextColor;
+@end
+
+
+@implementation KMSignayureTextField
+
+- (void)addSubview:(NSView *)view {
+    [super addSubview:view];
+    NSView * view1  =  view.subviews.firstObject;
+    if ([view1 isKindOfClass:[NSTextView class]]) {
+        NSTextView * textview = (NSTextView *)view1;
+        [textview setInsertionPointColor:[NSColor colorWithRed:102.0/255.0 green:102.0/255.0 blue:102.0/255.0 alpha:1.0]];
+    }
+}
+
+@end
+
+
+@interface KMPDFSignatureTextView()
+
+@property (nonatomic) IBOutlet KMSignayureTextField *nameTextFiled;
+
+@property (assign) IBOutlet NSLayoutConstraint *labelWidthLayoutConstraint;
+
+@property (nonatomic) IBOutlet NSBox *verticalLineBox;
+
+@end
+
+@implementation KMPDFSignatureTextView
+
+- (id)initWithFrame:(NSRect)frameRect
+{
+    if (self = [super initWithFrame:frameRect])
+    {
+        self.keyboardColor = [NSColor colorWithDeviceRed:0 green:0 blue:0 alpha:1];
+        
+        self.wantsLayer = YES;
+        self.layer.borderWidth = 1.0;
+        self.layer.borderColor =[NSColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.05].CGColor;
+        self.layer.backgroundColor = [NSColor colorWithRed:1 green:1 blue:1 alpha:0.9].CGColor;
+
+    }
+    return self;
+}
+
+-(void)awakeFromNib
+{
+    [super awakeFromNib];
+    
+//    NSMutableParagraphStyle *paragraphStyle = [[[NSMutableParagraphStyle alloc] init] autorelease];
+//    paragraphStyle.alignment = NSTextAlignmentCenter;
+//
+//    NSAttributedString *att = [[[NSAttributedString alloc] initWithString:NSLocalizedString(@"Sign Here",nil) attributes:@{NSForegroundColorAttributeName:[KMAppearance KMColor_Layout_H2],NSFontAttributeName:[NSFont systemFontOfSize:14.0],                                NSParagraphStyleAttributeName:paragraphStyle}] autorelease];
+//
+//    [self.nameTextFiled.cell setPlaceholderAttributedString:att];
+    self.nameTextFiled.placeholderString = NSLocalizedString(@"Sign Here",nil);
+    self.nameTextFiled.font = [NSFont systemFontOfSize:14.0];
+    [self.verticalLineBox setFillColor:[NSColor blackColor]];
+}
+
+#pragma mark - Public Method
+- (void)clearImage
+{
+    self.nameTextFiled.stringValue = @"";
+}
+
+- (NSImage *)signatureImage
+{
+    CGRect rect = CGRectZero;
+    NSString * string = self.nameTextFiled.stringValue?:@"";
+    CGSize size = [self sizeOfString:string witFontSize:self.nameTextFiled.font];
+    
+    if (size.width == 0) {
+        return nil;
+    } else {
+        rect = CGRectMake(kKMSignayureTextEdgeOffset,kKMSignayureTextEdgeOffset, size.width, size.height);
+    }
+
+    NSImage *image = [[NSImage alloc] initWithSize:CGSizeMake(size.width + kKMSignayureTextEdgeOffset* 2, size.height + kKMSignayureTextEdgeOffset* 2)];
+    [image lockFocus];
+    
+    NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
+    [dictionary setObject:self.nameTextFiled.font forKey:NSFontAttributeName];
+    [dictionary setObject:self.keyboardColor forKey:NSForegroundColorAttributeName];
+    [string drawInRect:rect withAttributes:dictionary];
+    
+    [image unlockFocus];
+    return image;
+}
+
+- (void)setKeyboardColor:(NSColor *)keyboardColor
+{
+    _keyboardColor = keyboardColor;
+    self.nameTextFiled.textColor = keyboardColor;
+}
+
+- (void)setFontName:(NSString *)fontName
+{
+    _fontName = fontName;
+    CGFloat fontSize = 14.0;
+    if (self.nameTextFiled.stringValue.length > 0) {
+        fontSize = kKMSignayureTextMaxFontSize;
+    }
+    NSFont * maxFont = [NSFont fontWithName:_fontName size:fontSize];
+    CGSize size = [self sizeOfString:self.nameTextFiled.stringValue witFontSize:maxFont];
+    
+    CGFloat width = size.width + kKMSignayureTextEdgeOffset * 2;
+    CGFloat scanel = 1.0;
+    
+    scanel = MIN(kKMSignayureTextMaxWidth/width, 60.0/(size.height + 2));
+    
+    NSFont* font = [NSFont fontWithName:_fontName size:fontSize];
+    self.nameTextFiled.font = font;
+}
+
+#pragma mark - NSTextFieldDelegate
+- (void)controlTextDidChange:(NSNotification *)obj
+{
+    NSTextField *textField = (NSTextField*)[obj object];
+    if (textField == self.nameTextFiled) {
+        NSString *string = textField.stringValue.length > 0 ? textField.stringValue : nil;
+        CGFloat fontSize = 14.0;
+        if (string) {
+            fontSize = kKMSignayureTextMaxFontSize;
+        }
+        NSFont * maxFont = [NSFont fontWithName:_fontName size:fontSize];
+        CGSize size = [self sizeOfString:string witFontSize:maxFont];
+        
+        CGFloat width = size.width + kKMSignayureTextEdgeOffset * 2;
+        CGFloat scanel = 1.0;
+        
+        scanel = MIN((self.bounds.size.width - 30)/width, 60.0/(size.height + 2));
+        
+        if (width >= 100) {
+            self.labelWidthLayoutConstraint.constant = width;
+        }
+        NSFont* font = [NSFont fontWithName:_fontName size:fontSize];
+        self.nameTextFiled.font = font;
+        
+        BOOL isTure = textField.stringValue.length > 0 ? YES : NO;
+        if (self.changeSignatureTextCallback) {
+            self.changeSignatureTextCallback(isTure);
+        }
+        if([self.delegate respondsToSelector:@selector(changeSignatureText:)]) {
+            [self.delegate changeSignatureText:isTure];
+        }
+    }
+}
+
+- (NSSize)sizeOfString:(NSString *)string witFontSize:(NSFont *)font
+{
+    NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
+    [dictionary setObject:font forKey:NSFontAttributeName];
+    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
+    [style setAlignment:NSCenterTextAlignment];
+    [dictionary setObject:style forKey:NSParagraphStyleAttributeName];
+    
+    CGSize size = [string boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT)
+                                       options:NSStringDrawingUsesLineFragmentOrigin
+                                    attributes:dictionary].size;
+    
+    return size;
+}
+
+@end
+
+
+

+ 38 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignature.h

@@ -0,0 +1,38 @@
+//
+//  KMSignature.h
+//  PDF Reader
+//
+//  Created by wangshuai on 13-3-20.
+//  Copyright (c) 2013年 zhangjie. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <Cocoa/Cocoa.h>
+
+typedef NS_OPTIONS(NSUInteger, kKMPDFSignatureType) {
+    kKMPDFSignatureType_Ink = 0,
+    kKMPDFSignatureType_Text ,
+    kKMPDFSignatureType_Image,
+};
+
+typedef NS_OPTIONS(NSUInteger, kKMPDFSignature) {
+    kKMPDFSignature_ManagerView = 0,
+    kKMPDFSignature_CreatView ,
+};
+
+@interface KMSignature : NSObject{
+    NSColor *_signatureColor;
+    NSMutableArray *_paths;
+    NSImage *_pathsImage;
+}
+
+@property (nonatomic,strong) NSColor *signatureColor;
+@property (nonatomic,strong) NSMutableArray *paths;
+@property (nonatomic,strong) NSImage *pathsImage;
+@property (nonatomic,assign) kKMPDFSignatureType signatureType;
+
+- (void)addPath:(NSBezierPath*)path;
+- (void)removePath:(NSBezierPath*)path;
+- (void)clearPath;
+
+@end

+ 61 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignature.m

@@ -0,0 +1,61 @@
+//
+//  KMSignature.m
+//  PDF Reader
+//
+//  Created by wangshuai on 13-3-20.
+//  Copyright (c) 2013年 zhangjie. All rights reserved.
+//
+
+#import "KMSignature.h"
+#define kPath_KEY          @"Paths"
+#define kColor_KEY         @"Color"
+#define kImage_KEY         @"Image"
+#define kType_KEY         @"Type"
+
+
+@implementation KMSignature
+@synthesize signatureColor = _signatureColor;
+@synthesize paths = _paths;
+@synthesize pathsImage = _pathsImage;
+
+- (id)init
+{
+    if (self = [super init]) {
+        _signatureColor = [NSColor blackColor];
+        _paths = [[NSMutableArray alloc] init];
+        _pathsImage = [[NSImage alloc] init];
+    }
+    return self;
+}
+
+- (void)addPath:(NSBezierPath*)path
+{
+    [_paths addObject:path];
+}
+
+- (void)removePath:(NSBezierPath*)path
+{
+    [_paths removeObject:path];
+}
+
+- (void)clearPath
+{
+    [_paths removeAllObjects];
+}
+
+- (void)encodeWithCoder:(NSCoder *)enoder {
+    [enoder encodeObject:_paths forKey:kPath_KEY];
+    [enoder encodeObject:_signatureColor forKey:kColor_KEY];
+    [enoder encodeObject:_pathsImage forKey:kImage_KEY];
+    [enoder encodeObject:@(self.signatureType) forKey:kType_KEY];
+}
+
+- (id)initWithCoder:(NSCoder *)decoder {
+    self.paths = [[decoder decodeObjectForKey:kPath_KEY] copy];
+    self.signatureColor = [[decoder decodeObjectForKey:kColor_KEY] copy];
+    self.pathsImage = [[decoder decodeObjectForKey:kImage_KEY] copy];
+    self.signatureType = [[decoder decodeObjectForKey:kType_KEY] integerValue];
+    return self;
+}
+
+@end

+ 285 - 2
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureAnnotationViewController.m

@@ -6,11 +6,108 @@
 //
 
 #import "KMSignatureAnnotationViewController.h"
+#import "KMSignatureWindowController.h"
+#import "KMSignatureManager.h"
+#import "KMButton.h"
+#import "NSMenu+Category.h"
+
+@interface KMSignatureTableRowView : NSTableRowView
+
+@end
+
+@implementation KMSignatureTableRowView
+
+- (instancetype)init {
+    self = [super init];
+    if (self) {
+        [self addTrackingArea];
+    }
+    return self;
+}
+
+- (void)addTrackingArea {
+    NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds options:NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect | NSTrackingActiveAlways |NSTrackingMouseMoved owner:self userInfo:nil];
+    [self addTrackingArea:trackingArea];
+}
+
+- (void)drawSelectionInRect:(NSRect)dirtyRect {
+        NSRect selectionRect = self.bounds;
+        [[NSColor clearColor] setFill];
+         NSBezierPath *selectionPath = [NSBezierPath bezierPathWithRoundedRect:selectionRect xRadius:0 yRadius:0];
+         [selectionPath fill];
+}
+
+- (void)mouseEntered:(NSEvent *)event {
+    [super mouseEntered:event];
+}
+
+@end
+
+#pragma mark - KMSignatureAnnotationTableviewCell
+
+@interface KMSignatureAnnotationTableviewCell : NSTableCellView
+
+@property (weak) IBOutlet NSImageView *signatureImageView;
+@property (weak) IBOutlet KMButton *closeButton;
+
+@property (nonatomic,copy) void (^mouseMoveCallback) (BOOL mouseEntered);
+
+@property (nonatomic,copy) void (^mouseDownCallback) (BOOL downEntered);
+
+@end
+
+@implementation KMSignatureAnnotationTableviewCell
+
+
+- (void)viewDidMoveToWindow {
+    [super viewDidMoveToWindow];
+    if ([self window] != nil) {
+        NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds options:NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect | NSTrackingActiveAlways |NSTrackingMouseMoved owner:self userInfo:nil];
+        [self addTrackingArea:trackingArea];
+    }
+}
+
+- (void)mouseEntered:(NSEvent *)event {
+    [super mouseEntered:event];
+    
+    if (self.mouseMoveCallback) {
+        self.mouseMoveCallback(YES);
+    }
+}
+
+- (void)mouseExited:(NSEvent *)event {
+    [super mouseExited:event];
+    
+    if (self.mouseMoveCallback) {
+        self.mouseMoveCallback(NO);
+    }
+}
+
+- (void)mouseDown:(NSEvent *)event {
+    [super mouseDown:event];
+    
+    if (self.mouseDownCallback) {
+        self.mouseDownCallback(YES);
+    }
+}
+
+- (void)mouseUp:(NSEvent *)event {
+    [super mouseUp:event];
+    
+    if (self.mouseDownCallback) {
+        self.mouseDownCallback(NO);
+    }
+}
+
+@end
 
 @interface KMSignatureAnnotationViewController ()
 @property (weak) IBOutlet NSBox *emptyBox;
 @property (weak) IBOutlet NSTableView *tableView;
 @property (weak) IBOutlet NSTextField *signatureLabel;
+@property (weak) IBOutlet NSTextField *emptyTipLabel;
+@property (weak) IBOutlet NSTextField *emptyMinTipLabel;
+@property (nonatomic,strong) NSMutableArray <KMSignature *>*signatures;
 
 @end
 
@@ -18,11 +115,197 @@
 
 - (void)viewDidLoad {
     [super viewDidLoad];
-   
+    self.signatureLabel.stringValue = NSLocalizedString(@"signature", nil);
+    self.emptyTipLabel.stringValue = NSLocalizedString(@"No signature created", nil);
+    self.emptyMinTipLabel.stringValue = NSLocalizedString(@"No signature created", nil);
+    self.signatures = [[NSMutableArray alloc] init];
+    [self reloadDataSignatures];
+}
+
+
+- (void)tableViewMenu {
+    NSMenu *menu = [[NSMenu alloc] init];
+    NSMenuItem *item = [menu addItemWithTitle:NSLocalizedString(@"Export stamp", nil) action:nil target:self];
+    NSMenu *tSubMenu = [[NSMenu alloc] init];
+    NSMenuItem *tMenuItem = [tSubMenu insertItemWithTitle:NSLocalizedString(@"PNG", @"Menu item title") action:@selector(exportCustomizeStamp:) target:self atIndex:0];
+    tMenuItem.tag = 0;
+    tMenuItem = [tSubMenu insertItemWithTitle:NSLocalizedString(@"JPG", @"Menu item title") action:@selector(exportCustomizeStamp:) target:self atIndex:1];
+    tMenuItem.tag = 1;
+    tMenuItem = [tSubMenu insertItemWithTitle:NSLocalizedString(@"PDF", @"Menu item title") action:@selector(exportCustomizeStamp:) target:self atIndex:2];
+    tMenuItem.tag = 2;
+    item.submenu = tSubMenu;
+    [menu addItem:[NSMenuItem separatorItem]];
+    [menu addItemWithTitle:NSLocalizedString(@"Delete stamp", nil) action:@selector(deleteCustomizeStamp) target:self];
+    [menu addItemWithTitle:NSLocalizedString(@"Delete All stamp", nil) action:@selector(deleteAllCustomizeStamp) target:self];
+    self.tableView.menu = menu;
+}
+
+- (void)tableCellCloseButton_Click:(NSButton *)button {
+    if(button.tag >= 0 && button.tag < self.signatures.count) {
+        KMSignatureManager *signatureManager = [[KMSignatureManager alloc] init];
+        [signatureManager loadAllSignatureList];
+        [signatureManager.sigatureList removeObjectAtIndex:button.tag];
+        [signatureManager saveSingaturesToFile];
+        [self reloadDataSignatures];
+    }
 }
 
 - (IBAction)insertSignatureButton_Click:(id)sender {
-    
+    KMSignatureWindowController *signatureWindowController = [[KMSignatureWindowController alloc] init];
+    [signatureWindowController beginSheetModalForWindow:[NSApp mainWindow] completionHandler:^(KMSignature *signature){
+        if (signature) {
+            [self reloadDataSignatures];
+        }
+    }];
 }
 
+- (void)reloadDataSignatures
+{
+    [self.signatures removeAllObjects];
+    KMSignatureManager *signatureManager = [[KMSignatureManager alloc] init];
+    [signatureManager loadAllSignatureList];
+    [self.signatures addObjectsFromArray:signatureManager.sigatureList];
+    if (_signatures.count > 0) {
+        [self reloadCustomEmptyState:NO];
+        [self tableViewMenu];
+    } else {
+        [self reloadCustomEmptyState:YES];
+        self.tableView.menu = nil;
+    }
+    [self.tableView reloadData];
+}
+
+- (void)reloadCustomEmptyState:(BOOL)isEmpty {
+    if (isEmpty) {
+        self.emptyBox.hidden = NO;
+        self.tableView.hidden = YES;
+    } else {
+        self.emptyBox.hidden = YES;
+        self.tableView.hidden = NO;
+    }
+}
+
+
+//MARK: menu Action
+
+- (void)exportCustomizeStamp:(NSMenuItem *)sender {
+    NSInteger index = self.tableView.clickedRow;
+    NSInteger type = sender.tag;
+    NSImage *image = self.signatures[index].pathsImage;
+    if (type == 0) {
+        NSData *data = image.TIFFRepresentation;
+        NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:data];
+        [imageRep setSize:image.size];
+        NSData *imageData = [imageRep representationUsingType:NSPNGFileType properties:@{}];
+        
+        NSSavePanel *savePanel = [NSSavePanel savePanel];
+        savePanel.allowedFileTypes = @[@"png"];
+        [savePanel beginSheetModalForWindow:[NSApp mainWindow] completionHandler:^(NSInteger result) {
+            if (result) {
+                if ([imageData writeToURL:savePanel.URL atomically:YES]) {
+                    [[NSWorkspace sharedWorkspace] selectFile:savePanel.URL.path
+                                     inFileViewerRootedAtPath:@""];
+                }
+            }
+        }];
+    } else if (type == 1) {
+        NSData *data = image.TIFFRepresentation;
+        NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:data];
+        [imageRep setSize:image.size];
+        NSData *imageData = [imageRep representationUsingType:NSJPEGFileType properties:@{}];
+        
+        NSSavePanel *savePanel = [NSSavePanel savePanel];
+        savePanel.allowedFileTypes = @[@"jpg"];
+        [savePanel beginSheetModalForWindow:[NSApp mainWindow] completionHandler:^(NSInteger result) {
+            if (result) {
+                if ([imageData writeToURL:savePanel.URL atomically:YES]) {
+                    [[NSWorkspace sharedWorkspace] selectFile:savePanel.URL.path
+                                     inFileViewerRootedAtPath:@""];
+                }
+            }
+        }];
+    } else {
+        CPDFDocument *pdf = [[CPDFDocument alloc] init];
+        CPDFPage *page = [[CPDFPage alloc] initWithImage:image];
+        [pdf insertPageObject:page atIndex:pdf.pageCount];
+        
+        NSSavePanel *savePanel = [NSSavePanel savePanel];
+        savePanel.allowedFileTypes = @[@"pdf"];
+        [savePanel beginSheetModalForWindow:[NSApp mainWindow] completionHandler:^(NSInteger result) {
+            if (result) {
+                if ([pdf writeToURL:savePanel.URL]) {
+                    [[NSWorkspace sharedWorkspace] selectFile:savePanel.URL.path
+                                     inFileViewerRootedAtPath:@""];
+                }
+            }
+        }];
+    }
+}
+
+- (void)deleteCustomizeStamp {
+    if(self.tableView.selectedRow >= 0 && self.tableView.selectedRow < self.signatures.count) {
+        KMSignature *signatur = self.signatures[self.tableView.selectedRow];
+        KMSignatureManager *signatureManager = [[KMSignatureManager alloc] init];
+        [signatureManager loadAllSignatureList];
+        [signatureManager.sigatureList removeObjectAtIndex:self.tableView.selectedRow];
+        [signatureManager saveSingaturesToFile];
+        [self reloadDataSignatures];
+    }
+}
+
+- (void)deleteAllCustomizeStamp {
+    KMSignatureManager *signatureManager = [[KMSignatureManager alloc] init];
+    [signatureManager loadAllSignatureList];
+    [signatureManager.sigatureList removeAllObjects];
+    [signatureManager saveSingaturesToFile];
+    [self reloadDataSignatures];
+
+}
+
+#pragma mark - NSTableViewDelegate,NSTableViewDataSource
+
+- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
+    return self.signatures.count;
+}
+
+- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
+    KMSignatureAnnotationTableviewCell *cellView = [tableView makeViewWithIdentifier:@"KMSignatureAnnotationTableviewCell" owner:self];
+    if (row < self.signatures.count) {
+        KMSignature *signature = [self.signatures objectAtIndex:row];
+        cellView.closeButton.hidden = YES;
+
+        cellView.mouseMoveCallback = ^(BOOL mouseEntered) {
+            if (mouseEntered) {
+                cellView.layer.backgroundColor = [NSColor lightGrayColor].CGColor;
+                cellView.closeButton.hidden = NO;
+            } else {
+                cellView.layer.backgroundColor = [NSColor clearColor].CGColor;
+                cellView.closeButton.hidden = YES;
+            }
+        };
+        cellView.wantsLayer = YES;
+        cellView.layer.backgroundColor = [NSColor whiteColor].CGColor;
+        cellView.signatureImageView.image = signature.pathsImage;
+        cellView.closeButton.tag = row;
+        [cellView.closeButton setTarget:self];
+        [cellView.closeButton setAction:@selector(tableCellCloseButton_Click:)];
+        return cellView;
+    }
+    return cellView;
+}
+
+- (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row {
+    KMSignatureTableRowView *rowView = [[KMSignatureTableRowView alloc] init];
+    return rowView;
+}
+
+- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row {
+    return 68;
+}
+
+- (void)tableViewSelectionDidChange:(NSNotification *)notification {
+ 
+}
+
+
 @end

+ 50 - 27
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureAnnotationViewController.xib

@@ -1,14 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21225" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21225"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="KMSignatureAnnotationViewController">
             <connections>
                 <outlet property="emptyBox" destination="ban-ci-oTA" id="WRU-LX-HMX"/>
+                <outlet property="emptyMinTipLabel" destination="vd7-mZ-jin" id="zNH-1P-a0Z"/>
+                <outlet property="emptyTipLabel" destination="Tbj-Oa-HOw" id="Pej-dH-skC"/>
                 <outlet property="signatureLabel" destination="2BZ-Qt-bmp" id="nPE-D6-BMO"/>
                 <outlet property="tableView" destination="c49-OQ-gwo" id="STQ-GZ-BHL"/>
                 <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
@@ -17,7 +19,7 @@
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
         <customView id="Hz6-mo-xeY">
-            <rect key="frame" x="0.0" y="0.0" width="205" height="415"/>
+            <rect key="frame" x="0.0" y="0.0" width="227" height="415"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2BZ-Qt-bmp">
@@ -29,56 +31,76 @@
                     </textFieldCell>
                 </textField>
                 <scrollView autohidesScrollers="YES" horizontalLineScroll="24" horizontalPageScroll="10" verticalLineScroll="24" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jdt-nX-aPc">
-                    <rect key="frame" x="0.0" y="0.0" width="205" height="387"/>
+                    <rect key="frame" x="0.0" y="0.0" width="227" height="387"/>
                     <clipView key="contentView" id="13m-PJ-paS">
-                        <rect key="frame" x="1" y="1" width="203" height="385"/>
+                        <rect key="frame" x="1" y="1" width="225" height="385"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" rowHeight="24" rowSizeStyle="automatic" viewBased="YES" id="c49-OQ-gwo">
-                                <rect key="frame" x="0.0" y="0.0" width="203" height="385"/>
+                                <rect key="frame" x="0.0" y="0.0" width="225" height="385"/>
                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                 <size key="intercellSpacing" width="17" height="0.0"/>
                                 <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
                                 <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
                                 <tableColumns>
-                                    <tableColumn identifier="AutomaticTableColumnIdentifier.0" width="191" minWidth="40" maxWidth="1000" id="q3o-rZ-9zM">
+                                    <tableColumn width="213" minWidth="40" maxWidth="1000" id="Ztp-vn-3l7">
                                         <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
                                             <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
                                             <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
                                         </tableHeaderCell>
-                                        <textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="HvF-VC-07y">
+                                        <textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="JsP-Rz-jrm">
                                             <font key="font" metaFont="system"/>
                                             <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
                                             <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
                                         </textFieldCell>
                                         <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
                                         <prototypeCellViews>
-                                            <tableCellView id="20a-No-z45">
-                                                <rect key="frame" x="8" y="0.0" width="186" height="24"/>
+                                            <tableCellView identifier="KMSignatureAnnotationTableviewCell" id="fFn-fH-aKu" customClass="KMSignatureAnnotationTableviewCell">
+                                                <rect key="frame" x="8" y="0.0" width="208" height="63"/>
                                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                 <subviews>
-                                                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jsX-rN-Gc2">
-                                                        <rect key="frame" x="0.0" y="4" width="186" height="16"/>
-                                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
-                                                        <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="xTy-4M-nSH">
-                                                            <font key="font" usesAppearanceFont="YES"/>
-                                                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                                                            <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                        </textFieldCell>
-                                                    </textField>
+                                                    <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Kd0-QP-Gjv">
+                                                        <rect key="frame" x="42" y="2" width="124" height="59"/>
+                                                        <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="auF-0q-dbs"/>
+                                                    </imageView>
+                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wkT-FA-45w" customClass="KMButton">
+                                                        <rect key="frame" x="166" y="33" width="30" height="30"/>
+                                                        <constraints>
+                                                            <constraint firstAttribute="height" constant="30" id="cgP-ck-Vle"/>
+                                                            <constraint firstAttribute="width" constant="30" id="gWe-jC-Mgj"/>
+                                                        </constraints>
+                                                        <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="KMImageNamePropertybarDeleteStamp" imagePosition="only" alignment="center" state="on" imageScaling="proportionallyDown" inset="2" id="OAa-xF-V5M">
+                                                            <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                                            <font key="font" metaFont="system"/>
+                                                        </buttonCell>
+                                                    </button>
                                                 </subviews>
+                                                <constraints>
+                                                    <constraint firstAttribute="bottom" secondItem="Kd0-QP-Gjv" secondAttribute="bottom" constant="2" id="Aem-kD-eSl"/>
+                                                    <constraint firstAttribute="trailing" secondItem="wkT-FA-45w" secondAttribute="trailing" constant="12" id="FvH-K9-s7b"/>
+                                                    <constraint firstItem="wkT-FA-45w" firstAttribute="leading" secondItem="Kd0-QP-Gjv" secondAttribute="trailing" id="SVc-c6-bka"/>
+                                                    <constraint firstItem="Kd0-QP-Gjv" firstAttribute="centerX" secondItem="fFn-fH-aKu" secondAttribute="centerX" id="TH7-iA-pkE"/>
+                                                    <constraint firstItem="Kd0-QP-Gjv" firstAttribute="top" secondItem="fFn-fH-aKu" secondAttribute="top" constant="2" id="fxS-IY-sce"/>
+                                                    <constraint firstItem="wkT-FA-45w" firstAttribute="top" secondItem="fFn-fH-aKu" secondAttribute="top" id="h8e-dF-wqW"/>
+                                                </constraints>
                                                 <connections>
-                                                    <outlet property="textField" destination="jsX-rN-Gc2" id="aDq-ns-edg"/>
+                                                    <outlet property="closeButton" destination="wkT-FA-45w" id="PSQ-F1-2u6"/>
+                                                    <outlet property="sampleImageView" destination="ODp-k8-Vi6" id="HYR-Md-odn"/>
+                                                    <outlet property="signatureImageView" destination="Kd0-QP-Gjv" id="JuI-Q1-VyK"/>
                                                 </connections>
                                             </tableCellView>
                                         </prototypeCellViews>
                                     </tableColumn>
                                 </tableColumns>
+                                <connections>
+                                    <outlet property="dataSource" destination="-2" id="GY7-tD-O9m"/>
+                                    <outlet property="delegate" destination="-2" id="EjT-ha-jYJ"/>
+                                </connections>
                             </tableView>
                         </subviews>
                     </clipView>
                     <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="Fo9-d3-jJe">
-                        <rect key="frame" x="1" y="119" width="223" height="15"/>
+                        <rect key="frame" x="1" y="371" width="203" height="15"/>
                         <autoresizingMask key="autoresizingMask"/>
                     </scroller>
                     <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="260-7Z-j2a">
@@ -87,7 +109,7 @@
                     </scroller>
                 </scrollView>
                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KUF-xf-qzQ">
-                    <rect key="frame" x="170" y="387" width="20" height="20"/>
+                    <rect key="frame" x="192" y="387" width="20" height="20"/>
                     <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="KMImageNameMainToolbarUp" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="nVD-Gp-kLW">
                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                         <font key="font" metaFont="system"/>
@@ -97,13 +119,13 @@
                     </connections>
                 </button>
                 <box borderType="none" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="ban-ci-oTA">
-                    <rect key="frame" x="10" y="0.0" width="185" height="377"/>
+                    <rect key="frame" x="10" y="0.0" width="207" height="377"/>
                     <view key="contentView" id="dqW-kL-zjA">
-                        <rect key="frame" x="0.0" y="0.0" width="185" height="377"/>
+                        <rect key="frame" x="0.0" y="0.0" width="207" height="377"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ODp-k8-Vi6">
-                                <rect key="frame" x="26" y="160" width="133" height="133"/>
+                                <rect key="frame" x="37" y="160" width="133" height="133"/>
                                 <constraints>
                                     <constraint firstAttribute="width" secondItem="ODp-k8-Vi6" secondAttribute="height" multiplier="1:1" id="exh-Kt-6NO"/>
                                     <constraint firstAttribute="width" constant="133" id="ig1-TA-XMq"/>
@@ -111,7 +133,7 @@
                                 <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="KMImageNameEmptySignature" id="rfd-We-aPr"/>
                             </imageView>
                             <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Tbj-Oa-HOw">
-                                <rect key="frame" x="27" y="134" width="131" height="16"/>
+                                <rect key="frame" x="38" y="134" width="131" height="16"/>
                                 <textFieldCell key="cell" lineBreakMode="clipping" title="No signature created" id="K2k-0V-W78">
                                     <font key="font" metaFont="system"/>
                                     <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -119,7 +141,7 @@
                                 </textFieldCell>
                             </textField>
                             <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vd7-mZ-jin">
-                                <rect key="frame" x="39" y="108" width="107" height="16"/>
+                                <rect key="frame" x="50" y="108" width="107" height="16"/>
                                 <textFieldCell key="cell" lineBreakMode="clipping" title="点击顶部“+”新建" id="Efj-7i-gM3">
                                     <font key="font" metaFont="system"/>
                                     <color key="textColor" name="tertiaryLabelColor" catalog="System" colorSpace="catalog"/>
@@ -158,5 +180,6 @@
     <resources>
         <image name="KMImageNameEmptySignature" width="140" height="140"/>
         <image name="KMImageNameMainToolbarUp" width="20" height="20"/>
+        <image name="KMImageNamePropertybarDeleteStamp" width="12" height="12"/>
     </resources>
 </document>

+ 21 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureManager.h

@@ -0,0 +1,21 @@
+//
+//  KMSignatureManager.h
+//  PDF Reader
+//
+//  Created by wangshuai on 13-3-20.
+//  Copyright (c) 2013年 zhangjie. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "KMSignature.h"
+
+@interface KMSignatureManager : NSObject{
+    NSMutableArray *_signatureList;
+}
+@property (nonatomic,retain) NSMutableArray *sigatureList;
+
+- (void)loadAllSignatureList;
+- (void)addSignature:(KMSignature*)signature;
+- (void)saveSingaturesToFile;
+
+@end

+ 56 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureManager.m

@@ -0,0 +1,56 @@
+//
+//  KMSignatureManager.m
+//  PDF Reader
+//
+//  Created by wangshuai on 13-3-20.
+//  Copyright (c) 2013年 zhangjie. All rights reserved.
+//
+
+#import "KMSignatureManager.h"
+
+@implementation KMSignatureManager
+@synthesize sigatureList = _signatureList;
+
+- (id)init
+{
+    if (self = [super init]) {
+        _signatureList = [[NSMutableArray alloc] init];
+    }
+    return self;
+}
+
+- (void)loadAllSignatureList
+{
+    [_signatureList removeAllObjects];
+    NSString* fileDirectory =[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
+    NSString *filePath = [fileDirectory stringByAppendingPathComponent:@"CPDFOfficeSignatureList"];
+    NSFileManager* fileManager = [NSFileManager defaultManager];
+    if ([fileManager fileExistsAtPath:filePath]) {
+        NSArray* array =  [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
+        NSInteger cnt = [array count];
+        for (int i = 0; i < cnt; i++) {
+            KMSignature *signature = [array objectAtIndex:i];
+            [_signatureList addObject:signature];
+        }
+        array = nil;
+    }
+}
+
+- (void)addSignature:(KMSignature*)signature
+{
+    [_signatureList addObject:signature];
+}
+
+- (void)saveSingaturesToFile
+{
+    NSString* fileDirectory =[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
+    NSString *filePath = [fileDirectory stringByAppendingPathComponent:@"CPDFOfficeSignatureList"];
+    
+    NSFileManager* fileManager = [NSFileManager defaultManager];
+    if (![fileManager fileExistsAtPath:filePath]) {
+        [fileManager createFileAtPath:filePath contents:nil attributes:nil];
+    }
+    [NSKeyedArchiver archiveRootObject:_signatureList toFile:filePath];
+}
+
+@end

+ 16 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.h

@@ -0,0 +1,16 @@
+//
+//  KMSignatureWindowController.h
+//  PDF Reader Premium
+//
+//  Created by wangshuai on 14/12/3.
+//  Copyright (c) 2014年 zhangjie. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#import "KMSignature.h"
+
+@interface KMSignatureWindowController : NSWindowController
+
+- (void)beginSheetModalForWindow:(NSWindow *)window completionHandler:(void (^)(KMSignature *signature))handler;
+
+@end

+ 701 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.m

@@ -0,0 +1,701 @@
+//
+//  KMSignatureWindowController.m
+//  PDF Reader Premium
+//
+//  Created by wangshuai on 14/12/3.
+//  Copyright (c) 2014年 zhangjie. All rights reserved.
+//
+
+#import "KMSignatureWindowController.h"
+#import "KMDrawView.h"
+#import "KMSignatureManager.h"
+#import "NSImage+CustomImage.h"
+#import "KMPDFSignatureImageView.h"
+#import "KMPDFSignatureTextView.h"
+#import "KMPopUpButton.h"
+#import "NSMenu+Category.h"
+#import "CPDFListView.h"
+
+static NSMutableArray * recentlyFonts;
+
+#pragma mark KMSignatureColorButton
+@interface KMSignatureColorButton : NSButton
+
+@property (nonatomic,retain) NSColor *circleColor;
+@property (nonatomic,retain) NSImage *drawImage;
+@end
+
+@implementation KMSignatureColorButton
+
+-(void)setCircleColor:(NSColor *)circleColor
+{
+    _circleColor = circleColor;
+    [self setNeedsDisplay:YES];
+}
+
+-(id)initWithCoder:(NSCoder *)coder {
+    if (self == [super initWithCoder:coder]) {
+        self.wantsLayer = YES;
+        self.layer.cornerRadius = 12;
+        self.layer.masksToBounds = YES;
+        self.layer.borderWidth = 1.5;
+    }
+    return self;
+}
+
+-(void)drawRect:(NSRect)rect
+{
+    [super drawRect:rect];
+    if (_circleColor) {
+        NSBezierPath *path3 = [NSBezierPath bezierPathWithOvalInRect:NSMakeRect(3, 3, rect.size.width - 6,  rect.size.height - 6)];
+        [self.circleColor set];
+        [path3 fill];
+    } else if (self.drawImage) {
+        [self.drawImage drawInRect:CGRectMake(3,3,rect.size.width -6,rect.size.height - 6)
+                         fromRect:NSZeroRect
+                        operation:NSCompositeSourceOver
+                          fraction:1.0];
+    }
+}
+
+@end
+
+
+#pragma mark KMSignatureButton
+@interface KMSignatureButton : NSButton
+
+@end
+
+@implementation KMSignatureButton
+
+- (NSMenu*)menuForEvent:(NSEvent *)theEvent
+{
+    NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
+    NSMenuItem *item = [menu addItemWithTitle:NSLocalizedString(@"Delete", nil) action:@selector(delete) keyEquivalent:@""];
+    item.target = self;
+    
+    item = [menu addItemWithTitle:NSLocalizedString(@"Export", @"Menu item title") action:nil keyEquivalent:@""];
+    
+    NSMenu * tSubMenu = [[NSMenu alloc] init];
+    
+    NSMenuItem *tMenuItem = [tSubMenu insertItemWithTitle:NSLocalizedString(@"PNG", @"Menu item title") action:@selector(export:) target:self atIndex:0];
+    tMenuItem.tag = 0;
+    
+    tMenuItem = [tSubMenu insertItemWithTitle:NSLocalizedString(@"JPG", @"Menu item title") action:@selector(export:) target:self atIndex:1];
+    tMenuItem.tag = 1;
+
+    tMenuItem = [tSubMenu insertItemWithTitle:NSLocalizedString(@"PDF", @"Menu item title") action:@selector(export:) target:self atIndex:2];
+    tMenuItem.tag = 2;
+    
+    item.submenu = tSubMenu;
+    
+    return menu;
+}
+
+- (void)delete
+{
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"kKMSignatureDeleteNotification" object:[NSNumber numberWithInteger:self.tag]];
+}
+
+- (void)export:(NSMenuItem *)sender
+{
+    NSInteger index = self.tag;
+    NSInteger type = sender.tag;
+    
+    KMSignatureManager *signatureManager = [[KMSignatureManager alloc] init];
+    [signatureManager loadAllSignatureList];
+    KMSignature *signature = signatureManager.sigatureList[index];
+    NSImage *image = signature.pathsImage;
+    
+    if (type == 0) {
+        NSData *data = image.TIFFRepresentation;
+        NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:data];
+        [imageRep setSize:image.size];
+        NSData *imageData = [imageRep representationUsingType:NSPNGFileType properties:@{}];
+        
+        NSSavePanel *savePanel = [NSSavePanel savePanel];
+        savePanel.allowedFileTypes = @[@"png"];
+        [savePanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
+            if (result) {
+                if ([imageData writeToURL:savePanel.URL atomically:YES]) {
+                    [[NSWorkspace sharedWorkspace] selectFile:savePanel.URL.path
+                                     inFileViewerRootedAtPath:@""];
+                }
+            }
+        }];
+    } else if (type == 1) {
+        NSData *data = image.TIFFRepresentation;
+        NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:data];
+        [imageRep setSize:image.size];
+        NSData *imageData = [imageRep representationUsingType:NSJPEGFileType properties:@{}];
+        
+        NSSavePanel *savePanel = [NSSavePanel savePanel];
+        savePanel.allowedFileTypes = @[@"jpg"];
+        [savePanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
+            if (result) {
+                if ([imageData writeToURL:savePanel.URL atomically:YES]) {
+                    [[NSWorkspace sharedWorkspace] selectFile:savePanel.URL.path
+                                     inFileViewerRootedAtPath:@""];
+                }
+            }
+        }];
+    } else {
+        CPDFDocument *pdf = [[CPDFDocument alloc] init];
+        CPDFPage *page = [[CPDFPage alloc] initWithImage:image];
+        [pdf insertPageObject:page atIndex:pdf.pageCount];
+        
+        NSSavePanel *savePanel = [NSSavePanel savePanel];
+        savePanel.allowedFileTypes = @[@"pdf"];
+        [savePanel beginSheetModalForWindow:[NSApp mainWindow] completionHandler:^(NSInteger result) {
+            if (result) {
+                if ([pdf writeToURL:savePanel.URL]) {
+                    [[NSWorkspace sharedWorkspace] selectFile:savePanel.URL.path
+                                     inFileViewerRootedAtPath:@""];
+                }
+            }
+        }];
+    }
+}
+
+@end
+
+#pragma mark KMSignatureWindowController
+@interface KMSignatureWindowController () <KMDrawViewDelegate,KMChangeSignatureTextDelegate>
+
+@property (weak) IBOutlet NSButton    *cancelBtton;
+@property (weak) IBOutlet NSButton    *applyButton;
+@property (weak) IBOutlet NSButton    *clearButton;
+@property (weak) IBOutlet NSButton *inputButton;
+@property (weak) IBOutlet NSButton *drawingButton;
+@property (weak) IBOutlet NSButton *pictureButton;
+@property (weak) IBOutlet NSBox *contentBox;
+@property (strong) IBOutlet NSView *inputView;
+@property (strong) IBOutlet NSView *drawingView;
+@property (strong) IBOutlet NSView *pictureView;
+
+@property (weak) IBOutlet KMPDFSignatureTextView *keyboardView;
+@property (weak) IBOutlet NSPopUpButton *fontBox;
+@property (weak) IBOutlet KMSignatureColorButton    *textBlackColorButton;
+@property (weak) IBOutlet KMSignatureColorButton    *textBlueColorButton;
+@property (weak) IBOutlet KMSignatureColorButton    *textPurpleColorButton;
+@property (weak) IBOutlet KMSignatureColorButton    *textGreenColorButton;
+@property (weak) IBOutlet KMSignatureColorButton    *textOrangeColorButton;
+@property (weak) IBOutlet KMSignatureColorButton    *textRedColorButton;
+@property (weak) IBOutlet KMSignatureColorButton *textColorButton;
+
+
+@property (weak) IBOutlet KMDrawView  *drawView;
+@property (weak) IBOutlet NSButton    *trackpadButton;
+@property (weak) IBOutlet NSSlider *slider;
+
+@property (weak) IBOutlet KMSignatureColorButton    *mouseBlackColorButton;
+@property (weak) IBOutlet KMSignatureColorButton    *mouseBlueColorButton;
+@property (weak) IBOutlet KMSignatureColorButton    *mousePurpleColorButton;
+@property (weak) IBOutlet KMSignatureColorButton    *mouseGreenColorButton;
+@property (weak) IBOutlet KMSignatureColorButton    *mouseOrangeColorButton;
+@property (weak) IBOutlet KMSignatureColorButton    *mouseRedColorButton;
+@property (weak) IBOutlet KMSignatureColorButton *mouseColorButton;
+
+@property (weak) IBOutlet KMPDFSignatureImageView *pictureBackView;
+
+@property (weak) IBOutlet NSTextField *trackpadLabel;
+@property (weak) IBOutlet NSTextField *widthSizeTextField;
+
+@property (nonatomic,strong) KMSignature   *selectedSignature;
+@property (nonatomic,strong) NSMenuItem *selectItem;
+@property (nonatomic,assign) kKMPDFSignatureType   type;
+@property (nonatomic,copy)  void (^handler)(KMSignature*);
+
+@end
+
+@implementation KMSignatureWindowController
+
+- (id)init
+{
+    if (self = [super initWithWindowNibName:@"KMSignatureWindowController"]) {
+
+    }
+    return self;
+}
+
+- (void)dealloc
+{
+    _drawView.delegate = nil;
+    _keyboardView.delegate = nil;
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+    [[NSColorPanel sharedColorPanel] setTarget:nil];
+    [[NSColorPanel sharedColorPanel] setAction:nil];
+}
+
+#pragma mark - View Methods
+
+- (void)windowDidLoad {
+    [super windowDidLoad];
+    
+    self.type = kKMPDFSignatureType_Text;
+    
+    self.textBlackColorButton.circleColor = self.mouseBlackColorButton.circleColor = [NSColor blackColor];
+    
+    self.textRedColorButton.circleColor =
+    self.mouseRedColorButton.circleColor = [NSColor colorWithRed:221.0f/255.0f green:2.0f/255.0f blue:2.0f/255.0f alpha:1.0f];
+    
+    self.textBlueColorButton.circleColor =
+    self.mouseBlueColorButton.circleColor  = [NSColor colorWithRed:0.0 green:52.0/255.0 blue:146.0/255.0 alpha:1.0];
+    
+    self.textGreenColorButton.circleColor =
+    self.mouseGreenColorButton.circleColor = [NSColor colorWithRed:39.0f/255.0f green:190.0f/255.0f blue:253.0f/255.0f alpha:1.0f];
+    
+    self.textOrangeColorButton.circleColor =
+    self.mouseOrangeColorButton.circleColor = [NSColor colorWithRed:253.0f/255.0f green:126.0f/255.0f blue:21.0f/255.0f alpha:1.0f];
+    
+    self.textPurpleColorButton.circleColor =
+    self.mousePurpleColorButton.circleColor = [NSColor colorWithRed:100.0/255.0 green:13.0/255.0 blue:168.0/255.0 alpha:1.0];
+    
+    self.textColorButton.drawImage = self.mouseColorButton.drawImage = [NSImage imageNamed:@"view_color"];
+    
+    self.widthSizeTextField.backgroundColor = [NSColor labelColor];
+    self.widthSizeTextField.wantsLayer = YES;
+    self.widthSizeTextField.layer.borderWidth = 0;
+    
+    [self localizedString];
+    
+    [self.cancelBtton setTarget:self];
+    [self.cancelBtton setAction:@selector(dismissSheet:)];
+    
+    [self.clearButton setTarget:self];
+    [self.clearButton setAction:@selector(clearButton_Click:)];
+    
+    self.applyButton.enabled = NO;
+    [self.applyButton setTarget:self];
+    [self.applyButton setAction:@selector(applyButton_Click:)];
+    
+    self.keyboardView.wantsLayer = YES;
+    self.keyboardView.layer.backgroundColor = [NSColor whiteColor].CGColor;
+    self.drawView.delegate = self;
+    self.drawView.wantsLayer = YES;
+    self.drawView.layer.backgroundColor = [NSColor whiteColor].CGColor;
+    self.pictureBackView.wantsLayer = YES;
+    self.pictureBackView.layer.backgroundColor = [NSColor whiteColor].CGColor;
+    
+    
+    [self.trackpadLabel setHidden:YES];
+    
+    _slider.floatValue = self.drawView.strokeRadius;
+    _widthSizeTextField.stringValue = [NSString stringWithFormat:@"%.1f",self.drawView.strokeRadius];
+    
+    __block typeof(self) blockSelf = self;
+    self.keyboardView.delegate = self;
+    self.drawView.changeDrawCallback = ^(BOOL isTure) {
+        if (isTure) {
+            blockSelf.applyButton.enabled = YES;
+        } else {
+            blockSelf.applyButton.enabled = NO;
+        }
+    };
+    self.pictureBackView.changeSignatureImageCallback = ^(BOOL isTure) {
+        if (isTure) {
+            blockSelf.applyButton.enabled = YES;
+        } else {
+            blockSelf.applyButton.enabled = NO;
+        }
+    };
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(widthSizeTextFieldNotification:) name:NSControlTextDidChangeNotification object:_widthSizeTextField];
+    
+    self.inputButton.bordered =
+    self.drawingButton.bordered =
+    self.pictureButton.bordered = YES;
+    [self inputButton_Click:nil];
+}
+
+#pragma mark - Private Methods
+
+-(void)localizedString
+{
+
+    [self.trackpadButton setTitle:NSLocalizedString(@"Trackpad", nil)];
+    [self.cancelBtton setTitle:NSLocalizedString(@"Cancel",nil)];
+    [self.applyButton setTitle:NSLocalizedString(@"Save", nil)];
+    [self.clearButton setTitle:NSLocalizedString(@"Clear", nil)];
+    [self.trackpadLabel setStringValue:NSLocalizedString(@"Press \"esc\" to disable the Trackpad.", nil)];
+    
+    NSArray *seletorFonts = @[@"Mistral", @"Bradley Hand", @"Brush Script MT", @"SignPainter", @"Edwardian Script ITC", @"American Typewriter",@"Baoli SC",@"Snell Roundhand", @"Apple Chancery", @"Monotype Corsiva"];
+    
+    NSArray *fonts = [[NSFontManager sharedFontManager] availableFontFamilies];
+    for (NSString *fontName in fonts) {
+        NSDictionary *attrited = @{NSFontAttributeName:[NSFont fontWithName:fontName size:12.0]};
+        NSAttributedString *string = [[NSAttributedString alloc] initWithString:fontName attributes:attrited];
+        NSMenuItem *item = [[NSMenuItem alloc] init];
+        item.attributedTitle = string;
+        [self.fontBox.menu addItem:item];
+    }
+    
+    NSString * fontName = nil;
+    
+    if (!recentlyFonts) {
+        recentlyFonts = [[NSMutableArray alloc] init];
+    }
+    if (recentlyFonts.count < 1) {
+        for (NSString *name in seletorFonts) {
+            if ([fonts containsObject:name]) {
+                fontName = name;
+                break;
+            }
+        }
+        if (fontName) {
+            [recentlyFonts addObject:fontName];
+        }
+    } else {
+        fontName = recentlyFonts.firstObject;
+    }
+    
+    if ([fonts containsObject:fontName]) {
+        self.keyboardView.fontName = fontName;
+        [self.fontBox setTitle:fontName];
+    } else {
+        self.keyboardView.fontName = fonts.firstObject;
+        [self.fontBox setTitle:fonts.firstObject];
+    }
+    
+    for (NSInteger i = 0; i<recentlyFonts.count; i++) {
+        NSString *fontName  = recentlyFonts[i];
+        NSDictionary *attrited = @{NSFontAttributeName:[NSFont fontWithName:fontName size:12.0]};
+        NSAttributedString *string = [[NSAttributedString alloc] initWithString:fontName attributes:attrited];
+        NSMenuItem *item = [[NSMenuItem alloc] init];
+        item.attributedTitle = string;
+        [self.fontBox.menu insertItem:item atIndex:1 + i];
+    }
+    NSMenuItem *sep = [NSMenuItem separatorItem];
+    [self.fontBox.menu  insertItem:sep atIndex:(recentlyFonts.count)+1];
+    
+    self.selectItem=  [self.fontBox.menu itemAtIndex:1];
+    self.selectItem.state = NSOnState;
+    [self.inputButton setTitle:NSLocalizedString(@"Input", nil)];
+    [self.drawingButton setTitle:NSLocalizedString(@"Drawing", nil)];
+    [self.pictureButton setTitle:NSLocalizedString(@"Picture", nil)];
+    
+    [self colorInkButtonAction:self.mouseBlackColorButton];
+    [self colorTextButtonAction:self.textBlackColorButton];
+}
+
+#pragma mark Button Mehtods
+
+- (IBAction)inputButton_Click:(id)sender {
+    self.inputButton.bordered = YES;
+    self.drawingButton.bordered =
+    self.pictureButton.bordered = NO;
+    self.contentBox.contentView = self.inputView;
+    self.type = kKMPDFSignatureType_Text;
+}
+- (IBAction)drawingButton_Click:(id)sender {
+    self.drawingButton.bordered = YES;
+    self.inputButton.bordered =
+    self.pictureButton.bordered = NO;
+    self.contentBox.contentView = self.drawingView;
+    self.type = kKMPDFSignatureType_Ink;
+}
+
+- (IBAction)pictureButton_Click:(id)sender {
+    self.pictureButton.bordered = YES;
+    self.inputButton.bordered =
+    self.drawingButton.bordered = NO;
+    self.contentBox.contentView = self.pictureView;
+    self.type = kKMPDFSignatureType_Image;
+}
+
+- (void)clearButton_Click:(id)sender
+{
+    if (kKMPDFSignatureType_Image == self.type) {
+        [self.pictureBackView clearImage];
+    } else if (kKMPDFSignatureType_Ink == self.type) {
+        [self.drawView clearImage];
+    }else if (kKMPDFSignatureType_Text == self.type) {
+        [self.keyboardView clearImage];
+    }
+    
+    self.applyButton.enabled = NO;
+}
+
+- (void)applyButton_Click:(id)sender
+{
+    KMSignature *signature = [[KMSignature alloc] init];
+
+    if (kKMPDFSignatureType_Text == self.type) {
+        NSImage *image = [self.keyboardView signatureImage];
+        
+        if (!image) {
+            NSAlert *alert = [[NSAlert alloc] init];
+            [alert setAlertStyle:NSCriticalAlertStyle];
+            [alert setMessageText:NSLocalizedString(@"Unable to add new signatures. Please try again.",nil)];
+            [alert runModal];
+            return;
+        }
+        
+        signature.pathsImage = image;
+        signature.signatureType = kKMPDFSignatureType_Text;
+        KMSignatureManager *signatureManager = [[KMSignatureManager alloc] init];
+        [signatureManager loadAllSignatureList];
+        [signatureManager addSignature:signature];
+        [signatureManager saveSingaturesToFile];
+    } else if(kKMPDFSignatureType_Image == self.type) {
+        NSImage *image = [self.pictureBackView signatureImage];
+        
+        if (!image) {
+            NSAlert *alert = [[NSAlert alloc] init];
+            [alert setAlertStyle:NSCriticalAlertStyle];
+            [alert setMessageText:NSLocalizedString(@"Unable to add new signatures. Please try again.",nil)];
+            [alert runModal];
+            return;
+        }
+        
+        signature.pathsImage = image;
+        signature.signatureType = kKMPDFSignatureType_Image;
+
+        KMSignatureManager *signatureManager = [[KMSignatureManager alloc] init];
+        [signatureManager loadAllSignatureList];
+        [signatureManager addSignature:signature];
+        [signatureManager saveSingaturesToFile];
+
+    } else {
+        NSImage *image = [self.drawView signatureImage];
+        
+        if (!image) {
+            NSAlert *alert = [[NSAlert alloc] init];
+            [alert setAlertStyle:NSCriticalAlertStyle];
+            [alert setMessageText:NSLocalizedString(@"Unable to add new signatures. Please try again.",nil)];
+            [alert runModal];
+            return;
+        }
+        
+        [signature addPath:self.drawView.drawBezierPath];
+        signature.signatureType = kKMPDFSignatureType_Ink;
+        signature.signatureColor = self.drawView.drawColor;
+        signature.pathsImage = image;
+        KMSignatureManager *signatureManager = [[KMSignatureManager alloc] init];
+        [signatureManager loadAllSignatureList];
+        [signatureManager addSignature:signature];
+        [signatureManager saveSingaturesToFile];
+    }
+    self.selectedSignature = signature;
+    [self dismissSheet:nil];
+}
+
+- (IBAction)trackpadButton_Click:(id)sender
+{
+    if (self.trackpadButton.cell.state) {
+        [self.trackpadLabel setHidden:NO];
+        self.drawView.isAcceptsTouch = YES;
+    } else {
+        [self.trackpadLabel setHidden:YES];
+        self.drawView.isAcceptsTouch = NO;
+    }
+}
+
+- (IBAction)boxItemClicked_Font:(id)sender
+{
+    NSString * name = self.fontBox.selectedItem.title;
+    self.fontBox.title = name;
+    self.keyboardView.fontName = name;
+
+    if ([recentlyFonts containsObject:name]) {
+        NSInteger index = [recentlyFonts indexOfObject:name];
+        [recentlyFonts removeObject:name];
+        [self.fontBox.menu removeItemAtIndex:index +1];
+        
+    }
+    if (recentlyFonts.count >0) {
+        [recentlyFonts insertObject:name atIndex:0];
+    } else {
+        [recentlyFonts addObject:name];
+    }
+
+    if (recentlyFonts.count >5) {
+        [recentlyFonts removeLastObject];
+        [self.fontBox.menu removeItemAtIndex:recentlyFonts.count];
+    }
+
+    NSDictionary *attrited = @{NSFontAttributeName:[NSFont fontWithName:name size:12.0]};
+    NSAttributedString *string = [[NSAttributedString alloc] initWithString:name attributes:attrited];
+    NSMenuItem *item = [[NSMenuItem alloc] init];
+    item.attributedTitle = string;
+    [self.fontBox.menu  insertItem:item atIndex:1];
+    
+    self.selectItem.state = NSOffState;
+    self.selectItem =  [self.fontBox.menu itemAtIndex:1];
+    self.selectItem.state = NSOnState;
+}
+
+- (IBAction)slider_Change:(id)sender
+{
+    self.drawView.strokeRadius = self.slider.floatValue;
+    
+    _widthSizeTextField.stringValue = [NSString stringWithFormat:@"%.1f",self.slider.floatValue];
+}
+
+- (IBAction)colorTextButtonAction:(KMSignatureColorButton *)sender {
+    if (sender.tag != 6) {
+        self.textBlackColorButton.layer.borderColor =
+        self.textRedColorButton.layer.borderColor =
+        self.textBlueColorButton.layer.borderColor =
+        self.textGreenColorButton.layer.borderColor =
+        self.textOrangeColorButton.layer.borderColor =
+        self.textPurpleColorButton.layer.borderColor  =
+        self.textColorButton.layer.borderColor= [NSColor clearColor].CGColor;
+        self.keyboardView.keyboardColor = sender.circleColor;
+        sender.layer.borderColor = [NSColor whiteColor].CGColor;
+    } else {
+        [[NSColorPanel sharedColorPanel] setTarget:self];
+        [[NSColorPanel sharedColorPanel] setAction:@selector(keyboardColorPanelColorDidChange:)];
+        [[NSColorPanel sharedColorPanel] orderFront:nil];
+    }
+}
+
+- (IBAction)colorInkButtonAction:(KMSignatureColorButton *)sender {
+    if (sender.tag != 6) {
+        self.mouseBlackColorButton.layer.borderColor =
+        self.mouseRedColorButton.layer.borderColor =
+        self.mouseBlueColorButton.layer.borderColor =
+        self.mouseGreenColorButton.layer.borderColor =
+        self.mouseOrangeColorButton.layer.borderColor =
+        self.mousePurpleColorButton.layer.borderColor =
+        self.mouseColorButton.layer.borderColor = [NSColor clearColor].CGColor;
+        
+        sender.layer.borderColor = [NSColor whiteColor].CGColor;
+        self.drawView.drawColor = sender.circleColor;
+    } else {
+        [[NSColorPanel sharedColorPanel] setTarget:self];
+        [[NSColorPanel sharedColorPanel] setAction:@selector(ColorPanelColorDidChange:)];
+        [[NSColorPanel sharedColorPanel] orderFront:nil];
+    }
+}
+
+- (void)ColorPanelColorDidChange:(id)sender
+{
+    self.mouseBlackColorButton.layer.borderColor =
+    self.mouseRedColorButton.layer.borderColor =
+    self.mouseBlueColorButton.layer.borderColor =
+    self.mouseGreenColorButton.layer.borderColor =
+    self.mouseOrangeColorButton.layer.borderColor =
+    self.mousePurpleColorButton.layer.borderColor =
+    self.mouseColorButton.layer.borderColor = [NSColor clearColor].CGColor;
+    
+    CGFloat red,green,blue,alpha;
+    NSColor *color = [(NSColorPanel*)sender color];
+    [[color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha];
+    self.drawView.drawColor = color;
+    self.mouseColorButton.layer.borderColor = [NSColor colorWithRed:33.0/255.0 green:124.0/255.0 blue:234.0/255.0 alpha:1.0].CGColor;
+}
+
+- (void)keyboardColorPanelColorDidChange:(id)sender
+{
+    self.textBlackColorButton.layer.borderColor =
+    self.textRedColorButton.layer.borderColor =
+    self.textBlueColorButton.layer.borderColor =
+    self.textGreenColorButton.layer.borderColor =
+    self.textOrangeColorButton.layer.borderColor =
+    self.textPurpleColorButton.layer.borderColor  =
+    self.textColorButton.layer.borderColor= [NSColor clearColor].CGColor;
+    
+    CGFloat red,green,blue,alpha;
+    NSColor *color = [NSColorPanel sharedColorPanel].color ? : [NSColor clearColor];
+    [[color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha];
+    self.keyboardView.keyboardColor = color;
+    self.textColorButton.layer.borderColor = [NSColor colorWithRed:33.0/255.0 green:124.0/255.0 blue:234.0/255.0 alpha:1.0].CGColor;
+}
+
+#pragma mark KMDrawViewDelegate Methods
+
+- (void)drawViewDidFinishTouchMode:(KMDrawView *)view
+{
+    [self.trackpadButton.cell setState:0];
+    [self.trackpadLabel setHidden:YES];
+}
+
+#pragma mark KMChangeSignatureTextDelegate Methods
+
+- (void)changeSignatureText:(BOOL)isTure {
+    self.applyButton.enabled = isTure;
+}
+
+#pragma mark Show Methods
+- (void)didEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
+{
+    if (contextInfo != NULL && self.handler) {
+        self.handler(self.selectedSignature);
+    }
+}
+
+- (void)beginSheetModalForWindow:(NSWindow *)window completionHandler:(void (^)(KMSignature *signature))handler;
+{
+
+    [NSApp beginSheet:[self window]
+       modalForWindow:window
+        modalDelegate:self
+       didEndSelector:@selector(didEndSheet:returnCode:contextInfo:)
+          contextInfo:(__bridge void * _Null_unspecified)(handler ? handler : NULL)];
+    self.handler = handler;
+}
+
+- (void)dismissSheet:(id)sender {
+    if (sender) {
+        [NSApp endSheet:[self window] returnCode:0];
+    } else {
+        [NSApp endSheet:[self window] returnCode:1];
+    }
+    [[self window] orderOut:self];
+}
+
+#pragma mark NSTabViewDelegate Methods
+
+- (BOOL)tabView:(NSTabView *)tabView shouldSelectTabViewItem:(nullable NSTabViewItem *)tabViewItem
+{
+    return YES;
+}
+
+- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem
+{
+    BOOL isImage = NO;
+    if ([tabView indexOfTabViewItem:tabViewItem] == 0) {
+        self.type = kKMPDFSignatureType_Text;
+        if ([self.keyboardView signatureImage]) {
+            isImage = YES;
+        }
+    } else if ([tabView indexOfTabViewItem:tabViewItem] == 1) {
+        self.type = kKMPDFSignatureType_Ink;
+        if ([self.drawView signatureImage]) {
+            isImage = YES;
+        }
+    } else if ([tabView indexOfTabViewItem:tabViewItem] == 2) {
+        self.type = kKMPDFSignatureType_Image;
+        if ([self.pictureBackView signatureImage]) {
+            isImage = YES;
+        }
+    }
+    
+    if (isImage) {
+        self.applyButton.enabled = YES;
+    } else {
+        self.applyButton.enabled = NO;
+    }
+}
+
+#pragma mark - NSNotification
+
+- (void)widthSizeTextFieldNotification:(NSNotification *)notification {
+    NSTextView *field = (NSTextView *)notification.object;
+    
+    if ([field isEqual:_widthSizeTextField]) {
+        CGFloat widthSize = [_widthSizeTextField.stringValue floatValue];
+        if (widthSize < 0.1) {
+            _widthSizeTextField.stringValue = @"0.1";
+            _drawView.strokeRadius = _slider.floatValue = 0.1;
+        } else if (widthSize > 4) {
+            _widthSizeTextField.stringValue = @"4.0";
+            _drawView.strokeRadius = _slider.floatValue = 4.0;
+        } else {
+            _drawView.strokeRadius = _slider.floatValue = widthSize;
+        }
+    }
+}
+
+@end

+ 821 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.xib

@@ -0,0 +1,821 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+    <dependencies>
+        <deployment identifier="macosx"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
+        <capability name="Named colors" minToolsVersion="9.0"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="KMSignatureWindowController">
+            <connections>
+                <outlet property="applyButton" destination="j7L-83-3Ut" id="p88-8o-mie"/>
+                <outlet property="cancelBtton" destination="s0y-mf-WpS" id="3yc-1u-IcY"/>
+                <outlet property="clearButton" destination="9qj-7Y-28D" id="eST-zI-M3J"/>
+                <outlet property="contentBox" destination="Zb7-ur-hyq" id="Bmf-CH-bNp"/>
+                <outlet property="drawView" destination="I2h-gk-zBq" id="Ez8-0k-xcp"/>
+                <outlet property="drawingButton" destination="xyn-sX-pty" id="Cxb-OI-t7I"/>
+                <outlet property="drawingView" destination="uWu-ea-oIZ" id="hWd-AD-3TC"/>
+                <outlet property="fontBox" destination="OX0-YE-NCd" id="tYU-Hj-EeX"/>
+                <outlet property="inputButton" destination="esW-e0-28b" id="zwP-fZ-I1j"/>
+                <outlet property="inputView" destination="NXb-2D-d7x" id="Alx-fs-Zdk"/>
+                <outlet property="keyboardView" destination="y6e-Mr-PoK" id="3bq-wa-eTs"/>
+                <outlet property="mouseBlackColorButton" destination="yuc-HU-IZY" id="RQQ-dM-7pN"/>
+                <outlet property="mouseBlueColorButton" destination="whb-iK-A1H" id="FOk-lR-JSc"/>
+                <outlet property="mouseColorButton" destination="bHb-2B-9IW" id="0QE-5G-VaK"/>
+                <outlet property="mouseGreenColorButton" destination="Hdf-LB-0dV" id="hLt-qI-zb9"/>
+                <outlet property="mouseOrangeColorButton" destination="sYi-rx-eJP" id="RwY-uA-R0G"/>
+                <outlet property="mousePurpleColorButton" destination="TLr-6u-kcz" id="5jh-vc-Kvc"/>
+                <outlet property="mouseRedColorButton" destination="bAs-ex-3wn" id="DUE-ey-NMa"/>
+                <outlet property="pictureBackView" destination="fH0-Z8-dC3" id="2KK-mq-EhE"/>
+                <outlet property="pictureButton" destination="Fjh-hd-6bs" id="1x7-mP-5Sh"/>
+                <outlet property="pictureView" destination="7II-X0-WZi" id="xEa-sy-Cs5"/>
+                <outlet property="slider" destination="sdR-we-Swp" id="uWq-Nf-Yq5"/>
+                <outlet property="textBlackColorButton" destination="3P0-xX-1B0" id="cgg-3s-laT"/>
+                <outlet property="textBlueColorButton" destination="gug-Lh-QIp" id="Vyb-j0-0fd"/>
+                <outlet property="textColorButton" destination="Wn0-74-O2r" id="6tL-ao-Zix"/>
+                <outlet property="textGreenColorButton" destination="j89-oP-egN" id="0Es-uA-Nsd"/>
+                <outlet property="textOrangeColorButton" destination="XIZ-Ha-pW9" id="1d0-hY-sae"/>
+                <outlet property="textPurpleColorButton" destination="i17-eA-DlO" id="SE3-sE-Lu8"/>
+                <outlet property="textRedColorButton" destination="AMW-D1-XIu" id="Fbs-Ze-7qv"/>
+                <outlet property="trackpadButton" destination="pqR-eZ-KlX" id="Kqq-Wp-4Hv"/>
+                <outlet property="trackpadLabel" destination="8sI-6n-jcW" id="Y6D-OK-vX5"/>
+                <outlet property="widthSizeTextField" destination="LsA-Os-ado" id="4nU-Vq-4Sq"/>
+                <outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
+            </connections>
+        </customObject>
+        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+        <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5">
+            <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
+            <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+            <rect key="contentRect" x="196" y="240" width="590" height="423"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
+            <view key="contentView" id="se5-gp-TjO">
+                <rect key="frame" x="0.0" y="0.0" width="590" height="423"/>
+                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                <subviews>
+                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="j7L-83-3Ut">
+                        <rect key="frame" x="491" y="14" width="86" height="39"/>
+                        <constraints>
+                            <constraint firstAttribute="width" constant="80" id="47F-dt-Cbf"/>
+                            <constraint firstAttribute="height" constant="32" id="fom-33-oXa"/>
+                        </constraints>
+                        <buttonCell key="cell" type="bevel" title="Cancel" bezelStyle="regularSquare" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="YKQ-wq-7Ov">
+                            <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                            <font key="font" metaFont="system"/>
+                            <string key="keyEquivalent" base64-UTF8="YES">
+Gw
+</string>
+                        </buttonCell>
+                    </button>
+                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9qj-7Y-28D">
+                        <rect key="frame" x="13" y="14" width="86" height="39"/>
+                        <constraints>
+                            <constraint firstAttribute="width" constant="80" id="2IF-i5-lfc"/>
+                            <constraint firstAttribute="height" constant="32" id="8fV-sG-5BN"/>
+                        </constraints>
+                        <buttonCell key="cell" type="bevel" title="Clear" bezelStyle="regularSquare" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Slu-mR-UaT">
+                            <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                            <font key="font" metaFont="system"/>
+                        </buttonCell>
+                    </button>
+                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="s0y-mf-WpS">
+                        <rect key="frame" x="403" y="14" width="86" height="39"/>
+                        <constraints>
+                            <constraint firstAttribute="width" constant="80" id="jKE-Mm-oCG"/>
+                            <constraint firstAttribute="height" constant="32" id="kRd-WV-Agv"/>
+                        </constraints>
+                        <buttonCell key="cell" type="bevel" title="Cancel" bezelStyle="regularSquare" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="76r-wf-8NT">
+                            <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                            <font key="font" metaFont="system"/>
+                            <string key="keyEquivalent" base64-UTF8="YES">
+Gw
+</string>
+                        </buttonCell>
+                    </button>
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="8sI-6n-jcW">
+                        <rect key="frame" x="126" y="26" width="229" height="16"/>
+                        <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Press &quot;esc&quot; to disable the Trackpad." id="m48-yd-Nf0">
+                            <font key="font" metaFont="system"/>
+                            <color key="textColor" red="0.18823529410000001" green="0.51764705879999995" blue="0.98431372549999996" alpha="1" colorSpace="calibratedRGB"/>
+                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                        </textFieldCell>
+                    </textField>
+                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="uH2-qz-onx">
+                        <rect key="frame" x="13" y="394" width="106" height="16"/>
+                        <textFieldCell key="cell" lineBreakMode="clipping" title="Create Signature" id="R8r-g6-5mF">
+                            <font key="font" metaFont="system"/>
+                            <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                            <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                        </textFieldCell>
+                    </textField>
+                    <box title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="Zb7-ur-hyq">
+                        <rect key="frame" x="13" y="58" width="564" height="267"/>
+                        <view key="contentView" id="uGM-sA-94r">
+                            <rect key="frame" x="4" y="5" width="556" height="259"/>
+                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        </view>
+                    </box>
+                    <box title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="uwM-6J-qpb">
+                        <rect key="frame" x="176" y="337" width="238" height="38"/>
+                        <view key="contentView" id="giD-Uw-TCT">
+                            <rect key="frame" x="4" y="5" width="230" height="30"/>
+                            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                            <subviews>
+                                <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="esW-e0-28b">
+                                    <rect key="frame" x="-1" y="-2" width="81" height="33"/>
+                                    <constraints>
+                                        <constraint firstAttribute="width" constant="75" id="g8u-uh-XvA"/>
+                                    </constraints>
+                                    <buttonCell key="cell" type="bevel" title="Input" bezelStyle="regularSquare" alignment="center" borderStyle="border" inset="2" id="NhA-fk-XQT">
+                                        <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                        <font key="font" metaFont="system"/>
+                                    </buttonCell>
+                                    <connections>
+                                        <action selector="inputButton_Click:" target="-2" id="W6n-0Y-jhs"/>
+                                    </connections>
+                                </button>
+                                <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xyn-sX-pty">
+                                    <rect key="frame" x="75" y="-2" width="81" height="33"/>
+                                    <constraints>
+                                        <constraint firstAttribute="width" constant="75" id="PMA-et-fgx"/>
+                                        <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="75" id="gyN-Xv-em9"/>
+                                    </constraints>
+                                    <buttonCell key="cell" type="bevel" title="Drawing" bezelStyle="regularSquare" alignment="center" borderStyle="border" inset="2" id="Up7-YU-6NT">
+                                        <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                        <font key="font" metaFont="system"/>
+                                    </buttonCell>
+                                    <connections>
+                                        <action selector="drawingButton_Click:" target="-2" id="c3k-oR-ZP0"/>
+                                    </connections>
+                                </button>
+                                <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Fjh-hd-6bs">
+                                    <rect key="frame" x="150" y="-2" width="81" height="33"/>
+                                    <constraints>
+                                        <constraint firstAttribute="width" constant="75" id="1Yd-tc-XBx"/>
+                                        <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="75" id="yir-05-0OY"/>
+                                    </constraints>
+                                    <buttonCell key="cell" type="bevel" title="Picture" bezelStyle="regularSquare" alignment="center" borderStyle="border" inset="2" id="fkI-hC-FgV">
+                                        <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                        <font key="font" metaFont="system"/>
+                                    </buttonCell>
+                                    <connections>
+                                        <action selector="pictureButton_Click:" target="-2" id="7qB-nf-L53"/>
+                                    </connections>
+                                </button>
+                            </subviews>
+                            <constraints>
+                                <constraint firstItem="esW-e0-28b" firstAttribute="leading" secondItem="giD-Uw-TCT" secondAttribute="leading" constant="2" id="1Wb-uX-xWj"/>
+                                <constraint firstItem="Fjh-hd-6bs" firstAttribute="leading" secondItem="xyn-sX-pty" secondAttribute="trailing" id="1dx-5F-XsB"/>
+                                <constraint firstAttribute="bottom" secondItem="Fjh-hd-6bs" secondAttribute="bottom" constant="2" id="6MD-Oa-jTG"/>
+                                <constraint firstItem="xyn-sX-pty" firstAttribute="leading" secondItem="esW-e0-28b" secondAttribute="trailing" constant="1" id="CMF-ie-vZZ"/>
+                                <constraint firstItem="esW-e0-28b" firstAttribute="top" secondItem="giD-Uw-TCT" secondAttribute="top" constant="2" id="NJT-9l-eSL"/>
+                                <constraint firstAttribute="bottom" secondItem="esW-e0-28b" secondAttribute="bottom" constant="2" id="Rpo-QB-gH0"/>
+                                <constraint firstAttribute="trailing" secondItem="Fjh-hd-6bs" secondAttribute="trailing" constant="2" id="Vsd-ap-wJl"/>
+                                <constraint firstItem="Fjh-hd-6bs" firstAttribute="top" secondItem="giD-Uw-TCT" secondAttribute="top" constant="2" id="XsP-Gl-DCF"/>
+                                <constraint firstItem="xyn-sX-pty" firstAttribute="top" secondItem="giD-Uw-TCT" secondAttribute="top" constant="2" id="Yih-qb-CGo"/>
+                                <constraint firstAttribute="bottom" secondItem="xyn-sX-pty" secondAttribute="bottom" constant="2" id="lPJ-c2-fTU"/>
+                            </constraints>
+                        </view>
+                        <constraints>
+                            <constraint firstAttribute="width" constant="232" id="gTE-d2-JpX"/>
+                            <constraint firstAttribute="height" constant="32" id="tyB-B4-ZdD"/>
+                        </constraints>
+                    </box>
+                </subviews>
+                <constraints>
+                    <constraint firstItem="uH2-qz-onx" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="15" id="6Zw-Bu-V0g"/>
+                    <constraint firstAttribute="bottom" secondItem="j7L-83-3Ut" secondAttribute="bottom" constant="18" id="AlF-Ra-vWr"/>
+                    <constraint firstItem="8sI-6n-jcW" firstAttribute="top" secondItem="Zb7-ur-hyq" secondAttribute="bottom" constant="20" id="CFI-Ph-TRM"/>
+                    <constraint firstItem="uwM-6J-qpb" firstAttribute="centerX" secondItem="se5-gp-TjO" secondAttribute="centerX" id="Fch-wz-IIw"/>
+                    <constraint firstItem="uH2-qz-onx" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="13" id="Ghe-kW-emH"/>
+                    <constraint firstItem="9qj-7Y-28D" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="16" id="NdR-Nx-YxU"/>
+                    <constraint firstItem="Zb7-ur-hyq" firstAttribute="top" secondItem="uwM-6J-qpb" secondAttribute="bottom" constant="18" id="V4R-Jp-2PA"/>
+                    <constraint firstItem="j7L-83-3Ut" firstAttribute="leading" secondItem="s0y-mf-WpS" secondAttribute="trailing" constant="8" id="X9g-V2-3wh"/>
+                    <constraint firstItem="j7L-83-3Ut" firstAttribute="centerY" secondItem="s0y-mf-WpS" secondAttribute="centerY" id="Y4D-k0-sM3"/>
+                    <constraint firstItem="j7L-83-3Ut" firstAttribute="centerY" secondItem="9qj-7Y-28D" secondAttribute="centerY" id="ccU-qA-3KC"/>
+                    <constraint firstAttribute="trailing" secondItem="Zb7-ur-hyq" secondAttribute="trailing" constant="16" id="d8u-vT-SsW"/>
+                    <constraint firstItem="uwM-6J-qpb" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="50" id="khJ-7o-sK7"/>
+                    <constraint firstItem="s0y-mf-WpS" firstAttribute="centerY" secondItem="8sI-6n-jcW" secondAttribute="centerY" id="o8L-NT-cYh"/>
+                    <constraint firstItem="8sI-6n-jcW" firstAttribute="centerX" secondItem="se5-gp-TjO" secondAttribute="centerX" constant="-55" id="qgN-ns-yvO"/>
+                    <constraint firstItem="Zb7-ur-hyq" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="16" id="t1b-Xu-pyk"/>
+                    <constraint firstAttribute="trailing" secondItem="j7L-83-3Ut" secondAttribute="trailing" constant="16" id="tGI-Zj-ht0"/>
+                </constraints>
+            </view>
+            <connections>
+                <outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
+            </connections>
+            <point key="canvasLocation" x="-158" y="125.5"/>
+        </window>
+        <menuItem title="Font" id="Bgp-vT-51J">
+            <attributedString key="attributedTitle"/>
+            <modifierMask key="keyEquivalentModifierMask"/>
+            <menu key="submenu" title="Font" systemMenu="font" id="NPH-NP-lJS">
+                <items>
+                    <menuItem title="Show Fonts" keyEquivalent="t" id="uof-f0-PYw">
+                        <connections>
+                            <action selector="orderFrontFontPanel:" target="wyz-2S-MNY" id="nOq-gE-ORo"/>
+                        </connections>
+                    </menuItem>
+                    <menuItem title="Bold" tag="2" keyEquivalent="b" id="tDu-4U-w2p">
+                        <connections>
+                            <action selector="addFontTrait:" target="wyz-2S-MNY" id="rVI-xr-G8J"/>
+                        </connections>
+                    </menuItem>
+                    <menuItem title="Italic" tag="1" keyEquivalent="i" id="caa-9k-YLw">
+                        <connections>
+                            <action selector="addFontTrait:" target="wyz-2S-MNY" id="oqS-4o-gRd"/>
+                        </connections>
+                    </menuItem>
+                    <menuItem title="Underline" keyEquivalent="u" id="xem-BC-ZPu">
+                        <connections>
+                            <action selector="underline:" target="-1" id="j0g-8Z-ZI3"/>
+                        </connections>
+                    </menuItem>
+                    <menuItem isSeparatorItem="YES" id="Qv3-wE-pK4"/>
+                    <menuItem title="Bigger" tag="3" keyEquivalent="+" id="Ec1-fx-dp5">
+                        <connections>
+                            <action selector="modifyFont:" target="wyz-2S-MNY" id="Yuc-ss-hwS"/>
+                        </connections>
+                    </menuItem>
+                    <menuItem title="Smaller" tag="4" keyEquivalent="-" id="haZ-xV-ZGG">
+                        <connections>
+                            <action selector="modifyFont:" target="wyz-2S-MNY" id="Ahb-Vy-uyv"/>
+                        </connections>
+                    </menuItem>
+                    <menuItem isSeparatorItem="YES" id="zMA-3c-Z91"/>
+                    <menuItem title="Kern" id="huX-Kg-0Ky">
+                        <modifierMask key="keyEquivalentModifierMask"/>
+                        <menu key="submenu" title="Kern" id="9h1-Ev-LMA">
+                            <items>
+                                <menuItem title="Use Default" id="bdd-oA-fmP">
+                                    <modifierMask key="keyEquivalentModifierMask"/>
+                                    <connections>
+                                        <action selector="useStandardKerning:" target="-1" id="Ktr-zw-bPd"/>
+                                    </connections>
+                                </menuItem>
+                                <menuItem title="Use None" id="CMw-O7-lWK">
+                                    <modifierMask key="keyEquivalentModifierMask"/>
+                                    <connections>
+                                        <action selector="turnOffKerning:" target="-1" id="jsl-9p-oG9"/>
+                                    </connections>
+                                </menuItem>
+                                <menuItem title="Tighten" id="pIq-Qb-p0W">
+                                    <modifierMask key="keyEquivalentModifierMask"/>
+                                    <connections>
+                                        <action selector="tightenKerning:" target="-1" id="iPL-Em-0FK"/>
+                                    </connections>
+                                </menuItem>
+                                <menuItem title="Loosen" id="IYO-zK-xVK">
+                                    <modifierMask key="keyEquivalentModifierMask"/>
+                                    <connections>
+                                        <action selector="loosenKerning:" target="-1" id="LzA-Rg-uC8"/>
+                                    </connections>
+                                </menuItem>
+                            </items>
+                        </menu>
+                    </menuItem>
+                    <menuItem title="Ligatures" id="Cno-Tp-WjR">
+                        <modifierMask key="keyEquivalentModifierMask"/>
+                        <menu key="submenu" title="Ligatures" id="BNB-rD-IXU">
+                            <items>
+                                <menuItem title="Use Default" id="Ik7-w2-aog">
+                                    <modifierMask key="keyEquivalentModifierMask"/>
+                                    <connections>
+                                        <action selector="useStandardLigatures:" target="-1" id="UUm-nQ-Q9r"/>
+                                    </connections>
+                                </menuItem>
+                                <menuItem title="Use None" id="fbn-Yd-Tem">
+                                    <modifierMask key="keyEquivalentModifierMask"/>
+                                    <connections>
+                                        <action selector="turnOffLigatures:" target="-1" id="URR-UJ-QNr"/>
+                                    </connections>
+                                </menuItem>
+                                <menuItem title="Use All" id="8WB-Dk-tFM">
+                                    <modifierMask key="keyEquivalentModifierMask"/>
+                                    <connections>
+                                        <action selector="useAllLigatures:" target="-1" id="hvn-xw-TH1"/>
+                                    </connections>
+                                </menuItem>
+                            </items>
+                        </menu>
+                    </menuItem>
+                    <menuItem title="Baseline" id="V8T-sk-gkc">
+                        <modifierMask key="keyEquivalentModifierMask"/>
+                        <menu key="submenu" title="Baseline" id="Hws-RP-4jY">
+                            <items>
+                                <menuItem title="Use Default" id="TKk-wH-3mJ">
+                                    <modifierMask key="keyEquivalentModifierMask"/>
+                                    <connections>
+                                        <action selector="unscript:" target="-1" id="3Dk-dL-c4g"/>
+                                    </connections>
+                                </menuItem>
+                                <menuItem title="Superscript" id="rVP-ya-mG8">
+                                    <modifierMask key="keyEquivalentModifierMask"/>
+                                    <connections>
+                                        <action selector="superscript:" target="-1" id="8PC-V5-omy"/>
+                                    </connections>
+                                </menuItem>
+                                <menuItem title="Subscript" id="fI7-we-TQz">
+                                    <modifierMask key="keyEquivalentModifierMask"/>
+                                    <connections>
+                                        <action selector="subscript:" target="-1" id="XEa-o0-hOg"/>
+                                    </connections>
+                                </menuItem>
+                                <menuItem title="Raise" id="QeT-1b-Ceb">
+                                    <modifierMask key="keyEquivalentModifierMask"/>
+                                    <connections>
+                                        <action selector="raiseBaseline:" target="-1" id="t2h-eZ-GEf"/>
+                                    </connections>
+                                </menuItem>
+                                <menuItem title="Lower" id="FRF-mX-3lp">
+                                    <modifierMask key="keyEquivalentModifierMask"/>
+                                    <connections>
+                                        <action selector="lowerBaseline:" target="-1" id="qpV-Ea-1jv"/>
+                                    </connections>
+                                </menuItem>
+                            </items>
+                        </menu>
+                    </menuItem>
+                    <menuItem isSeparatorItem="YES" id="soT-hs-wSb"/>
+                    <menuItem title="Show Colors" keyEquivalent="C" id="QLE-NT-yjI">
+                        <connections>
+                            <action selector="orderFrontColorPanel:" target="-1" id="A29-Ba-D6B"/>
+                        </connections>
+                    </menuItem>
+                    <menuItem isSeparatorItem="YES" id="KTc-22-VF0"/>
+                    <menuItem title="Copy Style" keyEquivalent="c" id="csU-fh-bwb">
+                        <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
+                        <connections>
+                            <action selector="copyFont:" target="-1" id="fSr-MX-aiY"/>
+                        </connections>
+                    </menuItem>
+                    <menuItem title="Paste Style" keyEquivalent="v" id="4lJ-K5-p7p">
+                        <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
+                        <connections>
+                            <action selector="pasteFont:" target="-1" id="m7g-fM-epu"/>
+                        </connections>
+                    </menuItem>
+                </items>
+            </menu>
+        </menuItem>
+        <customObject id="wyz-2S-MNY" customClass="NSFontManager"/>
+        <view id="NXb-2D-d7x">
+            <rect key="frame" x="0.0" y="0.0" width="556" height="279"/>
+            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+            <subviews>
+                <customView translatesAutoresizingMaskIntoConstraints="NO" id="y6e-Mr-PoK" customClass="KMPDFSignatureTextView">
+                    <rect key="frame" x="20" y="76" width="516" height="182"/>
+                    <subviews>
+                        <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="4mg-CI-O88" customClass="KMSignayureTextField">
+                            <rect key="frame" x="206" y="83" width="104" height="17"/>
+                            <constraints>
+                                <constraint firstAttribute="width" constant="100" id="PKU-Zg-SXA"/>
+                            </constraints>
+                            <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" focusRingType="none" alignment="center" placeholderString="Sign Here" id="n2U-Jv-ECn" customClass="KMVerticallyCenteredSecureTextFieldCell">
+                                <font key="font" metaFont="system" size="14"/>
+                                <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                <color key="backgroundColor" white="1" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                            </textFieldCell>
+                            <connections>
+                                <outlet property="delegate" destination="y6e-Mr-PoK" id="rqv-pX-Ug1"/>
+                            </connections>
+                        </textField>
+                        <box hidden="YES" boxType="custom" borderType="line" borderWidth="0.0" cornerRadius="1" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="3GF-Y1-2QB">
+                            <rect key="frame" x="187" y="69" width="1" height="44"/>
+                            <view key="contentView" id="HXg-bV-1K3">
+                                <rect key="frame" x="0.0" y="0.0" width="1" height="44"/>
+                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                            </view>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="44" id="eKf-yp-LSO"/>
+                                <constraint firstAttribute="width" constant="1" id="ytm-cc-TGm"/>
+                            </constraints>
+                            <color key="fillColor" name="KMAccentColor"/>
+                        </box>
+                    </subviews>
+                    <constraints>
+                        <constraint firstItem="4mg-CI-O88" firstAttribute="leading" secondItem="3GF-Y1-2QB" secondAttribute="trailing" constant="20" id="7Kg-jH-tk9"/>
+                        <constraint firstItem="4mg-CI-O88" firstAttribute="centerY" secondItem="3GF-Y1-2QB" secondAttribute="centerY" id="AZw-S9-WYs"/>
+                        <constraint firstItem="4mg-CI-O88" firstAttribute="centerY" secondItem="y6e-Mr-PoK" secondAttribute="centerY" id="Wz4-fM-xOm"/>
+                        <constraint firstItem="4mg-CI-O88" firstAttribute="centerX" secondItem="y6e-Mr-PoK" secondAttribute="centerX" id="h3Q-er-CY1"/>
+                    </constraints>
+                    <connections>
+                        <outlet property="labelWidthLayoutConstraint" destination="PKU-Zg-SXA" id="Dy4-cC-pYh"/>
+                        <outlet property="nameTextFiled" destination="4mg-CI-O88" id="YF4-Za-aOC"/>
+                    </connections>
+                </customView>
+                <popUpButton translatesAutoresizingMaskIntoConstraints="NO" id="OX0-YE-NCd">
+                    <rect key="frame" x="17" y="35" width="227" height="24"/>
+                    <constraints>
+                        <constraint firstAttribute="width" constant="220" id="SC1-Sc-4bW"/>
+                        <constraint firstAttribute="height" constant="19" id="u9g-WU-l1d"/>
+                    </constraints>
+                    <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="border" inset="2" pullsDown="YES" selectedItem="KZ5-Yj-30d" id="cMv-GJ-DlD">
+                        <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                        <font key="font" metaFont="menu"/>
+                        <menu key="menu" id="1uW-bf-xCL">
+                            <items>
+                                <menuItem title="Item 1" state="on" hidden="YES" id="KZ5-Yj-30d"/>
+                            </items>
+                        </menu>
+                    </popUpButtonCell>
+                    <connections>
+                        <action selector="boxItemClicked_Font:" target="-2" id="p6t-kB-gXh"/>
+                    </connections>
+                </popUpButton>
+                <customView translatesAutoresizingMaskIntoConstraints="NO" id="ZzX-Q8-4Rv">
+                    <rect key="frame" x="308" y="36" width="228" height="24"/>
+                    <subviews>
+                        <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3P0-xX-1B0" customClass="KMSignatureColorButton">
+                            <rect key="frame" x="0.0" y="0.0" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="width" constant="24" id="XYO-LK-9ze"/>
+                                <constraint firstAttribute="height" constant="24" id="sGZ-Vm-5xB"/>
+                            </constraints>
+                            <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" inset="2" id="MQd-r7-b12">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="colorTextButtonAction:" target="-2" id="2Vl-fM-UPk"/>
+                            </connections>
+                        </button>
+                        <button verticalHuggingPriority="750" tag="1" translatesAutoresizingMaskIntoConstraints="NO" id="gug-Lh-QIp" customClass="KMSignatureColorButton">
+                            <rect key="frame" x="34" y="0.0" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="width" constant="24" id="I7C-I5-RFU"/>
+                                <constraint firstAttribute="height" constant="24" id="jny-ZR-BvL"/>
+                            </constraints>
+                            <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" inset="2" id="fFP-bm-crI">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="colorTextButtonAction:" target="-2" id="Gdk-GQ-J4n"/>
+                            </connections>
+                        </button>
+                        <button verticalHuggingPriority="750" tag="2" translatesAutoresizingMaskIntoConstraints="NO" id="i17-eA-DlO" customClass="KMSignatureColorButton">
+                            <rect key="frame" x="68" y="0.0" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="width" constant="24" id="BdG-eO-AJC"/>
+                                <constraint firstAttribute="height" constant="24" id="ofU-hX-tgo"/>
+                            </constraints>
+                            <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" inset="2" id="Wxi-He-uxH">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="colorTextButtonAction:" target="-2" id="2HO-3r-EN0"/>
+                            </connections>
+                        </button>
+                        <button verticalHuggingPriority="750" tag="3" translatesAutoresizingMaskIntoConstraints="NO" id="j89-oP-egN" customClass="KMSignatureColorButton">
+                            <rect key="frame" x="102" y="0.0" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="width" constant="24" id="TsE-KO-YsM"/>
+                                <constraint firstAttribute="height" constant="24" id="o0G-nm-K9a"/>
+                            </constraints>
+                            <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" inset="2" id="aoB-ck-NLM">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="colorTextButtonAction:" target="-2" id="QRr-xu-Ga0"/>
+                            </connections>
+                        </button>
+                        <button verticalHuggingPriority="750" tag="4" translatesAutoresizingMaskIntoConstraints="NO" id="XIZ-Ha-pW9" customClass="KMSignatureColorButton">
+                            <rect key="frame" x="136" y="0.0" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="24" id="VQc-50-VwH"/>
+                                <constraint firstAttribute="width" constant="24" id="mHh-Dm-mTj"/>
+                            </constraints>
+                            <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" inset="2" id="HVS-MW-47K">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="colorTextButtonAction:" target="-2" id="3Qy-ha-uFI"/>
+                            </connections>
+                        </button>
+                        <button verticalHuggingPriority="750" tag="5" translatesAutoresizingMaskIntoConstraints="NO" id="AMW-D1-XIu" customClass="KMSignatureColorButton">
+                            <rect key="frame" x="170" y="0.0" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="24" id="Pz1-YW-pQY"/>
+                                <constraint firstAttribute="width" constant="24" id="acy-pG-KsS"/>
+                            </constraints>
+                            <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" inset="2" id="NqJ-7f-82Z">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="colorTextButtonAction:" target="-2" id="BVP-hY-EuK"/>
+                            </connections>
+                        </button>
+                        <button focusRingType="none" tag="6" translatesAutoresizingMaskIntoConstraints="NO" id="Wn0-74-O2r" customClass="KMSignatureColorButton">
+                            <rect key="frame" x="204" y="0.0" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="width" constant="24" id="AxK-Z4-Iq2"/>
+                                <constraint firstAttribute="height" constant="24" id="Oct-X8-Pt5"/>
+                            </constraints>
+                            <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" imagePosition="only" alignment="center" focusRingType="none" imageScaling="proportionallyUpOrDown" inset="2" id="ngH-vk-54u">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="colorTextButtonAction:" target="-2" id="Rae-MQ-AKg"/>
+                            </connections>
+                        </button>
+                    </subviews>
+                    <constraints>
+                        <constraint firstAttribute="trailing" secondItem="Wn0-74-O2r" secondAttribute="trailing" id="5EM-x7-CVp"/>
+                        <constraint firstItem="gug-Lh-QIp" firstAttribute="centerY" secondItem="3P0-xX-1B0" secondAttribute="centerY" id="6WN-dJ-R0i"/>
+                        <constraint firstAttribute="bottom" secondItem="3P0-xX-1B0" secondAttribute="bottom" id="9cW-iD-I3E"/>
+                        <constraint firstItem="gug-Lh-QIp" firstAttribute="leading" secondItem="3P0-xX-1B0" secondAttribute="trailing" constant="10" id="Kd3-ec-AdB"/>
+                        <constraint firstItem="j89-oP-egN" firstAttribute="leading" secondItem="i17-eA-DlO" secondAttribute="trailing" constant="10" id="ZhT-I4-4ok"/>
+                        <constraint firstItem="AMW-D1-XIu" firstAttribute="leading" secondItem="XIZ-Ha-pW9" secondAttribute="trailing" constant="10" id="dF9-ZF-vyl"/>
+                        <constraint firstItem="3P0-xX-1B0" firstAttribute="leading" secondItem="ZzX-Q8-4Rv" secondAttribute="leading" id="e8L-2S-gsq"/>
+                        <constraint firstItem="j89-oP-egN" firstAttribute="centerY" secondItem="3P0-xX-1B0" secondAttribute="centerY" id="gPb-a5-huX"/>
+                        <constraint firstItem="AMW-D1-XIu" firstAttribute="centerY" secondItem="3P0-xX-1B0" secondAttribute="centerY" id="hNn-SA-xGF"/>
+                        <constraint firstItem="3P0-xX-1B0" firstAttribute="top" secondItem="ZzX-Q8-4Rv" secondAttribute="top" id="one-KZ-J45"/>
+                        <constraint firstItem="Wn0-74-O2r" firstAttribute="leading" secondItem="AMW-D1-XIu" secondAttribute="trailing" constant="10" id="qzW-Ge-Gge"/>
+                        <constraint firstItem="Wn0-74-O2r" firstAttribute="centerY" secondItem="AMW-D1-XIu" secondAttribute="centerY" id="rGb-vg-lf7"/>
+                        <constraint firstItem="XIZ-Ha-pW9" firstAttribute="leading" secondItem="j89-oP-egN" secondAttribute="trailing" constant="10" id="uCW-n1-Yb6"/>
+                        <constraint firstItem="XIZ-Ha-pW9" firstAttribute="centerY" secondItem="3P0-xX-1B0" secondAttribute="centerY" id="uus-Mz-9Rh"/>
+                        <constraint firstItem="i17-eA-DlO" firstAttribute="centerY" secondItem="3P0-xX-1B0" secondAttribute="centerY" id="vi4-wI-OGw"/>
+                        <constraint firstItem="i17-eA-DlO" firstAttribute="leading" secondItem="gug-Lh-QIp" secondAttribute="trailing" constant="10" id="xOd-xS-C3g"/>
+                    </constraints>
+                </customView>
+            </subviews>
+            <constraints>
+                <constraint firstAttribute="trailing" secondItem="y6e-Mr-PoK" secondAttribute="trailing" constant="20" id="CKM-Pn-vQT"/>
+                <constraint firstItem="y6e-Mr-PoK" firstAttribute="top" secondItem="NXb-2D-d7x" secondAttribute="top" constant="21" id="G5m-NB-HNc"/>
+                <constraint firstItem="ZzX-Q8-4Rv" firstAttribute="top" secondItem="y6e-Mr-PoK" secondAttribute="bottom" constant="16" id="Spf-P6-Jq1"/>
+                <constraint firstItem="y6e-Mr-PoK" firstAttribute="leading" secondItem="NXb-2D-d7x" secondAttribute="leading" constant="20" id="Yju-8J-mOf"/>
+                <constraint firstItem="OX0-YE-NCd" firstAttribute="leading" secondItem="y6e-Mr-PoK" secondAttribute="leading" id="iT0-tR-2Ju"/>
+                <constraint firstItem="ZzX-Q8-4Rv" firstAttribute="trailing" secondItem="y6e-Mr-PoK" secondAttribute="trailing" id="q3r-ma-cN0"/>
+                <constraint firstAttribute="bottom" secondItem="ZzX-Q8-4Rv" secondAttribute="bottom" constant="36" id="wGa-it-ein"/>
+                <constraint firstItem="ZzX-Q8-4Rv" firstAttribute="centerY" secondItem="OX0-YE-NCd" secondAttribute="centerY" id="xcn-bd-gSK"/>
+            </constraints>
+            <point key="canvasLocation" x="-302" y="557"/>
+        </view>
+        <view id="uWu-ea-oIZ">
+            <rect key="frame" x="0.0" y="0.0" width="556" height="279"/>
+            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+            <subviews>
+                <customView translatesAutoresizingMaskIntoConstraints="NO" id="I2h-gk-zBq" customClass="KMDrawView">
+                    <rect key="frame" x="20" y="76" width="516" height="182"/>
+                </customView>
+                <button focusRingType="none" translatesAutoresizingMaskIntoConstraints="NO" id="pqR-eZ-KlX">
+                    <rect key="frame" x="18" y="39" width="83" height="18"/>
+                    <buttonCell key="cell" type="check" title="Trackpad" bezelStyle="regularSquare" imagePosition="left" focusRingType="none" inset="2" id="KL4-X1-mLd">
+                        <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+                        <font key="font" metaFont="system"/>
+                    </buttonCell>
+                    <connections>
+                        <action selector="trackpadButton_Click:" target="-2" id="UwP-WA-Gp6"/>
+                    </connections>
+                </button>
+                <slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sdR-we-Swp">
+                    <rect key="frame" x="146" y="32" width="98" height="28"/>
+                    <constraints>
+                        <constraint firstAttribute="width" constant="94" id="pnr-o0-fi2"/>
+                    </constraints>
+                    <sliderCell key="cell" continuous="YES" alignment="left" minValue="0.10000000000000001" maxValue="4" doubleValue="0.8441558441558441" tickMarkPosition="above" sliderType="linear" id="E3a-sd-QoG"/>
+                    <connections>
+                        <action selector="slider_Change:" target="-2" id="H0I-j3-zMz"/>
+                    </connections>
+                </slider>
+                <customView translatesAutoresizingMaskIntoConstraints="NO" id="XBs-Sr-XmD">
+                    <rect key="frame" x="308" y="36" width="228" height="24"/>
+                    <subviews>
+                        <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="yuc-HU-IZY" customClass="KMSignatureColorButton">
+                            <rect key="frame" x="0.0" y="0.0" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="width" constant="24" id="4KD-vf-FFw"/>
+                                <constraint firstAttribute="height" constant="24" id="7rV-4I-YK4"/>
+                            </constraints>
+                            <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" inset="2" id="6Uw-2d-OMd">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="colorInkButtonAction:" target="-2" id="zMx-4R-H7k"/>
+                            </connections>
+                        </button>
+                        <button verticalHuggingPriority="750" tag="1" translatesAutoresizingMaskIntoConstraints="NO" id="whb-iK-A1H" customClass="KMSignatureColorButton">
+                            <rect key="frame" x="34" y="0.0" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="width" constant="24" id="Ozc-ja-vIM"/>
+                                <constraint firstAttribute="height" constant="24" id="and-DK-N6N"/>
+                            </constraints>
+                            <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" inset="2" id="u5f-8Y-ilX">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="colorInkButtonAction:" target="-2" id="Tl9-1A-k9k"/>
+                            </connections>
+                        </button>
+                        <button verticalHuggingPriority="750" tag="2" translatesAutoresizingMaskIntoConstraints="NO" id="TLr-6u-kcz" customClass="KMSignatureColorButton">
+                            <rect key="frame" x="68" y="0.0" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="width" constant="24" id="4jb-Cs-i73"/>
+                                <constraint firstAttribute="height" constant="24" id="G3D-Yk-ROt"/>
+                            </constraints>
+                            <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" inset="2" id="HRD-y1-EZQ">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="colorInkButtonAction:" target="-2" id="Pgv-DQ-eMc"/>
+                            </connections>
+                        </button>
+                        <button verticalHuggingPriority="750" tag="3" translatesAutoresizingMaskIntoConstraints="NO" id="Hdf-LB-0dV" customClass="KMSignatureColorButton">
+                            <rect key="frame" x="102" y="0.0" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="24" id="6FQ-cu-WiZ"/>
+                                <constraint firstAttribute="width" constant="24" id="f53-cm-JHd"/>
+                            </constraints>
+                            <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" inset="2" id="85d-zt-HHR">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="colorInkButtonAction:" target="-2" id="OYr-zl-6I4"/>
+                            </connections>
+                        </button>
+                        <button verticalHuggingPriority="750" tag="4" translatesAutoresizingMaskIntoConstraints="NO" id="sYi-rx-eJP" customClass="KMSignatureColorButton">
+                            <rect key="frame" x="136" y="0.0" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="24" id="JIN-b6-yZb"/>
+                                <constraint firstAttribute="width" constant="24" id="Prc-EA-trQ"/>
+                            </constraints>
+                            <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" inset="2" id="tnw-eh-hqI">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="colorInkButtonAction:" target="-2" id="bUu-lH-Oir"/>
+                            </connections>
+                        </button>
+                        <button verticalHuggingPriority="750" tag="5" translatesAutoresizingMaskIntoConstraints="NO" id="bAs-ex-3wn" customClass="KMSignatureColorButton">
+                            <rect key="frame" x="170" y="0.0" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="24" id="UuB-S5-8Sy"/>
+                                <constraint firstAttribute="width" constant="24" id="pyV-FQ-JU1"/>
+                            </constraints>
+                            <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" inset="2" id="KGz-8y-9C4">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="colorInkButtonAction:" target="-2" id="o3k-8T-dCG"/>
+                            </connections>
+                        </button>
+                        <button focusRingType="none" tag="6" translatesAutoresizingMaskIntoConstraints="NO" id="bHb-2B-9IW" customClass="KMSignatureColorButton">
+                            <rect key="frame" x="204" y="0.0" width="24" height="24"/>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="24" id="QXA-ph-x8B"/>
+                                <constraint firstAttribute="width" constant="24" id="gaE-mG-aqX"/>
+                            </constraints>
+                            <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" imagePosition="only" alignment="center" focusRingType="none" imageScaling="proportionallyUpOrDown" inset="2" id="Jhj-f5-G2t">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="colorInkButtonAction:" target="-2" id="urg-3m-Oz9"/>
+                            </connections>
+                        </button>
+                    </subviews>
+                    <constraints>
+                        <constraint firstItem="bHb-2B-9IW" firstAttribute="centerY" secondItem="bAs-ex-3wn" secondAttribute="centerY" id="2mW-rz-8EO"/>
+                        <constraint firstItem="Hdf-LB-0dV" firstAttribute="leading" secondItem="TLr-6u-kcz" secondAttribute="trailing" constant="10" id="8zJ-82-AMU"/>
+                        <constraint firstAttribute="bottom" secondItem="yuc-HU-IZY" secondAttribute="bottom" id="9ZW-11-QpI"/>
+                        <constraint firstItem="bAs-ex-3wn" firstAttribute="centerY" secondItem="yuc-HU-IZY" secondAttribute="centerY" id="CaK-2u-NPX"/>
+                        <constraint firstItem="TLr-6u-kcz" firstAttribute="centerY" secondItem="yuc-HU-IZY" secondAttribute="centerY" id="EQT-UA-IZ7"/>
+                        <constraint firstItem="Hdf-LB-0dV" firstAttribute="centerY" secondItem="yuc-HU-IZY" secondAttribute="centerY" id="INr-cV-ShB"/>
+                        <constraint firstItem="yuc-HU-IZY" firstAttribute="leading" secondItem="XBs-Sr-XmD" secondAttribute="leading" id="Pt5-3o-xJc"/>
+                        <constraint firstItem="whb-iK-A1H" firstAttribute="leading" secondItem="yuc-HU-IZY" secondAttribute="trailing" constant="10" id="SxA-Is-uh9"/>
+                        <constraint firstItem="yuc-HU-IZY" firstAttribute="top" secondItem="XBs-Sr-XmD" secondAttribute="top" id="U36-42-G8h"/>
+                        <constraint firstItem="sYi-rx-eJP" firstAttribute="leading" secondItem="Hdf-LB-0dV" secondAttribute="trailing" constant="10" id="Vwq-jT-HXa"/>
+                        <constraint firstItem="bAs-ex-3wn" firstAttribute="leading" secondItem="sYi-rx-eJP" secondAttribute="trailing" constant="10" id="WrA-NS-b3Y"/>
+                        <constraint firstItem="sYi-rx-eJP" firstAttribute="centerY" secondItem="yuc-HU-IZY" secondAttribute="centerY" id="ZZ3-Dn-Wcd"/>
+                        <constraint firstAttribute="trailing" secondItem="bHb-2B-9IW" secondAttribute="trailing" id="ajq-uj-kqC"/>
+                        <constraint firstItem="whb-iK-A1H" firstAttribute="centerY" secondItem="yuc-HU-IZY" secondAttribute="centerY" id="coa-y8-7hU"/>
+                        <constraint firstItem="bHb-2B-9IW" firstAttribute="leading" secondItem="bAs-ex-3wn" secondAttribute="trailing" constant="10" id="sJ1-s4-9tc"/>
+                        <constraint firstItem="TLr-6u-kcz" firstAttribute="leading" secondItem="whb-iK-A1H" secondAttribute="trailing" constant="10" id="v6X-gu-Neb"/>
+                    </constraints>
+                </customView>
+                <textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="LsA-Os-ado">
+                    <rect key="frame" x="248" y="38" width="40" height="20"/>
+                    <constraints>
+                        <constraint firstAttribute="height" constant="20" id="Edl-m3-ttk"/>
+                        <constraint firstAttribute="width" constant="40" id="faM-ly-vU5"/>
+                    </constraints>
+                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" id="2YI-aT-sQO">
+                        <font key="font" metaFont="system"/>
+                        <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                    </textFieldCell>
+                </textField>
+            </subviews>
+            <constraints>
+                <constraint firstAttribute="trailing" secondItem="I2h-gk-zBq" secondAttribute="trailing" constant="20" id="0bC-We-6Hn"/>
+                <constraint firstItem="I2h-gk-zBq" firstAttribute="leading" secondItem="uWu-ea-oIZ" secondAttribute="leading" constant="20" id="0tw-lh-g0B"/>
+                <constraint firstAttribute="bottom" secondItem="XBs-Sr-XmD" secondAttribute="bottom" constant="36" id="414-oi-Yu6"/>
+                <constraint firstItem="XBs-Sr-XmD" firstAttribute="centerY" secondItem="pqR-eZ-KlX" secondAttribute="centerY" id="53g-vp-g6K"/>
+                <constraint firstItem="XBs-Sr-XmD" firstAttribute="centerY" secondItem="sdR-we-Swp" secondAttribute="centerY" id="BgD-5y-tyg"/>
+                <constraint firstItem="LsA-Os-ado" firstAttribute="centerY" secondItem="sdR-we-Swp" secondAttribute="centerY" id="D3Q-Uu-P77"/>
+                <constraint firstItem="XBs-Sr-XmD" firstAttribute="trailing" secondItem="I2h-gk-zBq" secondAttribute="trailing" id="EOQ-tV-06w"/>
+                <constraint firstItem="I2h-gk-zBq" firstAttribute="top" secondItem="uWu-ea-oIZ" secondAttribute="top" constant="21" id="R6L-2r-t5Z"/>
+                <constraint firstItem="XBs-Sr-XmD" firstAttribute="top" secondItem="I2h-gk-zBq" secondAttribute="bottom" constant="16" id="VDG-Q6-wrS"/>
+                <constraint firstItem="XBs-Sr-XmD" firstAttribute="leading" secondItem="sdR-we-Swp" secondAttribute="trailing" constant="66" id="gBa-29-vkq"/>
+                <constraint firstItem="pqR-eZ-KlX" firstAttribute="leading" secondItem="I2h-gk-zBq" secondAttribute="leading" id="kqU-FA-7ns"/>
+                <constraint firstItem="LsA-Os-ado" firstAttribute="leading" secondItem="sdR-we-Swp" secondAttribute="trailing" constant="6" id="mdS-N3-kVt"/>
+            </constraints>
+            <point key="canvasLocation" x="-302" y="905"/>
+        </view>
+        <view id="7II-X0-WZi">
+            <rect key="frame" x="0.0" y="0.0" width="556" height="279"/>
+            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+            <subviews>
+                <customView translatesAutoresizingMaskIntoConstraints="NO" id="fH0-Z8-dC3" customClass="KMPDFSignatureImageView">
+                    <rect key="frame" x="20" y="40" width="516" height="218"/>
+                    <subviews>
+                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="Z9Y-kq-Z1X">
+                            <rect key="frame" x="138" y="75" width="240" height="68"/>
+                            <subviews>
+                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="OZz-hG-Yf2">
+                                    <rect key="frame" x="111" y="29" width="18" height="17"/>
+                                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="or" id="prv-uQ-kZ4">
+                                        <font key="font" metaFont="system" size="14"/>
+                                        <color key="textColor" red="0.3921568627" green="0.3921568627" blue="0.3921568627" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                        <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                                    </textFieldCell>
+                                </textField>
+                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="A6g-VS-XMA">
+                                    <rect key="frame" x="8" y="51" width="224" height="17"/>
+                                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Drag image here" id="ytS-fD-Fui">
+                                        <font key="font" metaFont="system" size="14"/>
+                                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                        <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                                    </textFieldCell>
+                                </textField>
+                                <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="phK-G3-xZl">
+                                    <rect key="frame" x="68" y="-7" width="105" height="32"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="20" id="psy-Gs-h0e"/>
+                                    </constraints>
+                                    <buttonCell key="cell" type="push" title="Select a file" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="4Kd-E6-Yas">
+                                        <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                        <font key="font" metaFont="system"/>
+                                        <string key="keyEquivalent" base64-UTF8="YES">
+DQ
+</string>
+                                    </buttonCell>
+                                    <connections>
+                                        <action selector="buttonItemClick_SelectPhoto:" target="fH0-Z8-dC3" id="pA3-l9-VQQ"/>
+                                    </connections>
+                                </button>
+                            </subviews>
+                            <constraints>
+                                <constraint firstItem="OZz-hG-Yf2" firstAttribute="top" secondItem="A6g-VS-XMA" secondAttribute="bottom" constant="5" id="2xF-Pm-Rob"/>
+                                <constraint firstItem="phK-G3-xZl" firstAttribute="centerX" secondItem="Z9Y-kq-Z1X" secondAttribute="centerX" id="9NQ-s5-0xx"/>
+                                <constraint firstAttribute="trailing" secondItem="A6g-VS-XMA" secondAttribute="trailing" constant="10" id="P5d-P8-vM9"/>
+                                <constraint firstItem="OZz-hG-Yf2" firstAttribute="centerX" secondItem="Z9Y-kq-Z1X" secondAttribute="centerX" id="Z57-99-7oF"/>
+                                <constraint firstAttribute="width" constant="240" id="dPN-i1-lp7"/>
+                                <constraint firstItem="A6g-VS-XMA" firstAttribute="leading" secondItem="Z9Y-kq-Z1X" secondAttribute="leading" constant="10" id="mhN-F1-nAy"/>
+                                <constraint firstAttribute="bottom" secondItem="phK-G3-xZl" secondAttribute="bottom" id="sKF-ec-Mrz"/>
+                                <constraint firstItem="A6g-VS-XMA" firstAttribute="top" secondItem="Z9Y-kq-Z1X" secondAttribute="top" id="wW4-gY-QPH"/>
+                                <constraint firstAttribute="height" constant="68" id="zPI-2s-bGk"/>
+                            </constraints>
+                        </customView>
+                    </subviews>
+                    <constraints>
+                        <constraint firstItem="Z9Y-kq-Z1X" firstAttribute="centerY" secondItem="fH0-Z8-dC3" secondAttribute="centerY" id="9Vo-zl-7bB"/>
+                        <constraint firstItem="Z9Y-kq-Z1X" firstAttribute="centerX" secondItem="fH0-Z8-dC3" secondAttribute="centerX" id="ikF-MQ-WXe"/>
+                    </constraints>
+                    <connections>
+                        <outlet property="dragButton" destination="phK-G3-xZl" id="ykS-07-CfT"/>
+                        <outlet property="heraLabel" destination="A6g-VS-XMA" id="rMe-TB-tr7"/>
+                        <outlet property="orLabel" destination="OZz-hG-Yf2" id="idl-ra-Jnc"/>
+                        <outlet property="pictureView" destination="Z9Y-kq-Z1X" id="2Bs-ca-Kth"/>
+                    </connections>
+                </customView>
+            </subviews>
+            <constraints>
+                <constraint firstAttribute="trailing" secondItem="fH0-Z8-dC3" secondAttribute="trailing" constant="20" id="2eY-eC-S2H"/>
+                <constraint firstAttribute="bottom" secondItem="fH0-Z8-dC3" secondAttribute="bottom" constant="40" id="Kza-dN-ZXQ"/>
+                <constraint firstItem="fH0-Z8-dC3" firstAttribute="leading" secondItem="7II-X0-WZi" secondAttribute="leading" constant="20" id="b15-AR-T1l"/>
+                <constraint firstItem="fH0-Z8-dC3" firstAttribute="top" secondItem="7II-X0-WZi" secondAttribute="top" constant="21" id="jDK-WY-tZx"/>
+            </constraints>
+            <point key="canvasLocation" x="-302" y="1253"/>
+        </view>
+    </objects>
+    <resources>
+        <namedColor name="KMAccentColor">
+            <color red="0.27843137254901962" green="0.49411764705882355" blue="0.87058823529411766" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </namedColor>
+    </resources>
+</document>

+ 15 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/NSImage+CustomImage.h

@@ -0,0 +1,15 @@
+//
+//  NSImage+CustomImage.h
+//  PDF Reader Premium
+//
+//  Created by wangshuai on 14/12/3.
+//  Copyright (c) 2014年 zhangjie. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@interface NSImage (CustomImage)
+
++ (NSImage*)imageCustomColor:(NSColor *)color;
+
+@end

+ 42 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/Signature/NSImage+CustomImage.m

@@ -0,0 +1,42 @@
+//
+//  NSImage+CustomImage.m
+//  PDF Reader Premium
+//
+//  Created by wangshuai on 14/12/3.
+//  Copyright (c) 2014年 zhangjie. All rights reserved.
+//
+
+#import "NSImage+CustomImage.h"
+
+@implementation NSImage (CustomImage)
+
++ (NSImage*)imageCustomColor:(NSColor *)color
+{
+    NSSize size = NSMakeSize(160, 80);
+    CGContextRef context = CGBitmapContextCreate(nil, size.width, size.height, 8, 0,
+                                                 CGColorSpaceCreateDeviceRGB(),
+                                                 kCGImageAlphaPremultipliedLast);
+    //画距形边框
+    CGRect rect = CGRectMake(28, 8, 92, 64);
+    CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 1.0);
+    CGContextSetLineWidth(context, 8.0);
+    CGContextAddRect(context, rect);
+    CGContextStrokePath(context);
+    CGContextSetFillColorWithColor(context, color.CGColor);
+    CGContextAddRect(context, rect);
+    CGContextFillPath(context);
+    
+    //画下三角
+    CGContextSetFillColorWithColor(context, [NSColor blackColor].CGColor);
+    CGContextMoveToPoint(context, 136, 44);
+    CGContextAddLineToPoint(context, 145, 28);
+    CGContextAddLineToPoint(context, 154, 44);
+    CGContextFillPath(context);
+    
+    CGImageRef newImage = CGBitmapContextCreateImage(context);
+    NSImage *image = [[NSImage alloc] initWithCGImage:newImage size:NSMakeSize(size.width, size.height)];
+    CGContextRelease(context);
+    return image;
+}
+
+@end

+ 3 - 3
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.m

@@ -183,7 +183,7 @@
 
 - (void)tableViewMenu {
     NSMenu *menu = [[NSMenu alloc] init];
-    [menu addItemWithTitle:NSLocalizedString(@"Edit the text stamp", nil) action:@selector(eidtCustomizeStamp) target:self];
+//    [menu addItemWithTitle:NSLocalizedString(@"Edit the text stamp", nil) action:@selector(eidtCustomizeStamp) target:self];
     NSMenuItem *item = [menu addItemWithTitle:NSLocalizedString(@"Export stamp", nil) action:nil target:self];
     NSMenu *tSubMenu = [[NSMenu alloc] init];
     NSMenuItem *tMenuItem = [tSubMenu insertItemWithTitle:NSLocalizedString(@"PNG", @"Menu item title") action:@selector(exportCustomizeStamp:) target:self atIndex:0];
@@ -311,7 +311,7 @@
 
 - (void)eidtCustomizeStamp {
     __block typeof(self) blockSelf = self;
-    if(self.tableView.selectedRow > 0 && self.tableView.selectedRow < self.stampLists.count) {
+    if(self.tableView.selectedRow >= 0 && self.tableView.selectedRow < self.stampLists.count) {
         CStampObject *stamp = self.stampLists[self.tableView.selectedRow];
         KMCustomizeStampViewController *vc = [[KMCustomizeStampViewController alloc] init];
         vc.currentStamp = stamp;
@@ -381,7 +381,7 @@
 }
 
 - (void)deleteCustomizeStamp {
-    if(self.tableView.selectedRow > 0 && self.tableView.selectedRow < self.stampLists.count) {
+    if(self.tableView.selectedRow >= 0 && self.tableView.selectedRow < self.stampLists.count) {
         CStampObject *stamp = self.stampLists[self.tableView.selectedRow];
         [[KMStampManager defaultManager] removeStamp:stamp];
         [self reloadStampData:self.currentType];

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

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21225" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21225"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>

+ 2 - 2
PDF Office/PDF Office/Class/PDFWindowController/Toolbar/KMMainToolbarController.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21225" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21225"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>

+ 126 - 0
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -83,6 +83,8 @@ extension KMMainViewController {
         self.leftSideViewController.signatureViewController.reloadData()
     }
     
+    //MARK: menu菜单
+    
     func fontColorMenuItem()->NSMenuItem {
         let fontColorItem = NSMenuItem(title: NSLocalizedString("Text Color", comment: ""), action: #selector(menuItemEditingClick_FontColor), keyEquivalent: "")
 
@@ -135,10 +137,56 @@ extension KMMainViewController {
         return exportItem
     }
     
+    func addAnnotationStype() -> NSMenuItem {
+        let stypItem = NSMenuItem(title: NSLocalizedString("Add Annotation", comment: ""), action: nil, target: self)!
+        let stypeMenu = NSMenu()
+        stypeMenu.addItem(withTitle: NSLocalizedString("Ink", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 0)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Text", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 1)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Note", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 2)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Rectangle", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 3)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Circle", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 4)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Arrow", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 5)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Line", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 6)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Link", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 7)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Stamp", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 8)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Signture", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 9)
+        stypItem.submenu = stypeMenu
+        return stypItem
+    }
+    
+    func setAnnotationToolStype() -> NSMenuItem {
+        let stypItem = NSMenuItem(title: NSLocalizedString("Tool Model", comment: ""), action: nil, target: self)!
+        let stypeMenu = NSMenu()
+        stypeMenu.addItem(withTitle: NSLocalizedString("Default Tool", comment: ""), action: #selector(menuItemAnnotationClick_toolModel), target: self, tag: 0)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Roll Tool", comment: ""), action: #selector(menuItemAnnotationClick_toolModel), target: self, tag: 1)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Magnify", comment: ""), action: #selector(menuItemAnnotationClick_toolModel), target: self, tag: 2)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Select", comment: ""), action: #selector(menuItemAnnotationClick_toolModel), target: self, tag: 3)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Zoom Select", comment: ""), action: #selector(menuItemAnnotationClick_toolModel), target: self, tag: 4)
+        stypItem.submenu = stypeMenu
+        return stypItem
+    }
+    
+    func addBookmarkMenu() -> NSMenuItem {
+        let bookMarkItem = NSMenuItem(title: NSLocalizedString("Add BookMark", comment: ""), action: #selector(menuItemBookMarkClick_add), target: self)!
+        return bookMarkItem
+    }
+    
+    func findStringMenu() -> NSMenuItem {
+        let menuItem = NSMenuItem(title: NSLocalizedString("Find", comment: ""), action: #selector(menuItemAnnotationClick_FindString), target: self)!
+        return menuItem
+    }
+    
+    func printingMenu() -> NSMenuItem {
+        let menuItem = NSMenuItem(title: NSLocalizedString("Print", comment: ""), action: #selector(menuItemAnnotationClick_Print), target: self)!
+        return menuItem
+    }
+    
     func fontSizes()->NSArray {
         return ["6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "24", "36", "48", "72", "96", "144", "288"]
     }
     
+    //MARK: menuItem Action
+    
     @objc func menuItemEditingClick_FontColor(sender: NSMenuItem) {
         let color = listView.editingSelectionFontColor()
         let panel = NSColorPanel.shared
@@ -223,6 +271,84 @@ extension KMMainViewController {
         }
     }
     
+    @objc func menuItemAnnotationClick_toolModel(sender: NSMenuItem) {
+        self.listView.toolMode = .noteToolMode
+        switch sender.tag {
+        case 0:
+            self.toolbarController.toolbarType = .Annatiton
+        case 1:
+            self.toolbarController.toolbarType = .Move
+        case 2:
+            self.toolbarController.toolbarType = .Magnify
+        case 3:
+            self.toolbarController.toolbarType = .Select
+        case 4:
+            self.toolbarController.toolbarType = .SelectZoom
+        default:
+            break
+        }
+    }
+    
+    @objc func menuItemAnnotationClick_addStype(sender: NSMenuItem) {
+        if(self.toolbarController.toolbarType == .None) {
+            self.toolbarController.toolbarType = .Annatiton
+        }
+      
+        self.listView.toolMode = .noteToolMode
+        switch sender.tag {
+        case 0:
+            self.listView.annotationType = CAnnotationType.ink
+        case 1:
+            self.listView.annotationType = CAnnotationType.freeText
+        case 2:
+            self.listView.annotationType = CAnnotationType.anchored
+        case 3:
+            self.listView.annotationType = CAnnotationType.square
+        case 4:
+            self.listView.annotationType = CAnnotationType.square
+        case 5:
+            self.listView.annotationType = CAnnotationType.line
+        case 6:
+            self.listView.annotationType = CAnnotationType.line
+        case 7:
+            self.listView.annotationType = CAnnotationType.link
+        case 8:
+            self.listView.annotationType = CAnnotationType.stamp
+        case 9:
+            self.listView.annotationType = CAnnotationType.signSignature
+        default:
+            break
+        }
+        
+        self.rightSideViewController.view.isHidden = false
+        self.rightSideViewController.subViewType = .AnnotationProperts
+    }
+    
+    @objc func menuItemBookMarkClick_add(sender:NSMenuItem) {
+        if self.listView.document.bookmark(forPageIndex: UInt(self.listView.currentPageIndex)) == nil {
+            let index = self.listView.currentPageIndex
+            self.listView.document.addBookmark("\(NSLocalizedString("Page", comment: "")) \(index+1)", forPageIndex: UInt(index))
+            self.listView.setNeedsDisplayForVisiblePages()
+        } else {
+            self.listView.document.removeBookmark(forPageIndex: UInt(self.listView.currentPageIndex))
+            self.listView.setNeedsDisplayForVisiblePages()
+        }
+        if self.leftSideViewController.type.methodType == .BookMark {
+            self.leftSideViewController.bookViewController.reloadData()
+        }
+    }
+    
+    @objc func menuItemAnnotationClick_FindString(sender:NSMenuItem) {
+        self.leftSideViewController.type.methodType = .Search;
+        self.leftSideViewController.refreshShowMethod();
+    }
+    
+    @objc func menuItemAnnotationClick_Print(sender:NSMenuItem) {
+        KMPrintWindowController.openFile(url: URL(fileURLWithPath: self.listView.document.documentURL.path))
+    }
+    
+    //MARK: action
+    
     private func cropCurrentPage() {
         var rect = NSIntegralRect(self.listView.currentSelectionRect())
         var page: CPDFPage?

+ 23 - 18
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift

@@ -33,24 +33,7 @@ extension KMMainViewController {
 extension KMMainViewController: KMToolbarControllerDelegate {
     func toolbarController(_ viewController: KMToolbarController, heightOffsetChange heightOffset: Float) {
         self.heightOffset.constant = CGFloat(heightOffset)
-        if viewController.toolbarType == .Annatiton {
-           self.listView.toolMode = .noteToolMode
-        } else if viewController.toolbarType == .Move {
-            self.listView.toolMode = .moveToolMode
-        } else if viewController.toolbarType == .Magnify {
-            self.listView.toolMode = .magnifyToolMode
-        } else if viewController.toolbarType == .Select {
-            self.listView.toolMode = .selectToolMode
-        } else if viewController.toolbarType == .SelectZoom {
-            self.listView.toolMode = .selectZoomToolMode
-        } else if viewController.toolbarType == .Page {
-            
-        } else if viewController.toolbarType == .Form {
-            self.listView.toolMode = .formToolMode
-            self.rightSideViewController.subViewType = .AnnotationProperts
-        } else {
-            self.listView.toolMode = .textToolMode
-        }
+        self.refreshListViewToolMode()
         self.listView.annotationType = .unkown
         self.rightSideViewController.view.isHidden = true
     }
@@ -64,6 +47,7 @@ extension KMMainViewController: KMToolbarControllerDelegate {
             if self.listView.currentSelection != nil {
                 self.listView.addAnnotation(with: CAnnotationType(rawValue: item.tag) ?? CAnnotationType.unkown, selection: self.listView.currentSelection, page: self.listView.currentSelection.page, bounds: self.listView.currentSelection.bounds)
             } else {
+                self.refreshListViewToolMode()
                 self.listView.annotationType = CAnnotationType(rawValue: item.tag) ?? CAnnotationType.unkown
             }
         }
@@ -85,6 +69,27 @@ extension KMMainViewController: KMToolbarControllerDelegate {
         
     }
     
+    func refreshListViewToolMode () {
+        if self.toolbarController.toolbarType == .Annatiton {
+           self.listView.toolMode = .noteToolMode
+        } else if self.toolbarController.toolbarType == .Move {
+            self.listView.toolMode = .moveToolMode
+        } else if self.toolbarController.toolbarType == .Magnify {
+            self.listView.toolMode = .magnifyToolMode
+        } else if self.toolbarController.toolbarType == .Select {
+            self.listView.toolMode = .selectToolMode
+        } else if self.toolbarController.toolbarType == .SelectZoom {
+            self.listView.toolMode = .selectZoomToolMode
+        } else if self.toolbarController.toolbarType == .Page {
+            
+        } else if self.toolbarController.toolbarType == .Form {
+            self.listView.toolMode = .formToolMode
+            self.rightSideViewController.subViewType = .AnnotationProperts
+        } else {
+            self.listView.toolMode = .textToolMode
+        }
+    }
+    
     func showPDFLayoutModeAction(show: Bool) {
         
     }

+ 35 - 0
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -320,6 +320,41 @@ import Cocoa
         return tMenuItems
     }
     
+    func pdfListViewMenu(forEvent pdfListView: CPDFListView!, for theEvent: NSEvent!, click menu: AutoreleasingUnsafeMutablePointer<NSMenu?>!) {
+        let currentMenu : NSMenu = menu.pointee!
+        if (listView.toolMode != .selectToolMode) {
+            if (listView.activeAnnotation == nil) {
+                if(currentMenu.items.count > 2) {
+                    currentMenu.insertItem(self.addAnnotationStype(), at: 2)
+                }
+                if(currentMenu.items.count > 3) {
+                    currentMenu.insertItem(self.addBookmarkMenu(), at: 3)
+                }
+                if(currentMenu.items.count > 4) {
+                    currentMenu.insertItem(NSMenuItem.separator(), at: 4)
+                }
+                if(currentMenu.items.count > 5) {
+                    currentMenu.insertItem(self.setAnnotationToolStype(), at: 5)
+                }
+                if(currentMenu.items.count > 6) {
+                    let menuItem = NSMenuItem(title: NSLocalizedString("Automatic rolling", comment: ""), action:nil, target: self)!
+                    currentMenu.insertItem(menuItem, at: 6)
+                }
+                if(currentMenu.items.count > 7) {
+                    let menuItem = NSMenuItem(title: NSLocalizedString("TTS", comment: ""), action:nil, target: self)!
+                    currentMenu.insertItem(menuItem, at: 7)
+                }
+                if(currentMenu.items.count > 8) {
+                    let menuItem = NSMenuItem(title: NSLocalizedString("menuItem", comment: ""), action:nil, target: self)!
+                    currentMenu.insertItem(menuItem, at: 8)
+                }
+                currentMenu.insertItem(NSMenuItem.separator(), at: currentMenu.items.count)
+                currentMenu.insertItem(self.findStringMenu(), at: currentMenu.items.count)
+                currentMenu.insertItem(self.printingMenu(), at: currentMenu.items.count)
+            }
+        }
+    }
+    
     func pdfListViewDidSelectionEnd(_ pdfListView: CPDFListView!) {
         if (!self.listView.isEqual(to: pdfListView)) {
             return