Browse Source

PDFTools(iOS) - CPDFBookmark模块的增加

yangliuhua 1 year ago
parent
commit
ec9cb57759
22 changed files with 517 additions and 50 deletions
  1. 28 0
      compdfkit-tools/compdfkit-tools.xcodeproj/project.pbxproj
  2. 27 23
      compdfkit-tools/compdfkit-tools/Common/Controls/BOTA/CPDFBOTAViewController.m
  3. 1 1
      compdfkit-tools/compdfkit-tools/Common/Views/PDFView/PDFSliderView/CPDFSlider.m
  4. 30 0
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/CPDFBookmarkViewCell.h
  5. 66 0
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/CPDFBookmarkViewCell.m
  6. 37 0
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/CPDFBookmarkViewController.h
  7. 207 0
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/CPDFBookmarkViewController.m
  8. 23 0
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageAdd.imageset/Contents.json
  9. BIN
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageAdd.imageset/signature_icon_add.png
  10. BIN
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageAdd.imageset/signature_icon_add@2x.png
  11. BIN
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageAdd.imageset/signature_icon_add@3x.png
  12. 22 0
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageDelete.imageset/Contents.json
  13. BIN
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageDelete.imageset/pageedit_delete.png
  14. BIN
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageDelete.imageset/pageedit_delete@2x.png
  15. 22 0
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageEdit.imageset/Contents.json
  16. BIN
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageEdit.imageset/add_newpage01.png
  17. BIN
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageEdit.imageset/add_newpage01@2x.png
  18. 22 0
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageMore.imageset/Contents.json
  19. BIN
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageMore.imageset/btn_more.png
  20. BIN
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageMore.imageset/btn_more@2x.png
  21. 6 0
      compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/Contents.json
  22. 26 26
      compdfkit-tools/compdfkit-tools/Viewer/PDFSearch/CSearchToolbar.m

+ 28 - 0
compdfkit-tools/compdfkit-tools.xcodeproj/project.pbxproj

@@ -8,6 +8,11 @@
 
 /* Begin PBXBuildFile section */
 		C9AF182629EE8AB600EC4979 /* UtilsColor.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C9AF182529EE8AB600EC4979 /* UtilsColor.xcassets */; };
+		C9AF182C29EFB1FC00EC4979 /* CPDFBookmarkViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = C9AF182A29EFB1FC00EC4979 /* CPDFBookmarkViewCell.h */; };
+		C9AF182D29EFB1FC00EC4979 /* CPDFBookmarkViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C9AF182B29EFB1FC00EC4979 /* CPDFBookmarkViewCell.m */; };
+		C9AF183029EFB23C00EC4979 /* CPDFBookmarkViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = C9AF182E29EFB23C00EC4979 /* CPDFBookmarkViewController.h */; };
+		C9AF183129EFB23C00EC4979 /* CPDFBookmarkViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C9AF182F29EFB23C00EC4979 /* CPDFBookmarkViewController.m */; };
+		C9AF183329EFC63300EC4979 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C9AF183229EFC63300EC4979 /* Images.xcassets */; };
 		C9B0CE1829E6486700524B7F /* ComPDFKit.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = F313657129E4367A00EE6BBB /* ComPDFKit.xcframework */; };
 		F32DA16229ED904300E19ECA /* CPDFOutlineModel.h in Headers */ = {isa = PBXBuildFile; fileRef = F32DA12229ED904300E19ECA /* CPDFOutlineModel.h */; };
 		F32DA16329ED904300E19ECA /* Image.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F32DA12329ED904300E19ECA /* Image.xcassets */; };
