Przeglądaj źródła

【页面编辑】KMPDFEditExtractWindow OC转Swift

tangchao 1 rok temu
rodzic
commit
f91669be88

+ 16 - 0
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -3428,6 +3428,12 @@
 		BBF38A64294F53FD0086D025 /* KMWatermarkFileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBF38A61294F53FD0086D025 /* KMWatermarkFileView.swift */; };
 		BBF5D4A52A5FD2A000D09418 /* AppCenterAnalytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9F00CCC32A2F2E2400AC462E /* AppCenterAnalytics.framework */; };
 		BBF5D4A62A5FD2A500D09418 /* AppCenterCrashes.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9F00CCC42A2F2E2400AC462E /* AppCenterCrashes.framework */; };
+		BBF62C682B033B34007B7E86 /* KMPDFEditExtractWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBF62C672B033B34007B7E86 /* KMPDFEditExtractWindow.swift */; };
+		BBF62C692B033B34007B7E86 /* KMPDFEditExtractWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBF62C672B033B34007B7E86 /* KMPDFEditExtractWindow.swift */; };
+		BBF62C6A2B033B34007B7E86 /* KMPDFEditExtractWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBF62C672B033B34007B7E86 /* KMPDFEditExtractWindow.swift */; };
+		BBF62C6C2B033B5B007B7E86 /* KMPDFEditExtractWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBF62C6B2B033B5A007B7E86 /* KMPDFEditExtractWindow.xib */; };
+		BBF62C6D2B033B5B007B7E86 /* KMPDFEditExtractWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBF62C6B2B033B5A007B7E86 /* KMPDFEditExtractWindow.xib */; };
+		BBF62C6E2B033B5B007B7E86 /* KMPDFEditExtractWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBF62C6B2B033B5A007B7E86 /* KMPDFEditExtractWindow.xib */; };
 		BBF8A3FA2AE89B8500788BAC /* KMBatchHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBF8A3F92AE89B8500788BAC /* KMBatchHeader.swift */; };
 		BBF8A3FD2AE8B03B00788BAC /* KMBatchOperateFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBF8A3FC2AE8B03B00788BAC /* KMBatchOperateFile.swift */; };
 		BBF8A3FE2AE8B04100788BAC /* KMBatchOperateFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBF8A3FC2AE8B03B00788BAC /* KMBatchOperateFile.swift */; };
