CPDFViewController.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. //
  2. // CPDFViewController.m
  3. // Form-Ctrl-Demo
  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 "CPDFViewController.h"
  13. #import <ComPDFKit/ComPDFKit.h>
  14. #import <compdfkit_tools/compdfkit_tools.h>
  15. @interface CPDFViewController () <CPDFToolsViewControllerDelegate,CPDFFormBarDelegate,CPDFBOTAViewControllerDelegate,CPDFListViewDelegate,CPDFSignatureViewControllerDelegate>
  16. @property(nonatomic, strong) CPDFFormBar * formBar;
  17. @property(nonatomic, strong) CAnnotationManage *annotationManage;
  18. @property(nonatomic, strong) CPDFSignatureWidgetAnnotation * signatureAnnotation;
  19. @end
  20. @implementation CPDFViewController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. self.pdfListView.toolModel = CToolModelForm;
  24. self.pdfListView.delegate = self;
  25. self.view.backgroundColor = [CPDFColorUtils CPDFViewControllerBackgroundColor];
  26. [self initFormBar];
  27. [self enterFormMode];
  28. }
  29. - (void)initFormBar {
  30. self.annotationManage = [[CAnnotationManage alloc] initWithPDFView:self.pdfListView];
  31. self.formBar = [[CPDFFormBar alloc] initAnnotationManage:self.annotationManage];
  32. CGFloat height = 44.0;
  33. if (@available(iOS 11.0, *))
  34. height += self.view.safeAreaInsets.bottom;
  35. self.formBar.frame = CGRectMake(0, self.view.frame.size.height - height, self.view.frame.size.width, height);
  36. self.formBar.delegate = self;
  37. self.formBar.parentVC = self;
  38. #warning need to set parentVC
  39. // [self.formBar setParentVC:self];
  40. [self.view addSubview:self.formBar];
  41. }
  42. - (void)initWitNavigationTitle {
  43. //titleButton
  44. CNavigationBarTitleButton * navTitleButton = [[CNavigationBarTitleButton alloc] init];
  45. self.titleButton = navTitleButton;
  46. self.navigationTitle = NSLocalizedString(@"Form", nil);
  47. [navTitleButton setImage:[UIImage imageNamed:@"syasarrow"] forState:UIControlStateNormal];
  48. [navTitleButton addTarget:self action:@selector(titleButtonClickd:) forControlEvents:UIControlEventTouchUpInside];
  49. [navTitleButton setTitle:self.navigationTitle forState:UIControlStateNormal];
  50. [navTitleButton setTitleColor:[CPDFColorUtils CAnyReverseBackgooundColor] forState:UIControlStateNormal];
  51. self.titleButton.frame = CGRectMake(0, 0, 50, 30);
  52. self.navigationItem.titleView = self.titleButton;
  53. }
  54. - (void)viewWillLayoutSubviews {
  55. [super viewWillLayoutSubviews];
  56. if([self.popMenu superview]) {
  57. if (@available(iOS 11.0, *)) {
  58. [self.popMenu showMenuInRect:CGRectMake(self.view.frame.size.width - self.view.safeAreaInsets.right - 250, CGRectGetMaxY(self.navigationController.navigationBar.frame), 250, 200)];
  59. } else {
  60. // Fallback on earlier versions
  61. [self.popMenu showMenuInRect:CGRectMake(self.view.frame.size.width - 250, CGRectGetMaxY(self.navigationController.navigationBar.frame), 250, 200)];
  62. }
  63. }
  64. CGFloat height = 44.0;
  65. if (@available(iOS 11.0, *))
  66. height += self.view.safeAreaInsets.bottom;
  67. if(CToolModelForm == self.pdfListView.toolModel) {
  68. if (@available(iOS 11.0, *)) {
  69. self.formBar.frame = CGRectMake(self.view.safeAreaInsets.left, self.view.frame.size.height - height, self.view.frame.size.width- self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, height);
  70. } else {
  71. self.formBar.frame = CGRectMake(0, self.view.frame.size.height - height, self.view.frame.size.width, height);
  72. }
  73. } else {
  74. self.formBar.frame = CGRectMake(0, self.view.bounds.size.height, self.view.frame.size.width, height);
  75. }
  76. CGFloat tPosY = 0;
  77. CGFloat tBottomY = 0;
  78. if(CToolModelForm == self.pdfListView.toolModel) {
  79. if (!self.navigationController.navigationBarHidden) {
  80. [UIView animateWithDuration:0.3 animations:^{
  81. CGRect frame = self.formBar.frame;
  82. frame.origin.y = self.view.bounds.size.height-frame.size.height;
  83. self.formBar.frame = frame;
  84. }];
  85. CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
  86. tPosY = self.navigationController.navigationBar.frame.size.height + rectStatus.size.height;
  87. tBottomY = self.formBar.frame.size.height;
  88. } else {
  89. [UIView animateWithDuration:0.3 animations:^{
  90. CGRect frame = self.formBar.frame;
  91. frame.origin.y = self.view.bounds.size.height;
  92. self.formBar.frame = frame;
  93. }];
  94. }
  95. } else {
  96. tPosY = 0;
  97. if (!self.navigationController.navigationBarHidden) {
  98. CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
  99. tPosY = self.navigationController.navigationBar.frame.size.height + rectStatus.size.height;
  100. }
  101. }
  102. if (@available(iOS 11.0, *)) {
  103. self.pdfListView.frame = CGRectMake(self.view.safeAreaInsets.left, tPosY, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, self.view.frame.size.height - tBottomY - tPosY);
  104. } else {
  105. self.pdfListView.frame = CGRectMake(0, tPosY, self.view.frame.size.width, self.view.frame.size.height - tBottomY - tPosY);
  106. }
  107. }
  108. #pragma mark - Private
  109. - (void)enterFormMode {
  110. self.pdfListView.toolModel = CToolModelForm;
  111. self.navigationTitle = NSLocalizedString(@"Form", nil);
  112. [self.titleButton setTitle:self.navigationTitle forState:UIControlStateNormal];
  113. CGFloat tPosY = 0;
  114. CGFloat tBottomY = 0;
  115. CGRect frame = self.formBar.frame;
  116. frame.origin.y = self.view.bounds.size.height-frame.size.height;
  117. self.formBar.frame = frame;
  118. CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
  119. tPosY = self.navigationController.navigationBar.frame.size.height + rectStatus.size.height;
  120. tBottomY = self.formBar.frame.size.height;
  121. if (@available(iOS 11.0, *)) {
  122. self.pdfListView.frame = CGRectMake(self.view.safeAreaInsets.left, tPosY, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, self.view.frame.size.height - tBottomY - tPosY);
  123. } else {
  124. self.pdfListView.frame = CGRectMake(0, tPosY, self.view.frame.size.width, self.view.frame.size.height - tBottomY - tPosY);
  125. }
  126. [self.formBar updateStatus];
  127. }
  128. - (void)selectDocumentRefresh {
  129. [super selectDocumentRefresh];
  130. [self.formBar initUndoRedo];
  131. }
  132. - (void)enterViewerMode {
  133. self.pdfListView.toolModel = CToolModelViewer;
  134. self.navigationTitle = NSLocalizedString(@"Viewer", nil);
  135. [self.titleButton setTitle:self.navigationTitle forState:UIControlStateNormal];
  136. CGRect frame = self.formBar.frame;
  137. frame.origin.y = self.view.bounds.size.height;
  138. self.formBar.frame = frame;
  139. CGFloat tPosY = 0;
  140. CGFloat tBottomY = 0;
  141. if (@available(iOS 11.0, *)) {
  142. self.pdfListView.frame = CGRectMake(self.view.safeAreaInsets.left, tPosY, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, self.view.frame.size.height - tBottomY - tPosY);
  143. } else {
  144. self.pdfListView.frame = CGRectMake(0, tPosY, self.view.frame.size.width, self.view.frame.size.height - tBottomY - tPosY);
  145. }
  146. }
  147. - (void) titleButtonClickd:(UIButton *) button {
  148. CPDFToolsViewController * toolsVc = [[CPDFToolsViewController alloc] initCustomizeWithToolArrays:@[@(CToolModelViewer),@(CToolModelForm)]];
  149. toolsVc.delegate = self;
  150. AAPLCustomPresentationController *presentationController NS_VALID_UNTIL_END_OF_SCOPE;
  151. presentationController = [[AAPLCustomPresentationController alloc] initWithPresentedViewController:toolsVc presentingViewController:self];
  152. toolsVc.transitioningDelegate = presentationController;
  153. [self presentViewController:toolsVc animated:YES completion:nil];
  154. }
  155. - (void)navigationRightItemBota {
  156. CPDFBOTAViewController *botaViewController = [[CPDFBOTAViewController alloc] initCustomizeWithPDFView:self.pdfListView navArrays:@[@(CPDFBOTATypeStateOutline),@(CPDFBOTATypeStateBookmark),@(CPDFBOTATypeStateAnnotation)]];
  157. botaViewController.delegate = self;
  158. AAPLCustomPresentationController *presentationController NS_VALID_UNTIL_END_OF_SCOPE;
  159. presentationController = [[AAPLCustomPresentationController alloc] initWithPresentedViewController:botaViewController presentingViewController:self];
  160. botaViewController.transitioningDelegate = presentationController;
  161. [self presentViewController:botaViewController animated:YES completion:nil];
  162. }
  163. #pragma mark - CPDFListViewDelegate
  164. - (void)PDFListViewPerformTouchEnded:(CPDFListView *)pdfView {
  165. CGFloat tPosY = 0;
  166. CGFloat tBottomY = 0;
  167. if(CToolModelForm == self.pdfListView.toolModel) {
  168. if (self.navigationController.navigationBarHidden) {
  169. [self.navigationController setNavigationBarHidden:NO animated:YES];
  170. [UIView animateWithDuration:0.3 animations:^{
  171. CGRect frame = self.formBar.frame;
  172. frame.origin.y = self.view.bounds.size.height-frame.size.height;
  173. self.formBar.frame = frame;
  174. self.pdfListView.pageSliderView.alpha = 1.0;
  175. // self.formBar.topToolBar.alpha = 1.0;
  176. // self.formBar.drawPencilFuncView.alpha = 1.0;
  177. }];
  178. CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
  179. tPosY = self.navigationController.navigationBar.frame.size.height + rectStatus.size.height;
  180. tBottomY = self.formBar.frame.size.height;
  181. } else {
  182. [self.navigationController setNavigationBarHidden:YES animated:YES];
  183. [UIView animateWithDuration:0.3 animations:^{
  184. CGRect frame = self.formBar.frame;
  185. frame.origin.y = self.view.bounds.size.height;
  186. self.formBar.frame = frame;
  187. self.pdfListView.pageSliderView.alpha = 0.0;
  188. }];
  189. }
  190. } else {
  191. CGFloat tPosY = 0;
  192. if (self.navigationController.navigationBarHidden) {
  193. [self.navigationController setNavigationBarHidden:NO animated:YES];
  194. [UIView animateWithDuration:0.3 animations:^{
  195. self.pdfListView.pageSliderView.alpha = 1.0;
  196. }];
  197. CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
  198. tPosY = self.navigationController.navigationBar.frame.size.height + rectStatus.size.height;
  199. } else {
  200. [self.navigationController setNavigationBarHidden:YES animated:YES];
  201. [UIView animateWithDuration:0.3 animations:^{
  202. self.pdfListView.pageSliderView.alpha = 0.0;
  203. }];
  204. }
  205. }
  206. if (@available(iOS 11.0, *)) {
  207. self.pdfListView.frame = CGRectMake(self.view.safeAreaInsets.left, tPosY, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, self.view.frame.size.height - tBottomY - tPosY);
  208. } else {
  209. self.pdfListView.frame = CGRectMake(0, tPosY, self.view.frame.size.width, self.view.frame.size.height - tBottomY - tPosY);
  210. }
  211. }
  212. //- (void)PDFListViewEditNote:(CPDFListView *)pdfListView forAnnotation:(CPDFAnnotation *)annotation {
  213. // if([annotation isKindOfClass:[CPDFLinkAnnotation class]]) {
  214. // [self.formBar buttonItemClicked_open:annotation];
  215. // } else {
  216. // CGRect rect = [self.pdfListView convertRect:annotation.bounds fromPage:annotation.page];
  217. // CPDFNoteOpenViewController *noteVC = [[CPDFNoteOpenViewController alloc]initWithAnnotation:annotation];
  218. // noteVC.delegate = self;
  219. // [noteVC showViewController:self inRect:rect];
  220. // }
  221. //}
  222. //
  223. - (void)PDFListViewChangedAnnotationType:(CPDFListView *)pdfListView forAnnotationMode:(CPDFViewAnnotationMode)annotationMode {
  224. [self.formBar reloadData];
  225. }
  226. - (void)PDFListViewPerformUrl:(CPDFListView *)pdfView withContent:(NSString *)content {
  227. NSURL * url = [NSURL URLWithString:content];
  228. [[UIApplication sharedApplication] openURL:url];
  229. }
  230. //
  231. //- (void)PDFListViewPerformAddStamp:(CPDFListView *)pdfView atPoint:(CGPoint)point forPage:(CPDFPage *)page {
  232. // [self.annotationBar addStampAnnotationWithPage:page point:point];
  233. //}
  234. //
  235. //- (void)PDFListViewPerformAddImage:(CPDFListView *)pdfView atPoint:(CGPoint)point forPage:(CPDFPage *)page {
  236. // [self.annotationBar addImageAnnotationWithPage:page point:point];
  237. //}
  238. //
  239. //- (BOOL)PDFListViewerTouchEndedIsAudioRecordMedia:(CPDFListView *)pdfListView {
  240. // if (CPDFMediaStateAudioRecord == [CPDFMediaManager shareManager].mediaState) {
  241. // [self PDFListViewPerformTouchEnded:self.pdfListView];
  242. // return YES;
  243. // }
  244. // return NO;
  245. //}
  246. //
  247. //- (void)PDFListViewPerformCancelMedia:(CPDFListView *)pdfView atPoint:(CGPoint)point forPage:(CPDFPage *)page {
  248. // [CPDFMediaManager shareManager].mediaState = CPDFMediaStateStop;
  249. // self.pdfListView.annotationMode = CPDFViewAnnotationModeNone;
  250. //}
  251. //
  252. //- (void)PDFListViewPerformRecordMedia:(CPDFListView *)pdfView atPoint:(CGPoint)point forPage:(CPDFPage *)page {
  253. // NSInteger pageindex = [self.pdfListView.document indexForPage:page];
  254. // [CPDFMediaManager shareManager].mediaState = CPDFMediaStateAudioRecord;
  255. // [CPDFMediaManager shareManager].pageNum = pageindex;
  256. // [CPDFMediaManager shareManager].ptInPdf = point;
  257. //
  258. // if([self.soundPlayBar superview]) {
  259. // if(self.soundPlayBar.soundState == CPDFSoundStatePlay) {
  260. // [self.soundPlayBar stopAudioPlay];
  261. // [self.soundPlayBar removeFromSuperview];
  262. // } else if (self.soundPlayBar.soundState == CPDFSoundStateRecord) {
  263. // [self.soundPlayBar stopRecord];
  264. // [self.soundPlayBar removeFromSuperview];
  265. // }
  266. // }
  267. //
  268. // _soundPlayBar = [[CPDFSoundPlayBar alloc] initWithStyle:self.annotationManage.annotStyle];
  269. // _soundPlayBar.delegate = self;
  270. // [_soundPlayBar showInView:self.pdfListView soundState:CPDFSoundStateRecord];
  271. // [_soundPlayBar startAudioRecord];
  272. //}
  273. //
  274. //- (void)PDFListViewPerformPlay:(CPDFListView *)pdfView forAnnotation:(CPDFSoundAnnotation *)annotation {
  275. // NSString *filePath = [annotation mediaPath];
  276. // if (filePath) {
  277. // NSURL *URL = [NSURL fileURLWithPath:filePath];
  278. //
  279. // _soundPlayBar = [[CPDFSoundPlayBar alloc] initWithStyle:self.annotationManage.annotStyle];
  280. // _soundPlayBar.delegate = self;
  281. // [_soundPlayBar showInView:self.pdfListView soundState:CPDFSoundStatePlay];
  282. // [_soundPlayBar setURL:URL];
  283. // [_soundPlayBar startAudioPlay];
  284. // [CPDFMediaManager shareManager].mediaState = CPDFMediaStateVedioPlaying;
  285. // }
  286. //}
  287. //
  288. - (void)PDFListViewPerformSignatureWidget:(CPDFListView *)pdfView forAnnotation:(CPDFSignatureWidgetAnnotation *)annotation {
  289. if(CToolModelViewer == self.pdfListView.toolModel) {
  290. self.signatureAnnotation = annotation;
  291. AAPLCustomPresentationController *presentationController NS_VALID_UNTIL_END_OF_SCOPE;
  292. CPDFSignatureViewController *signatureVC = [[CPDFSignatureViewController alloc] initWithStyle:nil];
  293. presentationController = [[AAPLCustomPresentationController alloc] initWithPresentedViewController:signatureVC presentingViewController:self];
  294. signatureVC.delegate = self;
  295. signatureVC.transitioningDelegate = presentationController;
  296. [self presentViewController:signatureVC animated:YES completion:nil];
  297. }
  298. }
  299. - (void)PDFListViewEditWidget:(CPDFListView *)pdfListView forAnnotation:(CPDFAnnotation *)annotation {
  300. [self.formBar buttonItemClicked_openOption:annotation];
  301. }
  302. - (void)PDFListViewEditProperties:(CPDFListView *)pdfListView forAnnotation:(CPDFAnnotation *)annotation {
  303. [self.formBar buttonItemClicked_open:annotation];
  304. }
  305. #pragma mark - CPDFBOTAViewControllerDelegate
  306. - (void)botaViewControllerDismiss:(CPDFBOTAViewController *)botaViewController {
  307. [self.navigationController dismissViewControllerAnimated:YES completion:nil];
  308. }
  309. #pragma mark - CPDFAnnotationBarDelegate
  310. - (void)formBarClick:(CPDFFormBar *)pdfFormBar forSelected:(BOOL)isSelected forButton:(UIButton *)button {
  311. NSLog(@"form bar Clicked!");
  312. }
  313. //- (void)annotationBarClick:(CPDFAnnotationBar *)annotationBar clickAnnotationMode:(CPDFViewAnnotationMode)annotationMode forSelected:(BOOL)isSelected forButton:(UIButton *)button {
  314. // if(CPDFViewAnnotationModeInk == annotationMode || CPDFViewAnnotationModePencilDrawing == annotationMode) {
  315. // CGFloat tPosY = 0;
  316. // if(isSelected) {
  317. // [self.navigationController setNavigationBarHidden:YES animated:YES];
  318. // [UIView animateWithDuration:0.3 animations:^{
  319. // CGRect frame = self.annotationBar.frame;
  320. // frame.origin.y = self.view.bounds.size.height;
  321. // self.annotationBar.frame = frame;
  322. // self.pdfListView.pageSliderView.alpha = 0.0;
  323. //
  324. // if (@available(iOS 11.0, *)) {
  325. // self.pdfListView.frame = CGRectMake(self.view.safeAreaInsets.left, tPosY, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, self.view.frame.size.height - self.view.safeAreaInsets.bottom - tPosY);
  326. // } else {
  327. // self.pdfListView.frame = CGRectMake(0, tPosY, self.view.frame.size.width, self.view.frame.size.height - tPosY);
  328. // }
  329. // }];
  330. // } else {
  331. // [self.navigationController setNavigationBarHidden:NO animated:YES];
  332. // [UIView animateWithDuration:0.3 animations:^{
  333. // CGRect frame = self.annotationBar.frame;
  334. // frame.origin.y = self.view.bounds.size.height-frame.size.height;
  335. // self.annotationBar.frame = frame;
  336. // self.pdfListView.pageSliderView.alpha = 1.0;
  337. // }];
  338. // CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
  339. // tPosY = self.navigationController.navigationBar.frame.size.height + rectStatus.size.height;
  340. //
  341. // if (@available(iOS 11.0, *)) {
  342. // self.pdfListView.frame = CGRectMake(self.view.safeAreaInsets.left, tPosY, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, self.view.frame.size.height - tPosY- self.annotationBar.frame.size.height);
  343. // } else {
  344. // self.pdfListView.frame = CGRectMake(0, tPosY, self.view.frame.size.width, self.view.frame.size.height - tPosY- tPosY- self.annotationBar.frame.size.height);
  345. // }
  346. // }
  347. // } else if (CPDFViewAnnotationModeSound == annotationMode && !isSelected) {
  348. // if(CPDFSoundStateRecord == self.soundPlayBar.soundState) {
  349. // [self.soundPlayBar stopRecord];
  350. //
  351. // } else if (CPDFSoundStatePlay== self.soundPlayBar.soundState) {
  352. // [self.soundPlayBar stopAudioPlay];
  353. // }
  354. // }
  355. //}
  356. #pragma mark - CPDFNoteOpenViewControllerDelegate
  357. //- (void)getNoteOpenViewController:(CPDFNoteOpenViewController *)noteOpenVC content:(NSString *)content isDelete:(BOOL)isDelete {
  358. // if (isDelete) {
  359. // [noteOpenVC.annotation.page removeAnnotation:noteOpenVC.annotation];
  360. // [self.pdfListView setNeedsDisplayForPage:noteOpenVC.annotation.page];
  361. // if([self.pdfListView.activeAnnotations containsObject:noteOpenVC.annotation]) {
  362. // NSMutableArray *activeAnnotations = [NSMutableArray arrayWithArray:self.pdfListView.activeAnnotations];
  363. // [activeAnnotations removeObject:noteOpenVC.annotation];
  364. // [self.pdfListView updateActiveAnnotations:activeAnnotations];
  365. // }
  366. // } else {
  367. // if([noteOpenVC.annotation isKindOfClass:[CPDFMarkupAnnotation class]]) {
  368. // CPDFMarkupAnnotation *markupAnnotation = (CPDFMarkupAnnotation *)noteOpenVC.annotation;
  369. // [markupAnnotation setMarkupText:content?:@""];
  370. // } else {
  371. // noteOpenVC.annotation.contents = content?:@"";
  372. // }
  373. // }
  374. //}
  375. //#pragma mark - CPDFSoundPlayBarDelegate
  376. //
  377. //- (void)soundPlayBarRecordFinished:(CPDFSoundPlayBar *)soundPlayBar withFile:(NSString *)filePath {
  378. // self.pdfListView.annotationMode = CPDFViewAnnotationModeNone;
  379. //
  380. // CPDFPage *page = [self.pdfListView.document pageAtIndex:[CPDFMediaManager shareManager].pageNum];
  381. // CPDFSoundAnnotation *annotation = [[CPDFSoundAnnotation alloc] initWithDocument:self.pdfListView.document];
  382. //
  383. // if ([annotation setMediaPath:filePath]) {
  384. // CGRect bounds = annotation.bounds;
  385. // bounds.origin.x = [CPDFMediaManager shareManager].ptInPdf.x-bounds.size.width/2.0;
  386. // bounds.origin.y = [CPDFMediaManager shareManager].ptInPdf.y-bounds.size.height/2.0;
  387. // annotation.bounds = bounds;
  388. // [self.pdfListView addAnnotation:annotation forPage:page];
  389. // }
  390. //
  391. // [CPDFMediaManager shareManager].mediaState = CPDFMediaStateStop;
  392. // [self.pdfListView stopRecord];
  393. //}
  394. //
  395. //- (void)soundPlayBarRecordCancel:(CPDFSoundPlayBar *)soundPlayBar {
  396. // if(CPDFSoundStateRecord == self.soundPlayBar.soundState) {
  397. // [self.pdfListView stopRecord];
  398. // }
  399. // [CPDFMediaManager shareManager].mediaState = CPDFMediaStateStop;
  400. // self.pdfListView.annotationMode = CPDFViewAnnotationModeNone;
  401. //}
  402. //
  403. //- (void)soundPlayBarPlayClose:(CPDFSoundPlayBar *)soundPlayBar {
  404. // [CPDFMediaManager shareManager].mediaState = CPDFMediaStateStop;
  405. //}
  406. #pragma mark - CPDFToolsViewControllerDelegate
  407. - (void)CPDFToolsViewControllerDismiss:(CPDFToolsViewController *) viewController selectItemAtIndex:(CToolModel)selectIndex {
  408. if(CToolModelViewer == selectIndex) {
  409. //viewwer
  410. [self enterViewerMode];
  411. }else{
  412. //Form
  413. [self enterFormMode];
  414. }
  415. }
  416. #pragma mark - CPDFSignatureViewControllerDelegate
  417. - (void)signatureViewControllerDismiss:(CPDFSignatureViewController *)signatureViewController {
  418. self.signatureAnnotation = nil;
  419. }
  420. - (void)signatureViewController:(CPDFSignatureViewController *)signatureViewController image:(UIImage *)image {
  421. if(self.signatureAnnotation) {
  422. [self.signatureAnnotation signWithImage:image];
  423. [self.pdfListView setNeedsDisplayForPage:self.signatureAnnotation.page];
  424. self.signatureAnnotation = nil;
  425. }
  426. }
  427. @end