소스 검색

【打印】入口补充

lizhe 10 달 전
부모
커밋
a495977037

+ 12 - 6
PDF Office/PDF Master/Class/PDFTools/Print/KMPrintWindowController.swift

@@ -8,6 +8,9 @@
 import Cocoa
 import PDFKit
 var sizeController: KMPDFPrintManageWindowController?
+var bookletWindowController: KMPDFBookletWindowController?
+var multiplePrintWindowController: KMPDFMultiplePrintWindowController?
+var posterPrintWindowController: KMPDFPosterPrintWindowController?
 
 typealias KMPrintWindowControllerPrintTypeChange = (_ controller: KMPrintWindowController, _ type: KMPrintModelType) -> Void
 
@@ -207,12 +210,15 @@ extension KMPrintWindowController {
                 KMPrintWindowController.openPrintView(document: document)
             }
             NSWindow.currentWindow().beginSheet(sizeController!.window!)
-//        case .poster:
-//
-//        case .multipage:
-//
-//        case .pamphlet:
-
+        case .poster:
+            posterPrintWindowController = KMPDFPosterPrintWindowController.init(pdfDocument: pdfDocument)
+            NSWindow.currentWindow().beginSheet(posterPrintWindowController!.window!)
+        case .multipage:
+            multiplePrintWindowController = KMPDFMultiplePrintWindowController.init(pdfDocument: pdfDocument)
+            NSWindow.currentWindow().beginSheet(multiplePrintWindowController!.window!)
+        case .pamphlet:
+            bookletWindowController = KMPDFBookletWindowController.init(document: pdfDocument)
+            NSWindow.currentWindow().beginSheet(bookletWindowController!.window!)
         default:
             break
         }

+ 8 - 0
PDF Office/PDF Master/Class/PDFTools/Print/PrintHelper/Booklet/KMPDFBookletWindowController.m

@@ -82,6 +82,8 @@ static CGFloat KMPDFBookletGenerate_PDFViewMAXWidth = 290.0;
 static CGFloat KMPDFBookletGenerate_PDFViewMAXHeight = 404.0;
 
 //打印时PDFDocument的暂存路径
+#define kPrintFolderPath [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier]
+
 #define kBookletPrintFolderPath [[[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier] stringByAppendingPathComponent:@"Booklet"]
 
 #define kBookletFileSavePath [[[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier] stringByAppendingPathComponent:@"SaveBooklet.pdf"]
