Sfoglia il codice sorgente

PDFTools(iOS) - 传pdfView

chenyu 1 anno fa
parent
commit
25d4980fee

+ 3 - 3
compdfkit-tools/compdfkit-tools/PDFInfo/CPDFInfoViewController.h

@@ -12,7 +12,7 @@
 
 #import <UIKit/UIKit.h>
 
-@class CPDFDocument;
+@class CPDFView;
 
 NS_ASSUME_NONNULL_BEGIN
 
@@ -20,9 +20,9 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property (nonatomic,   copy) NSString * currentPath;
 
-@property (nonatomic, readonly) CPDFDocument *pdfDocument;
+@property (nonatomic, readonly) CPDFView *pdfView;
 
-- (instancetype)initWithDocument:(CPDFDocument *)pdfDocument;
+- (instancetype)initWithPDFView:(CPDFView *)pdfView;
 
 @end
 

+ 12 - 11
compdfkit-tools/compdfkit-tools/PDFInfo/CPDFInfoViewController.m

@@ -23,15 +23,16 @@
 
 @implementation CPDFInfoViewController
 
-#pragma mark life cycle
-
-- (instancetype)initWithDocument:(CPDFDocument *)pdfDocument {
+#pragma mark - Initializers
+- (instancetype)initWithPDFView:(CPDFView *)pdfView {
     if (self = [super init]) {
-        _pdfDocument = pdfDocument;
+        _pdfView = pdfView;
     }
     return self;
 }
 
+#pragma mark life cycle
+
 - (void)viewDidLoad
 {
     [super viewDidLoad];
@@ -109,8 +110,8 @@
 
 - (void) loadDocumentInfo {
 
-    NSDictionary *documentAttributes = [self.pdfDocument documentAttributes];
-    self.currentPath = self.pdfDocument.documentURL.path;
+    NSDictionary *documentAttributes = [self.pdfView.document documentAttributes];
+    self.currentPath = self.pdfView.document.documentURL.path;
     NSMutableArray* tableArray = [NSMutableArray array];
     // 1.abstract
     NSMutableArray*        mArray = [NSMutableArray array];
@@ -137,10 +138,10 @@
     
     // 2.create
     mArray = [NSMutableArray array];
-    NSString * versionString = [NSString stringWithFormat:@"%ld.%ld",(long)self.pdfDocument.majorVersion,(long)self.pdfDocument.minorVersion];
+    NSString * versionString = [NSString stringWithFormat:@"%ld.%ld",(long)self.pdfView.document.majorVersion,(long)self.pdfView.document.minorVersion];
     [mArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Version:",kDocumentInfoTitle nil),kDocumentInfoTitle, versionString, kDocumentInfoValue, nil]];
 
-    [mArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Pages:",kDocumentInfoTitle nil),kDocumentInfoTitle, [NSString stringWithFormat:@"%zd", self.pdfDocument.pageCount], kDocumentInfoValue, nil]];
+    [mArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Pages:",kDocumentInfoTitle nil),kDocumentInfoTitle, [NSString stringWithFormat:@"%zd", self.pdfView.document.pageCount], kDocumentInfoValue, nil]];
     if (documentAttributes[CPDFDocumentCreatorAttribute]) {
         [mArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Creator:",kDocumentInfoTitle nil),kDocumentInfoTitle, documentAttributes[CPDFDocumentCreatorAttribute], kDocumentInfoValue, nil]];
     }
@@ -200,13 +201,13 @@
     // 3.execute
     mArray = [NSMutableArray array];
     
-    [mArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Encrypted:",kDocumentInfoTitle nil),kDocumentInfoTitle, ((self.pdfDocument.isEncrypted == YES) ? NSLocalizedString(@"YES", nil) : NSLocalizedString(@"NO", nil)), kDocumentInfoValue, nil]];
+    [mArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Encrypted:",kDocumentInfoTitle nil),kDocumentInfoTitle, ((self.pdfView.document.isEncrypted == YES) ? NSLocalizedString(@"YES", nil) : NSLocalizedString(@"NO", nil)), kDocumentInfoValue, nil]];
 
     [mArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Unlocked:",kDocumentInfoTitle nil),kDocumentInfoTitle, NSLocalizedString(@"YES", nil), kDocumentInfoValue, nil]];
 
-    [mArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"AllowsCopying:",kDocumentInfoTitle nil),kDocumentInfoTitle, (self.pdfDocument.allowsCopying ? NSLocalizedString(@"YES", nil) : NSLocalizedString(@"NO", nil)), kDocumentInfoValue, nil]];
+    [mArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"AllowsCopying:",kDocumentInfoTitle nil),kDocumentInfoTitle, (self.pdfView.document.allowsCopying ? NSLocalizedString(@"YES", nil) : NSLocalizedString(@"NO", nil)), kDocumentInfoValue, nil]];
 
-    [mArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"AllowsPrinting:",kDocumentInfoTitle nil),kDocumentInfoTitle, (self.pdfDocument.allowsPrinting ? NSLocalizedString(@"YES", nil) : NSLocalizedString(@"NO", nil)), kDocumentInfoValue, nil]];
+    [mArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"AllowsPrinting:",kDocumentInfoTitle nil),kDocumentInfoTitle, (self.pdfView.document.allowsPrinting ? NSLocalizedString(@"YES", nil) : NSLocalizedString(@"NO", nil)), kDocumentInfoValue, nil]];
     
 
     [tableArray addObject:mArray];