@@ -66,6 +71,11 @@
 
 /* Begin PBXFileReference section */
 		C9AF182529EE8AB600EC4979 /* UtilsColor.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = UtilsColor.xcassets; sourceTree = "<group>"; };
+		C9AF182A29EFB1FC00EC4979 /* CPDFBookmarkViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFBookmarkViewCell.h; sourceTree = "<group>"; };
+		C9AF182B29EFB1FC00EC4979 /* CPDFBookmarkViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFBookmarkViewCell.m; sourceTree = "<group>"; };
+		C9AF182E29EFB23C00EC4979 /* CPDFBookmarkViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFBookmarkViewController.h; sourceTree = "<group>"; };
+		C9AF182F29EFB23C00EC4979 /* CPDFBookmarkViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFBookmarkViewController.m; sourceTree = "<group>"; };
+		C9AF183229EFC63300EC4979 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
 		F313657129E4367A00EE6BBB /* ComPDFKit.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = ComPDFKit.xcframework; path = ../Lib/ComPDFKit.xcframework; sourceTree = "<group>"; };
 		F32DA12229ED904300E19ECA /* CPDFOutlineModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPDFOutlineModel.h; sourceTree = "<group>"; };
 		F32DA12329ED904300E19ECA /* Image.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Image.xcassets; sourceTree = "<group>"; };
@@ -146,6 +156,18 @@
 			path = Utils;
 			sourceTree = "<group>";
 		};
+		C9AF182929EF9D2400EC4979 /* PDFBookmark */ = {
+			isa = PBXGroup;
+			children = (
+				C9AF182A29EFB1FC00EC4979 /* CPDFBookmarkViewCell.h */,
+				C9AF182B29EFB1FC00EC4979 /* CPDFBookmarkViewCell.m */,
+				C9AF182E29EFB23C00EC4979 /* CPDFBookmarkViewController.h */,
+				C9AF182F29EFB23C00EC4979 /* CPDFBookmarkViewController.m */,
+				C9AF183229EFC63300EC4979 /* Images.xcassets */,
+			);
+			path = PDFBookmark;
+			sourceTree = "<group>";
+		};
 		F313657029E4367A00EE6BBB /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