@@ -608,6 +610,12 @@ static CGFloat KMPDFBookletGenerate_PDFViewMAXHeight = 404.0;
     if (self = [super initWithWindowNibName:@"KMPDFBookletWindowController"]) {
         [self showWaitting];
         dispatch_async(dispatch_get_global_queue(0, 0), ^{
+            if (![[NSFileManager defaultManager] fileExistsAtPath:kPrintFolderPath]) {
+                if (![[NSFileManager defaultManager] createDirectoryAtPath:kPrintFolderPath withIntermediateDirectories:NO attributes:nil error:nil]) {
+                    return;
+                }
+            }
+            
             [pdfDocument writeToURL:[NSURL fileURLWithPath:kBookletFileSavePath]];
             self.pdfDocument = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:kBookletFileSavePath]];
             dispatch_async(dispatch_get_main_queue(), ^{

+ 7 - 0
PDF Office/PDF Master/Class/PDFTools/Print/PrintHelper/Multiple/KMPDFMultiplePrintWindowController.m

@@ -19,6 +19,7 @@
 #define  KMPDFMultiplePrint_MaxEdge   80.0
 #define  KMPDFMultiplePrint_MaxSpace  50.0
 
+#define kPrintFolderPath [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier]
 #define kKMPDFMultiplePrint_FolderPath [[[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier] stringByAppendingPathComponent:@"Multiple"]
 
 #define kMultipleFileSavePath [[[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier] stringByAppendingPathComponent:@"Multiple.pdf"]
@@ -170,6 +171,12 @@
     if (self = [super initWithWindowNibName:@"KMPDFMultiplePrintWindowController"]) {
         [self showWaitting];
         dispatch_async(dispatch_get_global_queue(0, 0), ^{
+            if (![[NSFileManager defaultManager] fileExistsAtPath:kPrintFolderPath]) {
+                if (![[NSFileManager defaultManager] createDirectoryAtPath:kPrintFolderPath withIntermediateDirectories:NO attributes:nil error:nil]) {
+                    return;
+                }
+            }
+            
             [pdfDocument writeToURL:[NSURL fileURLWithPath:kMultipleFileSavePath]];
             self.PDFDocument = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:kMultipleFileSavePath]];
             dispatch_async(dispatch_get_main_queue(), ^{

+ 7 - 0
PDF Office/PDF Master/Class/PDFTools/Print/PrintHelper/Poster/KMPDFPosterPrintWindowController.m

@@ -18,6 +18,7 @@
 
 #define maxPrintWidth 300
 
+#define kPrintFolderPath [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier]
 #define kPosterPrintFolderPath [[[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier] stringByAppendingPathComponent:@"PosterPrint"]
 
 #define kPosterPrintFileSavePath [[[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier] stringByAppendingPathComponent:@"PosterPrint.pdf"]
@@ -187,6 +188,12 @@
         [self.labelTextField.cell setPlaceholderString:contextString];
 
         dispatch_async(dispatch_get_global_queue(0, 0), ^{
+            if (![[NSFileManager defaultManager] fileExistsAtPath:kPrintFolderPath]) {
+                if (![[NSFileManager defaultManager] createDirectoryAtPath:kPrintFolderPath withIntermediateDirectories:NO attributes:nil error:nil]) {
+                    return;
+                }
+            }
+            
             [pdfDocument writeToURL:[NSURL fileURLWithPath:kPosterPrintFileSavePath]];
             self.PDFDocument = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:kPosterPrintFileSavePath]];
             dispatch_async(dispatch_get_main_queue(), ^{

+ 7 - 1
PDF Office/PDF Master/Class/PDFTools/Print/PrintHelper/PrintManage/KMPDFPrintManageWindowController.m

@@ -20,7 +20,7 @@
 #import "PDF_Reader_Pro-Swift.h"
 #import <Quartz/Quartz.h>
 
-
+#define kPrintFolderPath [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier]
 #define kPrintManageFileSavePath [[[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier] stringByAppendingPathComponent:@"printManage.pdf"]
 
 #define kPreviewMaxWidth 207.0
@@ -122,6 +122,12 @@ typedef NS_ENUM(NSUInteger, kPageSelectStyle) {
     if (self) {
         [self showWaitting];
         dispatch_async(dispatch_get_global_queue(0, 0), ^{
+            if (![[NSFileManager defaultManager] fileExistsAtPath:kPrintFolderPath]) {
+                if (![[NSFileManager defaultManager] createDirectoryAtPath:kPrintFolderPath withIntermediateDirectories:NO attributes:nil error:nil]) {
+                    return;
+                }
+            }
+            
             self.callBack = printHandler;
             [pdfDocument writeToURL:[NSURL fileURLWithPath:kPrintManageFileSavePath]];
             self.pdfDocument = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:kPrintManageFileSavePath]];

+ 3 - 0
PDF Office/PDF Master/PDF_Reader_Pro DMG-Bridging-Header.h

@@ -125,3 +125,6 @@
 
 //打印
 #import "KMPDFPrintManageWindowController.h"
+#import "KMPDFBookletWindowController.h"
+#import "KMPDFMultiplePrintWindowController.h"
+#import "KMPDFPosterPrintWindowController.h"

+ 3 - 0
PDF Office/PDF Master/PDF_Reader_Pro Edition-Bridging-Header.h

@@ -122,3 +122,6 @@
 
 //打印
 #import "KMPDFPrintManageWindowController.h"
+#import "KMPDFBookletWindowController.h"
+#import "KMPDFMultiplePrintWindowController.h"
+#import "KMPDFPosterPrintWindowController.h"

+ 3 - 0
PDF Office/PDF Master/PDF_Reader_Pro-Bridging-Header.h

@@ -121,3 +121,6 @@
 
 //打印
 #import "KMPDFPrintManageWindowController.h"
+#import "KMPDFBookletWindowController.h"
+#import "KMPDFMultiplePrintWindowController.h"
+#import "KMPDFPosterPrintWindowController.h"