CPDFViewController.m 826 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // CPDFViewController.m
  3. // PDFViewer
  4. //
  5. // Created by kdan on 2022/11/15.
  6. //
  7. #import <ComPDFKit/ComPDFKit.h>
  8. #import "CPDFViewController.h"
  9. @interface CPDFViewController ()
  10. @end
  11. @implementation CPDFViewController
  12. - (instancetype)initWithPath:(NSString *)inPath {
  13. if (self = [super init]) {
  14. _path = inPath;
  15. }
  16. return self;
  17. }
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. // Do any additional setup after loading the view.
  21. NSURL *url = [NSURL fileURLWithPath:_path];
  22. CPDFDocument *document = [[CPDFDocument alloc] initWithURL:url];
  23. CPDFView *pdfView = [[CPDFView alloc] initWithFrame:self.view.bounds];
  24. pdfView.document = document;
  25. pdfView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  26. [self.view addSubview:pdfView];
  27. }
  28. @end