KMEditDocumentController.swift 1023 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. }
  25. func refreshUI() {
  26. pdfView.updateRender(true)
  27. }
  28. func layoutDocumentView() {
  29. pdfView.document?.refreshPageData()
  30. pdfView.layoutDocumentView()
  31. }
  32. }