@@ -157,6 +179,7 @@
 		F32DA12029ED904300E19ECA /* Viewer */ = {
 			isa = PBXGroup;
 			children = (
+				C9AF182929EF9D2400EC4979 /* PDFBookmark */,
 				F32DA12129ED904300E19ECA /* PDFOutlie */,
 				F32DA12929ED904300E19ECA /* PDFSearch */,
 				F32DA13129ED904300E19ECA /* PDFThumbnail */,
@@ -438,8 +461,10 @@
 				F32DA19129ED908800E19ECA /* CPDFMoreListViewController.h in Headers */,
 				F32DA17029ED904300E19ECA /* CPDFThumbnailViewCell.h in Headers */,
 				F32DA17929ED904300E19ECA /* CPDFDisplayViewController.h in Headers */,
+				C9AF183029EFB23C00EC4979 /* CPDFBookmarkViewController.h in Headers */,
 				F32DA16C29ED904300E19ECA /* CPDFSearchResultsViewController.h in Headers */,
 				F382636829EFD0D9003F1DFD /* CPDFPageIndicatorView.h in Headers */,
+				C9AF182C29EFB1FC00EC4979 /* CPDFBookmarkViewCell.h in Headers */,
 				F32DA16529ED904300E19ECA /* CPDFOutlineViewController.h in Headers */,
 				F38F60C629EFF0C2008098F8 /* CPDFColorUtils.h in Headers */,
 				F32DA17829ED904300E19ECA /* CPDFDisplayTableViewCell.h in Headers */,
@@ -507,6 +532,7 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				C9AF183329EFC63300EC4979 /* Images.xcassets in Resources */,
 				F32DA16E29ED904300E19ECA /* Images.xcassets in Resources */,
 				F32DA18629ED904300E19ECA /* Image.xcassets in Resources */,
 				F3E8495929E69712007BE967 /* DisplayImage.xcassets in Resources */,
@@ -546,7 +572,9 @@
 				F32DA18329ED904300E19ECA /* CNavigationRightView.m in Sources */,
 				F32DA17729ED904300E19ECA /* CPDFInfoTableCell.m in Sources */,
 				F32DA16B29ED904300E19ECA /* CSearchToolbar.m in Sources */,
+				C9AF183129EFB23C00EC4979 /* CPDFBookmarkViewController.m in Sources */,
 				F32DA17629ED904300E19ECA /* CPDFInfoViewController.m in Sources */,
+				C9AF182D29EFB1FC00EC4979 /* CPDFBookmarkViewCell.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

+ 27 - 23
compdfkit-tools/compdfkit-tools/Common/Controls/BOTA/CPDFBOTAViewController.m

@@ -13,11 +13,12 @@
 #import "CPDFBOTAViewController.h"
 #import "CPDFThumbnailViewController.h"
 #import "CPDFOutlineViewController.h"
+#import "CPDFBookmarkViewController.h"
 #import "CPDFColorUtils.h"
 
 #import <ComPDFKit/ComPDFKit.h>
 
-@interface CPDFBOTAViewController () <CPDFOutlineViewControllerDelegate, CPDFThumbnailViewControllerDelegate>
+@interface CPDFBOTAViewController () <CPDFThumbnailViewControllerDelegate, CPDFBookmarkViewControllerDelegate>
 
 @property (nonatomic, assign) NSInteger pageIndex;
 @property (nonatomic, strong) UISegmentedControl *segmentedControl;
@@ -25,6 +26,7 @@
 
 @property (nonatomic, strong) CPDFThumbnailViewController *thumbnailViewController;
 @property (nonatomic, strong) CPDFOutlineViewController *outlineViewController;
+@property (nonatomic, strong) CPDFBookmarkViewController *bookmarkViewController;
 
 @end
 
@@ -42,6 +44,16 @@
 
 #pragma mark - Accessors
 
+- (CPDFBookmarkViewController *)bookmarkViewController {
+    if (!_bookmarkViewController) {
+        _bookmarkViewController = [[CPDFBookmarkViewController alloc] initWithPDFView:self.pdfView];
+        _bookmarkViewController.view.frame = CGRectMake(0, self.view.safeAreaInsets.top, self.view.bounds.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, self.view.bounds.size.height - self.view.safeAreaInsets.top - self.view.safeAreaInsets.bottom);
+        _bookmarkViewController.delegate = self;
+        _bookmarkViewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin;
+        [self addChildViewController:_bookmarkViewController];
+    }
+    return _bookmarkViewController;
+}
 
 #pragma mark - UIViewController Methods
 
@@ -52,31 +64,23 @@
 
     self.view.backgroundColor = [CPDFColorUtils CPDFViewControllerBackgroundColor];
     
-    NSArray *segmmentArray = [NSArray arrayWithObjects:NSLocalizedString(@"Thumbnail", nil), NSLocalizedString(@"Outline", nil), nil];
-    CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
-    self.segmentedControl = [[UISegmentedControl alloc] initWithItems:segmmentArray];
-    self.segmentedControl.frame = CGRectMake(self.view.frame.size.width / 4, self.navigationController.navigationBar.frame.size.height + MIN(statusBarFrame.size.width, statusBarFrame.size.height) + 5 , self.view.frame.size.width / 2, 30);
-    [self.segmentedControl addTarget:self action:@selector(segmentedControlValueChanged_BOTA:) forControlEvents:UIControlEventValueChanged];
-    self.segmentedControl.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
-    
-    
     self.thumbnailViewController = [[CPDFThumbnailViewController alloc] initWithPDFView:self.pdfView];
     self.thumbnailViewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin;
     self.thumbnailViewController.delegate = self;
     [self addChildViewController:_thumbnailViewController];
     
-    self.thumbnailViewController.view.frame = CGRectMake(0, self.navigationController.navigationBar.frame.size.height + MIN(statusBarFrame.size.width, statusBarFrame.size.height) + 45, self.view.bounds.size.width, self.view.bounds.size.height);
-    
+    self.thumbnailViewController.view.frame = CGRectMake(0, self.view.safeAreaInsets.top, self.view.bounds.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, self.view.bounds.size.height - self.view.safeAreaInsets.top - self.view.safeAreaInsets.bottom);
     
-    self.outlineViewController = [[CPDFOutlineViewController alloc] initWithPDFView:self.pdfView];
-    self.outlineViewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin;
-    self.outlineViewController.delegate = self;
-        [self addChildViewController:_outlineViewController];
-    self.outlineViewController.view.frame = CGRectMake(0, self.navigationController.navigationBar.frame.size.height + MIN(statusBarFrame.size.width, statusBarFrame.size.height) + 45, self.view.bounds.size.width, self.view.bounds.size.height);
     
-    self.segmentedControl.selectedSegmentIndex = 0;
+    NSArray *segmmentArray = [NSArray arrayWithObjects:NSLocalizedString(@"Thumbnail", nil), NSLocalizedString(@"Book mark", nil), nil];
+    _segmentedControl = [[UISegmentedControl alloc] initWithItems:segmmentArray];
+    _segmentedControl.selectedSegmentIndex = 0;
+    _segmentedControl.frame = CGRectMake(self.view.frame.size.width / 4, 0 , self.view.frame.size.width / 2, 30);
+    [_segmentedControl addTarget:self action:@selector(segmentedControlValueChanged_BOTA:) forControlEvents:UIControlEventValueChanged];
     [self.view addSubview:self.segmentedControl];
     
+    self.navigationItem.titleView = self.segmentedControl;
+    
     self.currentViewController = self.thumbnailViewController;
     [self.view addSubview:self.thumbnailViewController.view];
 }
@@ -90,14 +94,14 @@
         self.currentViewController = self.thumbnailViewController;
         [self.view addSubview:self.thumbnailViewController.view];
     } else if (self.segmentedControl.selectedSegmentIndex == 1) {
-        self.currentViewController = self.outlineViewController;
-        [self.view addSubview:self.outlineViewController.view];
+        self.currentViewController = self.bookmarkViewController;
+        [self.view addSubview:self.bookmarkViewController.view];
     }
 }
 
-#pragma mark - CPDFOutlineViewControllerDelegate
+#pragma mark - CPDFThumbnailViewControllerDelegate
 
-- (void)outlineViewController:(CPDFOutlineViewController *)outlineViewController pageIndex:(NSInteger)pageIndex {
+- (void)thumbnailViewController:(CPDFThumbnailViewController *)thumbnailViewController pageIndex:(NSInteger)pageIndex {
     [self.pdfView goToPageIndex:pageIndex animated:NO];
     
     if([self.delegate respondsToSelector:@selector(botaViewControllerDismiss:)]) {
@@ -105,9 +109,9 @@
     }
 }
 
-#pragma mark - CPDFThumbnailViewControllerDelegate
+#pragma mark - CPDFBookmarkViewControllerDelegate
 
-- (void)thumbnailViewController:(CPDFThumbnailViewController *)thumbnailViewController pageIndex:(NSInteger)pageIndex {
+- (void)boomarkViewController:(CPDFBookmarkViewController *)bookmarkViewController pageIndex:(NSInteger)pageIndex {
     [self.pdfView goToPageIndex:pageIndex animated:NO];
     
     if([self.delegate respondsToSelector:@selector(botaViewControllerDismiss:)]) {

+ 1 - 1
compdfkit-tools/compdfkit-tools/Common/Views/PDFView/PDFSliderView/CPDFSlider.m

@@ -105,7 +105,7 @@
     pageIndex = MAX(0, pageIndex);
     pageIndex = MIN(pageIndex, [self.pdfView.document pageCount]-1);
     
-    self.label.text = [NSString stringWithFormat:@"%@",@(pageIndex+1)];
+    self.label.text = [NSString stringWithFormat:@"%@/%@",@(pageIndex+1),@([self.pdfView.document pageCount])];
     [self.label sizeToFit];
     self.label.frame = CGRectMake(0, 0,
                                   CGRectGetWidth(self.label.frame)+20,

+ 30 - 0
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/CPDFBookmarkViewCell.h

@@ -0,0 +1,30 @@
+//
+//  CPDFBookmarkViewCell.h
+//  compdfkit-tools
+//
+//  Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+//
+//  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+//  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+//  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface CPDFBookmarkViewCell : UITableViewCell
+
+@property (nonatomic, strong) UILabel *titleLabel;
+
+@property (nonatomic, strong) UILabel *pageIndexLabel;
+
+@property (nonatomic, strong) UIButton *moreButton;
+
+@property (nonatomic, strong) UIButton *deleteButton;
+
+@property (nonatomic, strong) UIButton *editButton;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 66 - 0
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/CPDFBookmarkViewCell.m

@@ -0,0 +1,66 @@
+//
+//  CPDFBookmarkViewCell.m
+//  compdfkit-tools
+//
+//  Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+//
+//  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+//  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+//  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+// 
+
+#import "CPDFBookmarkViewCell.h"
+
+@implementation CPDFBookmarkViewCell
+
+- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
+    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
+        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, self.bounds.size.width - 100, self.bounds.size.height - 10)];
+        _titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+        
+        _pageIndexLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.size.width - 110, 5, 60, self.bounds.size.height - 10)];
+        _pageIndexLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
+        
+        _editButton = [[UIButton alloc] initWithFrame:CGRectMake(self.bounds.size.width - 40, 5, 30, self.bounds.size.height - 10)];
+        [_editButton addTarget:self action:@selector(buttonItemClicked_edit:) forControlEvents:UIControlEventTouchUpInside];
+        _editButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
+        [_editButton setImage:[UIImage imageNamed:@"CPDFBookmarkImageMore" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
+        
+        [self.contentView addSubview:self.titleLabel];
+        [self.contentView addSubview:self.pageIndexLabel];
+        [self.contentView addSubview:self.editButton];
+    }
+    return self;
+}
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    // Initialization code
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+    [super setSelected:selected animated:animated];
+
+    // Configure the view for the selected state
+}
+
+#pragma mark - Action
+
+- (void)buttonItemClicked_edit:(id)sender {
+    UITableView *tableView = [self getTableView];
+        if (tableView) {
+            NSIndexPath *indexPath = [tableView indexPathForCell:self];
+            [tableView setEditing:YES animated:YES];
+            [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
+        }
+}
+
+- (UITableView *)getTableView {
+    UIView *tableView = self.superview;
+    while (![tableView isKindOfClass:[UITableView class]] && tableView != nil) {
+        tableView = tableView.superview;
+    }
+    return (UITableView *)tableView;
+}
+
+@end

+ 37 - 0
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/CPDFBookmarkViewController.h

@@ -0,0 +1,37 @@
+//
+//  CPDFBookmarkViewController.h
+//  compdfkit-tools
+//
+//  Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+//
+//  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+//  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+//  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+// 
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@class CPDFView;
+@class CPDFBookmarkViewController;
+
+@protocol CPDFBookmarkViewControllerDelegate <NSObject>
+
+@optional
+
+- (void)boomarkViewController:(CPDFBookmarkViewController *)bookmarkViewController pageIndex:(NSInteger)pageIndex;
+
+@end
+
+@interface CPDFBookmarkViewController : UIViewController
+
+@property (nonatomic, readonly) CPDFView *pdfView;
+
+@property (nonatomic, weak) id<CPDFBookmarkViewControllerDelegate> delegate;
+
+- (instancetype)initWithPDFView:(CPDFView *)pdfView;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 207 - 0
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/CPDFBookmarkViewController.m

@@ -0,0 +1,207 @@
+//
+//  CPDFBookmarkViewController.m
+//  compdfkit-tools
+//
+//  Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+//
+//  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+//  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+//  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+// 
+
+#import "CPDFBookmarkViewController.h"
+#import "CPDFBookmarkViewCell.h"
+
+#import <ComPDFKit/ComPDFKit.h>
+
+@interface CPDFBookmarkViewController () <UITableViewDelegate, UITableViewDataSource>
+
+@property (nonatomic, strong) NSArray *bookmarks;
+
+@property (nonatomic, strong) UITableView *tableView;
+
+@property (nonatomic, strong) UILabel *noDataLabel;
+
+@property (nonatomic, strong) UIButton *addBookmarkBtn;
+
+@end
+
+@implementation CPDFBookmarkViewController
+
+#pragma mark - Initializers
+
+- (instancetype)initWithPDFView:(CPDFView *)pdfView {
+    if (self = [super init]) {
+        _pdfView = pdfView;
+    }
+    return self;
+}
+
+#pragma mark - UIViewController Methods
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
+    _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+    _tableView.delegate = self;
+    _tableView.dataSource = self;
+    _tableView.rowHeight = UITableViewAutomaticDimension;
+    _tableView.estimatedRowHeight = 60;
+    _tableView.tableFooterView = [[UIView alloc] init];
+//    [_tableView setEditing:YES animated:YES];
+    [self.view addSubview:self.tableView];
+    
+    _noDataLabel = [[UILabel alloc] init];
+    _noDataLabel.textColor = [UIColor grayColor];
+    _noDataLabel.text = NSLocalizedString(@"No bookmark", nil);
+    [_noDataLabel sizeToFit];
+    _noDataLabel.center = CGPointMake(self.view.bounds.size.width/2.0, self.view.bounds.size.height/2.0);
+    _noDataLabel.autoresizingMask = UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
+    [self.view addSubview:self.noDataLabel];
+    
+    _addBookmarkBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width - self.view.safeAreaInsets.right - 60, self.view.frame.size.height - self.view.safeAreaInsets.bottom - 60, 60, 60)];
+    _addBookmarkBtn.layer.cornerRadius = 30;
+    _addBookmarkBtn.layer.masksToBounds = YES;
+    _addBookmarkBtn.layer.borderWidth = 1.0;
+    _addBookmarkBtn.layer.borderColor = [UIColor blueColor].CGColor;
+    _addBookmarkBtn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
+    [_addBookmarkBtn setImage:[UIImage imageNamed:@"CPDFBookmarkImageAdd" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
+    [_addBookmarkBtn addTarget:self action:@selector(buttonItemClicked_add:) forControlEvents:UIControlEventTouchUpInside];
+    [self.view addSubview:self.addBookmarkBtn];
+    
+    [self createGestureRecognizer];
+}
+
+- (void)viewDidAppear:(BOOL)animated {
+    [super viewDidAppear:animated];
+    
+    [self reloadData];
+}
+
+#pragma mark - Private Methods
+
+- (void)reloadData {
+    if ([self.pdfView.document bookmarks].count > 0) {
+        self.bookmarks = [self.pdfView.document bookmarks];
+        [self.tableView reloadData];
+        self.tableView.hidden = NO;
+        self.noDataLabel.hidden = YES;
+    } else {
+        self.tableView.hidden = YES;
+        self.noDataLabel.hidden = NO;
+    }
+}
+
+- (void)createGestureRecognizer {
+    [self.addBookmarkBtn setUserInteractionEnabled:YES];
+
+    UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panaddBookmarkBtn:)];
+    [self.addBookmarkBtn addGestureRecognizer:panRecognizer];
+}
+
+- (void)panaddBookmarkBtn:(UIPanGestureRecognizer *)recognizer {
+    CGPoint point = [recognizer translationInView:_tableView];
+    CGRect documentFrame = _tableView.frame;
+    documentFrame.origin.x -= _tableView.frame.origin.x;
+    documentFrame.origin.y -= _tableView.frame.origin.y;
+    
+    [_addBookmarkBtn setCenter:CGPointMake(_addBookmarkBtn.center.x + point.x, _addBookmarkBtn.center.y + point.y)];
+    
+    if (!CGRectContainsRect(documentFrame,_addBookmarkBtn.frame)) {
+        [_addBookmarkBtn setCenter:CGPointMake(_addBookmarkBtn.center.x - point.x, _addBookmarkBtn.center.y - point.y)];
+    }
+}
+
+#pragma mark - Action
+
+- (void)buttonItemClicked_add:(id)sender {
+    if (![self.pdfView.document bookmarkForPageIndex:self.pdfView.currentPageIndex]) {
+        [self.pdfView.document addBookmark:[NSString stringWithFormat:@"my page %lu", self.pdfView.currentPageIndex+1] forPageIndex:self.pdfView.currentPageIndex];
+        [self reloadData];
+    } else {
+        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil)
+                                                               style:UIAlertActionStyleCancel
+                                                             handler:nil];
+        UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil
+                                                                       message:NSLocalizedString(@"You've bookmarked about this", nil)
+                                                                preferredStyle:UIAlertControllerStyleAlert];
+        [alert addAction:cancelAction];
+    
+        [self presentViewController:alert animated:YES completion:nil];
+    }
+}
+
+#pragma mark - UITableViewDataSource
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    if (self.bookmarks.count > 0) {
+        self.noDataLabel.hidden = YES;
+    } else {
+        self.noDataLabel.hidden = NO;
+    }
+    return self.bookmarks.count;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    CPDFBookmarkViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
+    if (cell == nil) {
+        cell = [[CPDFBookmarkViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
+    }
+    
+    CPDFBookmark *bookmark = self.bookmarks[indexPath.row];
+    cell.pageIndexLabel.text = [NSString stringWithFormat:@"page %ld", bookmark.pageIndex+1];
+    cell.titleLabel.text = bookmark.label;
+    
+    return cell;
+}
+
+#pragma mark - UITableViewDelegate
+
+- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
+    return YES;
+}
+
+- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
+    UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
+        CPDFBookmarkViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
+        [self.pdfView.document removeBookmarkForPageIndex:cell.pageIndexLabel.text.floatValue - 1];
+        NSMutableArray *bookmarks = (NSMutableArray *)self.bookmarks;
+        [bookmarks removeObjectAtIndex:indexPath.row];
+        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:YES];
+        [self reloadData];
+    }];
+    
+    UITableViewRowAction *editAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"edit" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
+        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@" " message:nil preferredStyle:UIAlertControllerStyleAlert];
+        [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {}];
+            
+        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:nil];
+        
+        UIAlertAction *addAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Add", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            CPDFBookmarkViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
+            cell.titleLabel.text = alert.textFields.firstObject.text;
+        }];
+        
+        [alert addAction:cancelAction];
+        [alert addAction:addAction];
+        
+        [self presentViewController:alert animated:YES completion:nil];
+    }];
+    
+    deleteAction.backgroundColor = [UIColor redColor];
+    editAction.backgroundColor = [UIColor blueColor];
+    return @[deleteAction, editAction];
+}
+
+- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
+    return UITableViewCellEditingStyleDelete;
+}
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+    if ([self.delegate respondsToSelector:@selector(boomarkViewController:pageIndex:)]) {
+        [self.delegate boomarkViewController:self pageIndex:indexPath.row + 1];
+    }
+}
+
+@end

+ 23 - 0
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageAdd.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "filename" : "signature_icon_add.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "signature_icon_add@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "signature_icon_add@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageAdd.imageset/signature_icon_add.png


BIN
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageAdd.imageset/signature_icon_add@2x.png


BIN
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageAdd.imageset/signature_icon_add@3x.png


+ 22 - 0
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageDelete.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "filename" : "pageedit_delete.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "pageedit_delete@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageDelete.imageset/pageedit_delete.png


BIN
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageDelete.imageset/pageedit_delete@2x.png


+ 22 - 0
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageEdit.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "filename" : "add_newpage01.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "add_newpage01@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageEdit.imageset/add_newpage01.png


BIN
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageEdit.imageset/add_newpage01@2x.png


+ 22 - 0
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageMore.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "filename" : "btn_more.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "btn_more@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageMore.imageset/btn_more.png


BIN
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/CPDFBookmarkImageMore.imageset/btn_more@2x.png


+ 6 - 0
compdfkit-tools/compdfkit-tools/Viewer/PDFBookmark/Images.xcassets/Contents.json

@@ -0,0 +1,6 @@
+{
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

+ 26 - 26
compdfkit-tools/compdfkit-tools/Viewer/PDFSearch/CSearchToolbar.m

@@ -33,9 +33,9 @@
 
 @property (nonatomic, strong) UIButton *doneItem;
 
-@property (nonatomic, assign) NSInteger nowSection;
+@property (nonatomic, assign) NSInteger nowPageIndex;
 
-@property (nonatomic, assign) NSInteger nowRow;
+@property (nonatomic, assign) NSInteger nowNumber;
 
 @property (nonatomic, strong) NSArray *resultArray;
 
@@ -136,12 +136,12 @@
                     [alert addAction:cancelAction];
                     [tRootViewControl presentViewController:alert animated:YES completion:nil];
                 } else {
-                    block_self.nowRow = 0;
-                    block_self.nowSection = 0;
-                    if(block_self.resultArray.count > block_self.nowSection) {
-                        NSArray *selections = [block_self.resultArray objectAtIndex:block_self.nowSection];
-                        if(selections.count > block_self.nowRow) {
-                            CPDFSelection *selection = [selections objectAtIndex:block_self.nowRow];
+                    block_self.nowNumber = 0;
+                    block_self.nowPageIndex = 0;
+                    if(block_self.resultArray.count > block_self.nowPageIndex) {
+                        NSArray *selections = [block_self.resultArray objectAtIndex:block_self.nowPageIndex];
+                        if(selections.count > block_self.nowNumber) {
+                            CPDFSelection *selection = [selections objectAtIndex:block_self.nowNumber];
                             NSInteger pageIndex = [block_self.pdfView.document indexForPage:selection.page];
                             
                             [self.pdfView goToPageIndex:pageIndex animated:NO];
@@ -165,8 +165,8 @@
 - (void)clearAllSearch {
     _resultArray = [[NSArray alloc] init];
     
-    self.nowRow = 0;
-    self.nowSection = 0;
+    self.nowNumber = 0;
+    self.nowPageIndex = 0;
 }
 
 #pragma mark - Accessors
@@ -226,38 +226,38 @@
 }
 
 - (void)buttonItemClicked_Next:(id)sender {
-    if (_nowRow < [self.resultArray[self.nowSection] count] - 1) {
-        _nowRow++;
+    if (_nowNumber < [self.resultArray[self.nowPageIndex] count] - 1) {
+        _nowNumber++;
     } else {
-        if (self.nowSection >= self.resultArray.count - 1) {
-            self.nowRow = 0;
-            self.nowSection = 0;
+        if (self.nowPageIndex >= self.resultArray.count - 1) {
+            self.nowNumber = 0;
+            self.nowPageIndex = 0;
         } else {
-            _nowSection++;
-            _nowRow = 0;
+            _nowPageIndex++;
+            _nowNumber = 0;
         }
     }
     
-    CPDFSelection *selection = self.resultArray[self.nowSection][self.nowRow];
+    CPDFSelection *selection = self.resultArray[self.nowPageIndex][self.nowNumber];
     NSInteger pageIndex = [self.pdfView.document indexForPage:selection.page];
     [self.pdfView goToPageIndex:pageIndex animated:NO];
     [self.pdfView setHighlightedSelection:selection animated:YES];
 }
 
 - (void)buttonItemClicked_Previous:(id)sender {
-    if (_nowRow > 0) {
-        _nowRow--;
+    if (_nowNumber > 0) {
+        _nowNumber--;
     } else {
-        if (self.nowSection == 0) {
-            _nowSection = self.resultArray.count - 1;
-            _nowRow = [self.resultArray[self.nowSection] count] - 1;
+        if (self.nowPageIndex == 0) {
+            _nowPageIndex = self.resultArray.count - 1;
+            _nowNumber = [self.resultArray[self.nowPageIndex] count] - 1;
         } else {
-            _nowSection--;
-            _nowRow = [self.resultArray[self.nowSection] count] - 1;
+            _nowPageIndex--;
+            _nowNumber = [self.resultArray[self.nowPageIndex] count] - 1;
         }
     }
     
-    CPDFSelection *selection = self.resultArray[self.nowSection][self.nowRow];
+    CPDFSelection *selection = self.resultArray[self.nowPageIndex][self.nowNumber];
     NSInteger pageIndex = [self.pdfView.document indexForPage:selection.page];
     [self.pdfView goToPageIndex:pageIndex animated:NO];
     [self.pdfView setHighlightedSelection:selection animated:YES];