|
@@ -7,6 +7,7 @@
|
|
|
|
|
|
import Foundation
|
|
|
import AppKit
|
|
|
+import PDFKit
|
|
|
|
|
|
class CompareViewController: NSViewController, NSTableViewDataSource, NSTableViewDelegate, NSPopoverDelegate {
|
|
|
|
|
@@ -32,6 +33,39 @@ class CompareViewController: NSViewController, NSTableViewDataSource, NSTableVie
|
|
|
return sharedCViewController!
|
|
|
}
|
|
|
|
|
|
+ // IBAction
|
|
|
+ @IBAction func exportAction(_ sender:NSButton) {
|
|
|
+ let savePanel = NSSavePanel.init();
|
|
|
+ let checkBox = NSButton(checkboxWithTitle: "过滤无差异项", target: self, action: nil);
|
|
|
+
|
|
|
+ savePanel.allowedContentTypes = [.pdf]
|
|
|
+ savePanel.accessoryView = checkBox
|
|
|
+
|
|
|
+ if (savePanel.runModal() == .OK) {
|
|
|
+ let url = NSURL.init(fileURLWithPath: "");
|
|
|
+ let pdf = PDFDocument.init(url: url as URL);
|
|
|
+
|
|
|
+ // for ( pageCount = 0; pageCount < _photoArray.count; pageCount++) {
|
|
|
+ // BOOL isDir;
|
|
|
+ // NSString *filePath = _photoArray[pageCount];
|
|
|
+ // if ( [[NSFileManager defaultManager] fileExistsAtPath:filePath isDirectory:&isDir] && !isDir) {
|
|
|
+ // @autoreleasepool {
|
|
|
+ // NSImage *image = [[NSImage alloc] initWithContentsOfFile:filePath];
|
|
|
+ // PDFPage *page = [[PDFPage alloc] initWithImage:image];
|
|
|
+ // PDFPage *copyPage = [page copy];
|
|
|
+ // [pdf insertPage:copyPage atIndex: [pdf pageCount]];
|
|
|
+ //
|
|
|
+ // [copyPage release];
|
|
|
+ // [page release];
|
|
|
+ // [image release];
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // Show
|
|
|
func showIn(_ view:NSView?, rect:NSRect) {
|
|
|
if _popover == nil {
|
|
|
_popover = NSPopover.init()
|
|
@@ -43,6 +77,7 @@ class CompareViewController: NSViewController, NSTableViewDataSource, NSTableVie
|
|
|
_popover.show(relativeTo: rect, of: view!, preferredEdge: NSRectEdge.minX)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// Getter & Setter
|
|
|
func setFiles(_ files:NSArray) {
|
|
|
_files = files
|
|
@@ -130,4 +165,6 @@ class CompareViewController: NSViewController, NSTableViewDataSource, NSTableVie
|
|
|
func popoverShouldClose(_ popover: NSPopover) -> Bool {
|
|
|
return true
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|