KMEditDocumentController.swift 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // KMEditDocumentController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by Niehaoyu on 2024/11/1.
  6. //
  7. import Cocoa
  8. class KMEditDocumentController: NSViewController {
  9. var pdfDocument: CPDFDocument?
  10. var pdfView: CPDFListView = CPDFListView.init()
  11. let coverView = NSView(frame: CGRectMake(0, 0, 300, 300))
  12. override func viewDidLoad() {
  13. super.viewDidLoad()
  14. // Do view setup here.
  15. pdfView.frame = view.bounds
  16. pdfView.autoresizingMask = [.width, .height]
  17. pdfView.setDisplay(.singlePage)
  18. pdfView.autoScales = true
  19. view.addSubview(pdfView)
  20. }
  21. func reloadData() {
  22. guard let pdfDocument = self.pdfDocument else { return }
  23. pdfView.document = pdfDocument
  24. pdfView.layoutDocumentView()
  25. }
  26. func refreshUI() {
  27. pdfView.updateRender(true)
  28. }
  29. func layoutDocumentView() {
  30. pdfView.document?.refreshPageData()
  31. pdfView.layoutDocumentView()
  32. }
  33. }