@@ -5007,6 +5013,8 @@
 		BBF38A59294F2B760086D025 /* KMWatermarkPositionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMWatermarkPositionView.swift; sourceTree = "<group>"; };
 		BBF38A5D294F42FF0086D025 /* KMWatermarkAdjectiveStepper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMWatermarkAdjectiveStepper.swift; sourceTree = "<group>"; };
 		BBF38A61294F53FD0086D025 /* KMWatermarkFileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMWatermarkFileView.swift; sourceTree = "<group>"; };
+		BBF62C672B033B34007B7E86 /* KMPDFEditExtractWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPDFEditExtractWindow.swift; sourceTree = "<group>"; };
+		BBF62C6B2B033B5A007B7E86 /* KMPDFEditExtractWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMPDFEditExtractWindow.xib; sourceTree = "<group>"; };
 		BBF8A3F92AE89B8500788BAC /* KMBatchHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBatchHeader.swift; sourceTree = "<group>"; };
 		BBF8A3FC2AE8B03B00788BAC /* KMBatchOperateFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBatchOperateFile.swift; sourceTree = "<group>"; };
 		BBF8A4002AE8B4E200788BAC /* KMBatchBaseParameter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBatchBaseParameter.swift; sourceTree = "<group>"; };
@@ -7909,6 +7917,7 @@
 		BB2EDF49296E6373003BCF58 /* Window */ = {
 			isa = PBXGroup;
 			children = (
+				BBF62C6B2B033B5A007B7E86 /* KMPDFEditExtractWindow.xib */,
 				BB03D69F2B024AC7008C9976 /* KMPDFEditInsertPageWindow.xib */,
 				BB10FAE82AFE03CC00F18D65 /* KMPDFEditPageRangeWindowController.xib */,
 				BB2EDF4A296E63E5003BCF58 /* KMPageEditInsertCustomPageWindowController.swift */,
@@ -7919,6 +7928,7 @@
 				BB03D68B2B01C782008C9976 /* KMPDFEditInsertBlankPageWindow.swift */,
 				BB03D68F2B01C7AA008C9976 /* KMPDFEditInsertBlankPageWindow.xib */,
 				BB03D69B2B0249A2008C9976 /* KMPDFEditInsertPageWindow.swift */,
+				BBF62C672B033B34007B7E86 /* KMPDFEditExtractWindow.swift */,
 			);
 			path = Window;
 			sourceTree = "<group>";
@@ -9964,6 +9974,7 @@
 				ADB2D6FD294882B70029D2B3 /* KMTextFieldStepperView.xib in Resources */,
 				BB69C95F299116FD0001A9B1 /* plaid.pdf in Resources */,
 				89D2D2FE294C806000BFF5FE /* KMPDFThumbnailItem.xib in Resources */,
+				BBF62C6C2B033B5B007B7E86 /* KMPDFEditExtractWindow.xib in Resources */,
 				BB6DD80F29347F77001F0544 /* KMSecureEncryptWindowController.xib in Resources */,
 				BBFD2B162AEFAC9C0016C456 /* KMBatchOperateBaseViewController.xib in Resources */,
 				AD867FAA29DFB78200F00440 /* KMAnnotationOutlineView.xib in Resources */,
@@ -10236,6 +10247,7 @@
 				AD1CA4252A061D190070541F /* KMAnnotationScreenAuthorViewItem.xib in Resources */,
 				AD1D483F2AFB81F4007AC1F0 /* KMMergeBlankView.xib in Resources */,
 				9F853A092947137500DF644E /* newtab.pdf in Resources */,
+				BBF62C6D2B033B5B007B7E86 /* KMPDFEditExtractWindow.xib in Resources */,
 				9F0CB4A329683E2600007028 /* KMPropertiesPanelSizeSubVC.xib in Resources */,
 				BB853C682AF87502009C20C1 /* KMBatchOperateRemoveWatermarkViewController.xib in Resources */,
 				ADF6B8822A485A8F0090CB78 /* KMComparativeViewCollectionItemItem.xib in Resources */,
@@ -10772,6 +10784,7 @@
 				ADE86A7D2B0221E100414DFA /* KMSecurityWindowController.xib in Resources */,
 				896DD45A2985FB3200ADE514 /* KMPageDisplayThemeCollectionViewItem.xib in Resources */,
 				9F00CCBB2A2F1E0F00AC462E /* dsa_priv.pem in Resources */,
+				BBF62C6E2B033B5B007B7E86 /* KMPDFEditExtractWindow.xib in Resources */,
 				9F0CB46C2967E5CB00007028 /* KMPropertiesPanelSubViewController.xib in Resources */,
 				AD85D1B22AF09C79000F4D28 /* KMHomeQuickToolsWindowCollectionViewItem.xib in Resources */,
 				BBC348482956A638008D2CD1 /* KMEditBackgroundController.xib in Resources */,
@@ -11482,6 +11495,7 @@
 				BBB9B31C299A5D6D004F3235 /* KMCloudOperation.m in Sources */,
 				BB981E592AD4F70D001988CA /* KMWelcomeWindowController.swift in Sources */,
 				BB8B173C2907CDD9001C5EA5 /* NibLoadable.swift in Sources */,
+				BBF62C682B033B34007B7E86 /* KMPDFEditExtractWindow.swift in Sources */,
 				BB2F9AB32AFCC2F800F9DD93 /* KMProfileInfoWindowController.swift in Sources */,
 				ADE3C1AB29A4779E00793B13 /* KMPrintAccessoryController.swift in Sources */,
 				BB8F4557295AA1270037EA22 /* KMHeaderFooterPropertyInfoController.swift in Sources */,
@@ -11882,6 +11896,7 @@
 				BB8F457B295AFB330037EA22 /* KMHeaderFooterFontInfoView.swift in Sources */,
 				BBB5C80829F4CEE40054F261 /* KMLinkAnnotationPropertyEmptyController.swift in Sources */,
 				ADAC0DE22AC273D600FD4F52 /* KMOCToolClass.swift in Sources */,
+				BBF62C692B033B34007B7E86 /* KMPDFEditExtractWindow.swift in Sources */,
 				9FDD0F892952FCC6000C4DAD /* KMCompLightParser.swift in Sources */,
 				BBD1F78C296FACA300343885 /* KMPageEditExtractSettingView.swift in Sources */,
 				ADBC375129CAE27900D93208 /* KMComparativeOutlineRowView.swift in Sources */,
@@ -12899,6 +12914,7 @@
 				AD0FA50429A8E36200EDEB50 /* KMLightMemberAlertView.swift in Sources */,
 				9F0CB53F2986571A00007028 /* KMDesignToken+Typography.swift in Sources */,
 				ADE787AC2AA5A8D3002EC85A /* KMAccountExceptionView.swift in Sources */,
+				BBF62C6A2B033B34007B7E86 /* KMPDFEditExtractWindow.swift in Sources */,
 				9F1FE49529406E4700E952CA /* common.m in Sources */,
 				BB90E4F82AF3B71800B04B9F /* KMPDFWatermarkData.swift in Sources */,
 				BBC3481E295593F0008D2CD1 /* KMBackgroundListController.swift in Sources */,

+ 142 - 0
PDF Office/PDF Master/Class/PDFTools/PageEdit/Window/KMPDFEditExtractWindow.swift

@@ -0,0 +1,142 @@
+//
+//  KMPDFEditExtractWindow.swift
+//  PDF Master
+//
+//  Created by tangchao on 2023/11/14.
+//
+
+import Cocoa
+
+class KMPDFEditExtractWindow: NSWindowController {    
+    @IBOutlet var cancelButton: NSButton!
+    @IBOutlet var extractButton: NSButton!
+    @IBOutlet var deleteExtractButton: NSButton!
+    @IBOutlet var extractAsDocumentsPerPageButton: NSButton! //每页提取为单个PDF
+    
+    var callback: ((CPDFDocument?, KMFileAttribute?, Bool, Bool)->Void)?
+    
+    private var _extractPerPageFlag = false //是否按页提取标志位;
+    private var _selectedPagesName = ""
+    private var _pdfDocument: CPDFDocument?
+    private var _attribute: KMFileAttribute?
+    
+    convenience init(document: CPDFDocument, selectedPagesName pageString: String) {
+        self.init(windowNibName: "KMPDFEditExtractWindow")
+        
+        self._selectedPagesName = pageString
+        self._pdfDocument = document
+        
+        self._attribute = KMFileAttribute()
+        self._attribute?.pagesString = pageString
+
+        if (pageString.isEmpty == false) {
+            self._selectedPagesName = pageString
+            self._attribute?.bAllPage = false
+        } else {
+            self._attribute?.bAllPage = true
+        }
+        self._attribute?.filePath = document.documentURL.path
+        self._attribute?.pdfDocument = self._pdfDocument!
+    }
+    
+    convenience init(fileURL documentPath: URL, selectedPagesName pageString: String) {
+        self.init(windowNibName: "KMPDFEditExtractWindow")
+        
+        self._selectedPagesName = pageString
+        self._pdfDocument = CPDFDocument(url: documentPath)
+        
+        self._attribute = KMFileAttribute()
+        self._attribute?.pagesString = pageString
+        if (pageString.isEmpty == false) {
+            self._selectedPagesName = pageString
+            
+            self._attribute?.bAllPage = false
+        } else {
+            self._attribute?.bAllPage = true
+        }
+        self._attribute?.filePath = documentPath.path
+        self._attribute?.pdfDocument = self._pdfDocument!
+    }
+    
+    override func windowDidLoad() {
+        super.windowDidLoad()
+    
+        self._extractPerPageFlag = false
+        self.extractAsDocumentsPerPageButton.title = KMLocalizedString("Each page in a separate file", nil)
+        
+//        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+//            if ([self.pdfDocument isEncrypted] && [self.pdfDocument isLocked]) {
+//                PasswordWindowController *com = [[PasswordWindowController alloc] initWithWindowNibName:@"PasswordWindowController"];
+//                com.fileURL = [self.pdfDocument documentURL];
+//                [com beginSheetModalForWindow:self.window completionHandler:^(NSString *password) {
+//                    if (password) {
+//                        self.attribute.password = password;
+//                        [self.pdfDocument unlockWithPassword:password];
+//                    } else {
+//                        self.pdfDocument = nil;
+//                        [NSApp endSheet:[self window]];
+//                        [[self window] orderOut:self];
+//                        [self release];
+//                    }
+//
+//                }];
+//                [com release];
+//            }
+            
+//        });
+        
+        self.window?.title =  KMLocalizedString("Extract",nil)
+        self.cancelButton.title = KMLocalizedString("Cancel",nil)
+        self.extractButton.title = KMLocalizedString("Extract",nil)
+        self.deleteExtractButton.title = KMLocalizedString("Delete pages after extraction",nil)
+        self.deleteExtractButton.wantsLayer = true
+        self.extractAsDocumentsPerPageButton.wantsLayer = true
+    }
+    
+    /*
+     - (void)updateButtonStateWithONButton:(NSButton *)sender
+     {
+         sender.state = NSControlStateValueOn;
+     }
+     */
+    
+    @IBAction func buttonItemClicked_Cancel(_ sender: AnyObject) {
+        self._pdfDocument = nil;
+
+        guard let block = self.callback else {
+            return
+        }
+        block(nil, nil, false, false)
+    }
+    
+    @IBAction func buttonItemClicked_Extract(_ sender: AnyObject) {
+        if let data = self._attribute?.fetchSelectPages().isEmpty, data {
+            let alert = NSAlert()
+            alert.alertStyle = .critical
+            alert.messageText = String(format: "%@ %@", self._attribute?.filePath.lastPathComponent ?? "", KMLocalizedString("Invalid page range or the page number is out of range. Please try again.", nil))
+            alert.runModal()
+            return
+        }
+        
+        if (self.deleteExtractButton.state == .on &&  self._pdfDocument!.pageCount == (self._attribute?.fetchSelectPages().count)!) {
+            let alert = NSAlert()
+            alert.alertStyle = .critical
+            alert.messageText = String(format: "%@ %@", self._attribute?.filePath.lastPathComponent ?? "", KMLocalizedString("Invalid page range or the page number is out of range. Please try again.", nil))
+            alert.runModal()
+            return;
+        }
+        guard let block = self.callback else {
+            return
+        }
+        block(self._pdfDocument, self._attribute, self._extractPerPageFlag, self.deleteExtractButton.state == .on)
+    }
+    
+    @IBAction func buttonItemClicked_OnePDFPerPage(_ sender: AnyObject) {
+        if (self.extractAsDocumentsPerPageButton.state == .on) {
+            self._extractPerPageFlag = true
+        } else {
+            self._extractPerPageFlag = false
+        }
+    }
+
+}

+ 93 - 0
PDF Office/PDF Master/Class/PDFTools/PageEdit/Window/KMPDFEditExtractWindow.xib

@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="18122" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+    <dependencies>
+        <deployment identifier="macosx"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18122"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="KMPDFEditExtractWindow">
+            <connections>
+                <outlet property="cancelButton" destination="eHg-SM-yHy" id="SE6-V2-P34"/>
+                <outlet property="deleteExtractButton" destination="rCY-nY-m6Y" id="dBu-y0-eJP"/>
+                <outlet property="extractAsDocumentsPerPageButton" destination="5uB-Sp-Ety" id="yAc-lL-KCG"/>
+                <outlet property="extractButton" destination="69q-zc-58G" id="wJr-U8-4M4"/>
+                <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="Extract" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5">
+            <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
+            <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+            <rect key="contentRect" x="196" y="240" width="400" height="340"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
+            <value key="minSize" type="size" width="400" height="340"/>
+            <value key="maxSize" type="size" width="400" height="340"/>
+            <view key="contentView" wantsLayer="YES" id="se5-gp-TjO">
+                <rect key="frame" x="0.0" y="0.0" width="400" height="114"/>
+                <autoresizingMask key="autoresizingMask"/>
+                <subviews>
+                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="eHg-SM-yHy">
+                        <rect key="frame" x="230" y="13" width="76" height="32"/>
+                        <buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="CY3-vf-RC6">
+                            <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                            <font key="font" metaFont="system"/>
+                            <string key="keyEquivalent" base64-UTF8="YES">
+Gw
+</string>
+                        </buttonCell>
+                        <connections>
+                            <action selector="buttonItemClicked_Cancel:" target="-2" id="bhv-L5-eTf"/>
+                        </connections>
+                    </button>
+                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="69q-zc-58G">
+                        <rect key="frame" x="299" y="13" width="78" height="32"/>
+                        <buttonCell key="cell" type="push" title="Extract" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="WWY-I2-m6l">
+                            <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="buttonItemClicked_Extract:" target="-2" id="rjI-ch-nYe"/>
+                        </connections>
+                    </button>
+                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="5uB-Sp-Ety">
+                        <rect key="frame" x="38" y="81" width="64" height="18"/>
+                        <buttonCell key="cell" type="check" title="Single" bezelStyle="regularSquare" imagePosition="left" inset="2" id="DF1-C9-pov">
+                            <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+                            <font key="font" metaFont="system"/>
+                        </buttonCell>
+                        <connections>
+                            <action selector="buttonItemClicked_OnePDFPerPage:" target="-2" id="u3r-e0-b1n"/>
+                        </connections>
+                    </button>
+                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rCY-nY-m6Y">
+                        <rect key="frame" x="38" y="57" width="65" height="18"/>
+                        <buttonCell key="cell" type="check" title="Check" bezelStyle="regularSquare" imagePosition="left" inset="2" id="Pi1-rQ-jq0">
+                            <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+                            <font key="font" metaFont="system"/>
+                        </buttonCell>
+                    </button>
+                </subviews>
+                <constraints>
+                    <constraint firstAttribute="bottom" secondItem="69q-zc-58G" secondAttribute="bottom" constant="20" id="3FE-H2-b6b"/>
+                    <constraint firstItem="5uB-Sp-Ety" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="40" id="KCE-fJ-miE"/>
+                    <constraint firstAttribute="bottom" secondItem="rCY-nY-m6Y" secondAttribute="bottom" constant="58" id="UBd-sZ-TLk"/>
+                    <constraint firstItem="69q-zc-58G" firstAttribute="centerY" secondItem="eHg-SM-yHy" secondAttribute="centerY" id="fZQ-Zo-dDL"/>
+                    <constraint firstItem="69q-zc-58G" firstAttribute="leading" secondItem="eHg-SM-yHy" secondAttribute="trailing" constant="7" id="hwH-7U-4I3"/>
+                    <constraint firstItem="rCY-nY-m6Y" firstAttribute="leading" secondItem="5uB-Sp-Ety" secondAttribute="leading" id="jMI-fn-inS"/>
+                    <constraint firstItem="5uB-Sp-Ety" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="16" id="pbo-Rv-g0K"/>
+                    <constraint firstAttribute="trailing" secondItem="69q-zc-58G" secondAttribute="trailing" constant="30" id="tra-1s-8Du"/>
+                    <constraint firstItem="rCY-nY-m6Y" firstAttribute="top" secondItem="5uB-Sp-Ety" secondAttribute="bottom" constant="8" id="vg9-Ic-3z1"/>
+                </constraints>
+            </view>
+            <connections>
+                <outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
+            </connections>
+            <point key="canvasLocation" x="113.5" y="92.5"/>
+        </window>
+    </objects>
+</document>

+ 62 - 43
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Thumbnail/Base/KMPDFThumbViewBaseController.swift

@@ -297,57 +297,76 @@ class KMPDFThumbViewBaseController: KMBaseViewController {
     
     // 提取 指定的item
     public func extractActionIndexpaths(indexpaths: Set<IndexPath>) {
-        Task { @MainActor in
-            if await (KMLightMemberManager.manager.canPayFunction() == false) {
-                let _ = KMSubscribeWaterMarkWindowController.show(window: self.view.window!, type: .extract) { isSubscribeSuccess, isWaterMarkExport, isClose in
-                    if (isClose) {
-                        return
-                    }
-                    if (isSubscribeSuccess) {
-                        self.showExtractWindow_success(indexpaths: indexpaths) { [unowned self] oneDocumentPerPage, extractAfterDelete in
-                            self._extractPages(indexpaths: indexpaths, oneDocumentPerPage: oneDocumentPerPage) { [unowned self] result, params in
-                                if (result == .failure || result == .cancel) {
-                                    return
-                                }
-                                
-                                if (extractAfterDelete) {
-                                    self.deleteIndexPaths(indexpaths: indexpaths)
-                                }
-                            }
-                        }
-                        return
-                    }
-                    if (isWaterMarkExport) {
-                        self.showExtractWindow_success(indexpaths: indexpaths) { [unowned self] oneDocumentPerPage, extractAfterDelete in
-                            self._extractPages(indexpaths: indexpaths, oneDocumentPerPage: oneDocumentPerPage, limit: true) { [unowned self] result, params in
-                                if (result == .failure || result == .cancel) {
-                                    return
-                                }
-                                
-                                if (extractAfterDelete) {
-                                    self.deleteIndexPaths(indexpaths: indexpaths)
-                                }
-                            }
-                        }
-                        return
-                    }
-
-                }
-                return
-            }
-            
-            self.showExtractWindow_success(indexpaths: indexpaths) { [unowned self] oneDocumentPerPage, extractAfterDelete in
-                self._extractPages(indexpaths: indexpaths, oneDocumentPerPage: oneDocumentPerPage) { [unowned self] result, params in
+//        Task { @MainActor in
+//            if await (KMLightMemberManager.manager.canPayFunction() == false) {
+//                let _ = KMSubscribeWaterMarkWindowController.show(window: self.view.window!, type: .extract) { isSubscribeSuccess, isWaterMarkExport, isClose in
+//                    if (isClose) {
+//                        return
+//                    }
+//                    if (isSubscribeSuccess) {
+//                        self.showExtractWindow_success(indexpaths: indexpaths) { [unowned self] oneDocumentPerPage, extractAfterDelete in
+//                            self._extractPages(indexpaths: indexpaths, oneDocumentPerPage: oneDocumentPerPage) { [unowned self] result, params in
+//                                if (result == .failure || result == .cancel) {
+//                                    return
+//                                }
+//
+//                                if (extractAfterDelete) {
+//                                    self.deleteIndexPaths(indexpaths: indexpaths)
+//                                }
+//                            }
+//                        }
+//                        return
+//                    }
+//                    if (isWaterMarkExport) {
+//                        self.showExtractWindow_success(indexpaths: indexpaths) { [unowned self] oneDocumentPerPage, extractAfterDelete in
+//                            self._extractPages(indexpaths: indexpaths, oneDocumentPerPage: oneDocumentPerPage, limit: true) { [unowned self] result, params in
+//                                if (result == .failure || result == .cancel) {
+//                                    return
+//                                }
+//
+//                                if (extractAfterDelete) {
+//                                    self.deleteIndexPaths(indexpaths: indexpaths)
+//                                }
+//                            }
+//                        }
+//                        return
+//                    }
+//
+//                }
+//                return
+//            }
+//
+//            self.showExtractWindow_success(indexpaths: indexpaths) { [unowned self] oneDocumentPerPage, extractAfterDelete in
+//                self._extractPages(indexpaths: indexpaths, oneDocumentPerPage: oneDocumentPerPage) { [unowned self] result, params in
+//                    if (result == .failure || result == .cancel) {
+//                        return
+//                    }
+//
+//                    if (extractAfterDelete) {
+//                        self.deleteIndexPaths(indexpaths: indexpaths)
+//                    }
+//                }
+//            }
+//        }
+//        let pageIndexs = self.indexpathsToIndexs(indexpaths: indexpaths)
+//        var fileName = self.thumbnailView.document?.documentURL.deletingPathExtension().lastPathComponent
+//        fileName?.append(KMPageRangeTools.newParseSelectedIndexs(selectedIndex: pageIndexs.sorted()))
+        let windowC = KMPDFEditExtractWindow(document: self.thumbnailView.document!, selectedPagesName: "")
+        windowC.callback = { [weak self] pdfDoc, fileAttribute, oneDocumentPerPage, isDeletePage in
+            self?.km_endSheet()
+            if let _ = pdfDoc {
+                self?._extractPages(indexpaths: indexpaths, oneDocumentPerPage: oneDocumentPerPage) { [unowned self] result, params in
                     if (result == .failure || result == .cancel) {
                         return
                     }
                     
-                    if (extractAfterDelete) {
-                        self.deleteIndexPaths(indexpaths: indexpaths)
+                    if (isDeletePage) {
+                        self?.deleteIndexPaths(indexpaths: indexpaths)
                     }
                 }
             }
         }
+        self.km_beginSheet(windowC: windowC)
     }
     
     // 替换 特定的item