12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- //
- // KMEditDocumentController.swift
- // PDF Reader Pro
- //
- // Created by Niehaoyu on 2024/11/1.
- //
- import Cocoa
- class KMEditDocumentController: NSViewController {
-
- var pdfDocument: CPDFDocument?
-
- var pdfView: CPDFListView = CPDFListView.init()
-
- let coverView = NSView(frame: CGRectMake(0, 0, 300, 300))
-
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do view setup here.
-
- pdfView.frame = view.bounds
- pdfView.autoresizingMask = [.width, .height]
- pdfView.setDisplay(.singlePage)
- pdfView.toolMode = .CMoveToolMode
- pdfView.autoScales = true
- view.addSubview(pdfView)
-
- }
-
- func reloadData() {
- guard let pdfDocument = self.pdfDocument else { return }
-
- DispatchQueue.main.async {
- self.pdfView.document = pdfDocument
- self.pdfView.layoutDocumentView()
- }
-
- }
-
- func refreshUI() {
- pdfView.updateRender(true)
-
- DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.15) {[weak self] in
- self?.pdfView.updateRender(true)
- }
- }
-
- func layoutDocumentView() {
- pdfView.document?.refreshPageData()
- pdfView.layoutDocumentView()
-
- }
-
- }
|