|
@@ -17,7 +17,7 @@
|
|
|
#import <AVFAudio/AVFAudio.h>
|
|
|
#import <AVFoundation/AVFoundation.h>
|
|
|
|
|
|
-@interface CPDFViewController () <CPDFSoundPlayBarDelegate,CPDFAnnotationBarDelegate,CPDFToolsViewControllerDelegate,CPDFNoteOpenViewControllerDelegate,CPDFBOTAViewControllerDelegate,CPDFEditToolBarDelegate>
|
|
|
+@interface CPDFViewController () <CPDFSoundPlayBarDelegate,CPDFAnnotationBarDelegate,CPDFToolsViewControllerDelegate,CPDFNoteOpenViewControllerDelegate,CPDFBOTAViewControllerDelegate,CPDFEditToolBarDelegate,CPDFFormBarDelegate,CPDFListViewDelegate,CPDFPageEditViewControllerDelegate>
|
|
|
|
|
|
@property(nonatomic, strong) CPDFAnnotationBar *annotationBar;
|
|
|
|
|
@@ -33,6 +33,8 @@
|
|
|
|
|
|
@property(nonatomic, assign) CPDFEditMode editMode;
|
|
|
|
|
|
+@property(nonatomic, strong) CPDFSignatureWidgetAnnotation * signatureAnnotation;
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation CPDFViewController
|
|
@@ -49,8 +51,8 @@
|
|
|
self.pdfListView.editingConfig = editingConfig;
|
|
|
|
|
|
[self initAnnotationBar];
|
|
|
-
|
|
|
[self initWithEditTool];
|
|
|
+ [self initWithFormTool];
|
|
|
|
|
|
[self enterViewerMode];
|
|
|
|
|
@@ -81,6 +83,14 @@
|
|
|
[self.view addSubview:self.toolBar];
|
|
|
}
|
|
|
|
|
|
+- (void)initWithFormTool {
|
|
|
+ if(!self.formBar){
|
|
|
+ self.formBar = [[CPDFFormBar alloc] initAnnotationManage:self.annotationManage];
|
|
|
+ }
|
|
|
+ self.formBar.delegate = self;
|
|
|
+ [self.view addSubview:self.formBar];
|
|
|
+}
|
|
|
+
|
|
|
- (void)initWitNavigationTitle {
|
|
|
//titleButton
|
|
|
CNavigationBarTitleButton * navTitleButton = [[CNavigationBarTitleButton alloc] init];
|
|
@@ -114,8 +124,12 @@
|
|
|
self.annotationBar.frame = CGRectMake(0, self.view.frame.size.height - height, self.view.frame.size.width, height);
|
|
|
} else if(CToolModelEdit == self.pdfListView.toolModel){
|
|
|
self.toolBar.frame = CGRectMake(0, self.view.frame.size.height - height, self.view.frame.size.width, height);
|
|
|
- }else{
|
|
|
+ }else if(CToolModelAnnotation == self.pdfListView.toolModel){
|
|
|
self.annotationBar.frame = CGRectMake(0, self.view.bounds.size.height, self.view.frame.size.width, height);
|
|
|
+ }else if(CToolModelForm == self.pdfListView.toolModel){
|
|
|
+ self.formBar.frame = CGRectMake(0, self.view.frame.size.height - height, self.view.frame.size.width, height);
|
|
|
+ } else if(CToolModelPageEdit == self.pdfListView.toolModel){
|
|
|
+
|
|
|
}
|
|
|
|
|
|
CGFloat tPosY = 0;
|
|
@@ -161,10 +175,14 @@
|
|
|
#pragma mark - Public Methods
|
|
|
|
|
|
- (void)selectDocumentRefresh {
|
|
|
- self.pdfListView.annotationMode = CPDFViewAnnotationModeNone;
|
|
|
- [self.annotationBar updatePropertiesButtonState];
|
|
|
- [self.annotationBar reloadData];
|
|
|
- [self.annotationBar updateUndoRedoState];
|
|
|
+ if(CToolModelAnnotation == self.pdfListView.toolModel) {
|
|
|
+ self.pdfListView.annotationMode = CPDFViewAnnotationModeNone;
|
|
|
+ [self.annotationBar updatePropertiesButtonState];
|
|
|
+ [self.annotationBar reloadData];
|
|
|
+ [self.annotationBar updateUndoRedoState];
|
|
|
+ }else if(CToolModelForm == self.pdfListView.toolModel) {
|
|
|
+ [self.formBar initUndoRedo];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#pragma mark - Private
|
|
@@ -172,6 +190,7 @@
|
|
|
- (void)enterEditMode {
|
|
|
self.toolBar.hidden = NO;
|
|
|
self.annotationBar.hidden = YES;
|
|
|
+ self.formBar.hidden = YES;
|
|
|
self.pdfListView.toolModel = CToolModelEdit;
|
|
|
[self.pdfListView beginEditingLoadType:CEditingLoadTypeText | CEditingLoadTypeImage];
|
|
|
self.navigationTitle = NSLocalizedString(@"Content Edit", nil);
|
|
@@ -200,6 +219,7 @@
|
|
|
- (void)enterAnnotationMode {
|
|
|
self.toolBar.hidden = YES;
|
|
|
self.annotationBar.hidden = NO;
|
|
|
+ self.formBar.hidden = YES;
|
|
|
if (self.pdfListView.isEdited) {
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
[self.pdfListView commitEditing];
|
|
@@ -233,10 +253,14 @@
|
|
|
inset.bottom = 0;
|
|
|
self.pdfListView.documentView.contentInset = inset;
|
|
|
}
|
|
|
+
|
|
|
+ [self viewWillLayoutSubviews];
|
|
|
}
|
|
|
|
|
|
- (void)enterViewerMode {
|
|
|
self.toolBar.hidden = YES;
|
|
|
+ self.formBar.hidden = YES;
|
|
|
+ self.annotationBar.hidden = YES;
|
|
|
if (self.pdfListView.isEdited) {
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
[self.pdfListView commitEditing];
|
|
@@ -250,11 +274,11 @@
|
|
|
self.pdfListView.toolModel = CToolModelViewer;
|
|
|
self.navigationTitle = NSLocalizedString(@"Viewer", nil);
|
|
|
[self.titleButton setTitle:self.navigationTitle forState:UIControlStateNormal];
|
|
|
-
|
|
|
+
|
|
|
CGRect frame = self.annotationBar.frame;
|
|
|
frame.origin.y = self.view.bounds.size.height;
|
|
|
self.annotationBar.frame = frame;
|
|
|
-
|
|
|
+
|
|
|
if (CPDFDisplayDirectionVertical == [CPDFKitConfig sharedInstance].displayDirection) {
|
|
|
UIEdgeInsets inset = self.pdfListView.documentView.contentInset;
|
|
|
inset.bottom = 10 + self.annotationBar.frame.size.height;
|
|
@@ -264,11 +288,13 @@
|
|
|
inset.bottom = 0;
|
|
|
self.pdfListView.documentView.contentInset = inset;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-(void) enterFormMode {
|
|
|
self.toolBar.hidden = YES;
|
|
|
self.annotationBar.hidden = YES;
|
|
|
+ self.formBar.hidden = NO;
|
|
|
if (self.pdfListView.isEdited) {
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
[self.pdfListView commitEditing];
|
|
@@ -283,24 +309,32 @@
|
|
|
self.navigationTitle = NSLocalizedString(@"Form", nil);
|
|
|
[self.titleButton setTitle:self.navigationTitle forState:UIControlStateNormal];
|
|
|
|
|
|
- CGRect frame = self.annotationBar.frame;
|
|
|
- frame.origin.y = self.view.bounds.size.height;
|
|
|
- self.annotationBar.frame = frame;
|
|
|
+ CGFloat tPosY = 0;
|
|
|
+ CGFloat tBottomY = 0;
|
|
|
+ CGRect frame = self.formBar.frame;
|
|
|
+ frame.origin.y = self.view.bounds.size.height-frame.size.height;
|
|
|
+ self.formBar.frame = frame;
|
|
|
+
|
|
|
+ CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
|
|
|
+ tPosY = self.navigationController.navigationBar.frame.size.height + rectStatus.size.height;
|
|
|
+ tBottomY = self.formBar.frame.size.height;
|
|
|
|
|
|
if (CPDFDisplayDirectionVertical == [CPDFKitConfig sharedInstance].displayDirection) {
|
|
|
- UIEdgeInsets inset = self.pdfListView.documentView.contentInset;
|
|
|
- inset.bottom = 10 + self.annotationBar.frame.size.height;
|
|
|
- self.pdfListView.documentView.contentInset = inset;
|
|
|
+ UIEdgeInsets inset = self.pdfListView.documentView.contentInset;
|
|
|
+ inset.bottom = 10 + self.formBar.frame.size.height;
|
|
|
+ self.pdfListView.documentView.contentInset = inset;
|
|
|
} else{
|
|
|
- UIEdgeInsets inset = self.pdfListView.documentView.contentInset;
|
|
|
- inset.bottom = 0;
|
|
|
- self.pdfListView.documentView.contentInset = inset;
|
|
|
+ UIEdgeInsets inset = self.pdfListView.documentView.contentInset;
|
|
|
+ inset.bottom = 0;
|
|
|
+ self.pdfListView.documentView.contentInset = inset;
|
|
|
}
|
|
|
+ [self viewWillLayoutSubviews];
|
|
|
}
|
|
|
|
|
|
-(void)enterPageEditMode {
|
|
|
self.toolBar.hidden = YES;
|
|
|
self.annotationBar.hidden = YES;
|
|
|
+ self.formBar.hidden = YES;
|
|
|
if (self.pdfListView.isEdited) {
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
[self.pdfListView commitEditing];
|
|
@@ -315,19 +349,6 @@
|
|
|
self.navigationTitle = NSLocalizedString(@"Page Edit", nil);
|
|
|
[self.titleButton setTitle:self.navigationTitle forState:UIControlStateNormal];
|
|
|
|
|
|
- CGRect frame = self.annotationBar.frame;
|
|
|
- frame.origin.y = self.view.bounds.size.height;
|
|
|
- self.annotationBar.frame = frame;
|
|
|
-
|
|
|
- if (CPDFDisplayDirectionVertical == [CPDFKitConfig sharedInstance].displayDirection) {
|
|
|
- UIEdgeInsets inset = self.pdfListView.documentView.contentInset;
|
|
|
- inset.bottom = 10 + self.annotationBar.frame.size.height;
|
|
|
- self.pdfListView.documentView.contentInset = inset;
|
|
|
- } else{
|
|
|
- UIEdgeInsets inset = self.pdfListView.documentView.contentInset;
|
|
|
- inset.bottom = 0;
|
|
|
- self.pdfListView.documentView.contentInset = inset;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
- (void)enterPDFShare {
|
|
@@ -506,7 +527,16 @@
|
|
|
}
|
|
|
|
|
|
- (void)PDFListViewChangedAnnotationType:(CPDFListView *)pdfListView forAnnotationMode:(CPDFViewAnnotationMode)annotationMode {
|
|
|
- [self.annotationBar reloadData];
|
|
|
+ if(CToolModelAnnotation == self.pdfListView.toolModel) {
|
|
|
+ [self.annotationBar reloadData];
|
|
|
+ }else if(CToolModelForm == self.pdfListView.toolModel) {
|
|
|
+ [self.formBar reloadData];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)PDFListViewPerformUrl:(CPDFListView *)pdfView withContent:(NSString *)content {
|
|
|
+ NSURL * url = [NSURL URLWithString:content];
|
|
|
+ [[UIApplication sharedApplication] openURL:url];
|
|
|
}
|
|
|
|
|
|
- (void)PDFListViewPerformAddStamp:(CPDFListView *)pdfView atPoint:(CGPoint)point forPage:(CPDFPage *)page {
|
|
@@ -586,11 +616,25 @@
|
|
|
}
|
|
|
|
|
|
- (void)PDFListViewPerformSignatureWidget:(CPDFListView *)pdfView forAnnotation:(CPDFSignatureWidgetAnnotation *)annotation {
|
|
|
- [self.annotationBar openSignatureAnnotation:annotation];
|
|
|
+ if(CToolModelAnnotation == self.pdfListView.toolModel) {
|
|
|
+ [self.annotationBar openSignatureAnnotation:annotation];
|
|
|
+ }else if(CToolModelForm == self.pdfListView.toolModel) {
|
|
|
+ self.signatureAnnotation = annotation;
|
|
|
+ AAPLCustomPresentationController *presentationController NS_VALID_UNTIL_END_OF_SCOPE;
|
|
|
+ CPDFSignatureViewController *signatureVC = [[CPDFSignatureViewController alloc] initWithStyle:nil];
|
|
|
+ presentationController = [[AAPLCustomPresentationController alloc] initWithPresentedViewController:signatureVC presentingViewController:self];
|
|
|
+ signatureVC.delegate = self;
|
|
|
+ signatureVC.transitioningDelegate = presentationController;
|
|
|
+ [self presentViewController:signatureVC animated:YES completion:nil];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (void)PDFListViewEditProperties:(CPDFListView *)pdfListView forAnnotation:(CPDFAnnotation *)annotation {
|
|
|
- [self.annotationBar buttonItemClicked_open:self.titleButton];
|
|
|
+ if(CToolModelAnnotation == self.pdfListView.toolModel){
|
|
|
+ [self.annotationBar buttonItemClicked_open:self.titleButton];
|
|
|
+ }else if(CToolModelForm == self.pdfListView.toolModel) {
|
|
|
+ [self.formBar buttonItemClicked_open:annotation];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (void)PDFListViewCustomMenuClick:(CPDFListView *)pdfView identifier:(NSString *)menuIdentifier point:(CGPoint)point {
|
|
@@ -716,6 +760,10 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+- (void)PDFListViewEditWidget:(CPDFListView *)pdfListView forAnnotation:(CPDFAnnotation *)annotation {
|
|
|
+ [self.formBar buttonItemClicked_openOption:annotation];
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - CPDFToolsViewControllerDelegate
|
|
|
|
|
|
- (void)CPDFToolsViewControllerDismiss:(CPDFToolsViewController *) viewController selectItemAtIndex:(CToolModel)selectIndex {
|
|
@@ -727,6 +775,10 @@
|
|
|
}else if(CToolModelAnnotation == selectIndex){
|
|
|
//Annotation
|
|
|
[self enterAnnotationMode];
|
|
|
+ }else if(CToolModelForm == selectIndex) {
|
|
|
+ [self enterFormMode];
|
|
|
+ }else if(CToolModelPageEdit == selectIndex) {
|
|
|
+ [self enterPageEditMode];
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -736,4 +788,43 @@
|
|
|
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
|
|
|
}
|
|
|
|
|
|
+#pragma mark - CPDFSignatureViewControllerDelegate
|
|
|
+
|
|
|
+- (void)signatureViewControllerDismiss:(CPDFSignatureViewController *)signatureViewController {
|
|
|
+ self.signatureAnnotation = nil;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)signatureViewController:(CPDFSignatureViewController *)signatureViewController image:(UIImage *)image {
|
|
|
+ if(self.signatureAnnotation) {
|
|
|
+ [self.signatureAnnotation signWithImage:image];
|
|
|
+ [self.pdfListView setNeedsDisplayForPage:self.signatureAnnotation.page];
|
|
|
+ self.signatureAnnotation = nil;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - Action
|
|
|
+
|
|
|
+- (void)buttonItemClicked_thumbnail:(id)sender {
|
|
|
+ CPDFPageEditViewController *pageEditViewcontroller = [[CPDFPageEditViewController alloc] initWithPDFView:self.pdfListView];
|
|
|
+ pageEditViewcontroller.pageEditDelegate = self;
|
|
|
+ pageEditViewcontroller.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
+ [self.navigationController presentViewController:pageEditViewcontroller animated:YES completion:nil];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - CPDFPageEditViewControllerDelegate
|
|
|
+
|
|
|
+- (void)pageEditViewControllerDone:(CPDFPageEditViewController *)pageEditViewController {
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
+ [weakSelf reloadDocumentWithFilePath:self.filePath password:nil completion:^(BOOL result) {
|
|
|
+ [weakSelf.pdfListView reloadInputViews];
|
|
|
+ }];
|
|
|
+
|
|
|
+ [weakSelf.pdfListView reloadInputViews];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)pageEditViewController:(CPDFPageEditViewController *)pageEditViewController pageIndex:(NSInteger)pageIndex {
|
|
|
+ [self.pdfListView goToPageIndex:pageIndex animated:NO];
|
|
|
+ [self.navigationController popViewControllerAnimated:YES];
|
|
|
+}
|
|
|
+
|
|
|
@end
|