|
@@ -199,9 +199,6 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
|
|
|
mainViewController?.document = pdfDocument
|
|
|
}
|
|
|
|
|
|
- if let pdfDoc = self.mainViewController?.document {
|
|
|
- self.convertNotesUsingPDFDocument(pdfDoc)
|
|
|
- }
|
|
|
self.view = mainViewController?.view
|
|
|
|
|
|
if let currentBrowser = currentWindowController?.browser {
|
|
@@ -902,51 +899,7 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
|
|
|
@IBAction func showWindow(_ sender: Any?) {
|
|
|
KMPrint("showWindow")
|
|
|
}
|
|
|
-
|
|
|
- func convertNotesUsingPDFDocument(_ pdfDocument: CPDFDocument) {
|
|
|
- mainViewController!.beginProgressSheet(withMessage: NSLocalizedString("Converting notes", comment: "Message for progress sheet").appending("..."), maxValue: 0)
|
|
|
-
|
|
|
- let count = pdfDocument.pageCount
|
|
|
- let pdfView = mainViewController?.listView
|
|
|
-
|
|
|
- for i in 0..<count {
|
|
|
- let page = pdfDocument.page(at: i)
|
|
|
-
|
|
|
- var addAnnotations = [CPDFAnnotation]()
|
|
|
- var removeAnnotations = [CPDFAnnotation]()
|
|
|
-
|
|
|
- for annotation in page?.annotations ?? [] {
|
|
|
- var newAnnotation: CPDFAnnotation?
|
|
|
- if let inkAnnotation = annotation as? CPDFInkAnnotation, inkAnnotation.contents.hasPrefix("<?xml version=\"1.0\" encoding=\"utf-8\"?>") {
|
|
|
- let table = KMTableAnnotation(KMNoteBounds: annotation.bounds, document: pdfView!.document)
|
|
|
- table.border = annotation.border
|
|
|
- table.color = annotation.color
|
|
|
- table.createForm(withList: annotation.contents, andPaths: inkAnnotation.bezierPaths())
|
|
|
- table.updateAppearanceInk(withIsAdd: false)
|
|
|
- newAnnotation = table
|
|
|
- }
|
|
|
- if let newAnnotation = newAnnotation {
|
|
|
- addAnnotations.append(newAnnotation)
|
|
|
- removeAnnotations.append(annotation)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for i in 0..<addAnnotations.count {
|
|
|
- let newAnnotation = addAnnotations[i]
|
|
|
- let annotation = removeAnnotations[i]
|
|
|
-
|
|
|
- // this is only to make sure markup annotations generate the lineRects, for thread safety
|
|
|
- pdfView!.addAnnotation(with: newAnnotation, to: page)
|
|
|
- pdfView!.remove(annotation)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- mainViewController!.dismissProgressSheet()
|
|
|
|
|
|
- pdfView?.undoManager?.removeAllActions()
|
|
|
- undoManager?.removeAllActions()
|
|
|
- }
|
|
|
-
|
|
|
// MARK: - Private Methods
|
|
|
|
|
|
private func _PDFBundleFileWrapper(for name: String) -> FileWrapper {
|