PDFNativeViewFactory.swift 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // PDFNativeViewFactory.swift
  3. // Runner
  4. //
  5. // Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
  6. //
  7. // THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
  8. // AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
  9. // UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
  10. // This notice may not be removed from this file.
  11. //
  12. import Flutter
  13. import UIKit
  14. import ComPDFKit
  15. class PDFLNativeViewFactory: NSObject, FlutterPlatformViewFactory {
  16. private var messenger: FlutterBinaryMessenger
  17. init(messenger: FlutterBinaryMessenger) {
  18. self.messenger = messenger
  19. super.init()
  20. }
  21. func create(
  22. withFrame frame: CGRect,
  23. viewIdentifier viewId: Int64,
  24. arguments args: Any?
  25. ) -> FlutterPlatformView {
  26. return FLNativeView(
  27. frame: frame,
  28. viewIdentifier: viewId,
  29. arguments: args,
  30. binaryMessenger: messenger)
  31. }
  32. }
  33. class FLNativeView: NSObject, FlutterPlatformView {
  34. private var _view: UIView
  35. init(
  36. frame: CGRect,
  37. viewIdentifier viewId: Int64,
  38. arguments args: Any?,
  39. binaryMessenger messenger: FlutterBinaryMessenger?
  40. ) {
  41. _view = UIView()
  42. super.init()
  43. // iOS views can be created here
  44. createNativeView(view: _view)
  45. }
  46. func view() -> UIView {
  47. return _view
  48. }
  49. func createNativeView(view _view: UIView){
  50. // let document = CPDFDocument(url: <#T##URL!#>)
  51. let pdfview = CPDFView(frame: _view.frame)
  52. // pdfview.document = document
  53. _view.addSubview(pdfview)
  54. }
  55. }