123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548 |
- //
- // CPDFViewController.m
- // ContentEditor
- //
- // Copyright © 2014-2024 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.
- // This notice may not be removed from this file.
- //
- #import "CPDFViewController.h"
- #import <ComPDFKit/ComPDFKit.h>
- #import <AVFAudio/AVFAudio.h>
- #import <AVFoundation/AVFoundation.h>
- @interface CPDFViewController () <CPDFSoundPlayBarDelegate,CPDFAnnotationBarDelegate,CPDFToolsViewControllerDelegate,CPDFNoteOpenViewControllerDelegate,CPDFBOTAViewControllerDelegate,CPDFKeyboardToolbarDelegate>
- @property(nonatomic, strong) CPDFAnnotationToolBar *annotationBar;
- @property(nonatomic, strong) CPDFSoundPlayBar *soundPlayBar;
- @property(nonatomic, strong) CAnnotationManage *annotationManage;
- @end
- @implementation CPDFViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.pdfListView.toolModel = CToolModelAnnotation;
- self.view.backgroundColor = [CPDFColorUtils CPDFViewControllerBackgroundColor];
-
- [self initAnnotationBar];
- if (self.configuration.enterToolModel == CPDFToolFunctionTypeStateViewer) {
- [self enterViewerMode];
- } else {
- [self enterAnnotationMode];
- }
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(PDFPageDidRemoveAnnotationNotification:) name:CPDFPageDidRemoveAnnotationNotification object:nil];
- }
- - (void)initAnnotationBar {
- self.annotationManage = [[CAnnotationManage alloc] initWithPDFView:self.pdfListView];
-
- self.annotationBar = [[CPDFAnnotationToolBar alloc] initAnnotationManage:self.annotationManage];
-
- CGFloat height = 44.0;
- if (@available(iOS 11.0, *))
- height += self.view.safeAreaInsets.bottom;
-
- self.annotationBar.frame = CGRectMake(0, self.view.frame.size.height - height, self.view.frame.size.width, height);
- self.annotationBar.delegate = self;
- [self.annotationBar setParentVC:self];
- [self.view addSubview:self.annotationBar];
- }
- - (void)initWitNavigationTitle {
- //titleButton
- [super initWitNavigationTitle];
- self.navigationTitle = NSLocalizedString(@"Annotation", nil);
- }
- - (void)viewWillLayoutSubviews {
- [super viewWillLayoutSubviews];
-
- if([self.popMenu superview]) {
- if (@available(iOS 11.0, *)) {
- [self.popMenu showMenuInRect:CGRectMake(self.view.frame.size.width - self.view.safeAreaInsets.right - 250, CGRectGetMaxY(self.navigationController.navigationBar.frame), 250, 250)];
- } else {
- // Fallback on earlier versions
- [self.popMenu showMenuInRect:CGRectMake(self.view.frame.size.width - 250, CGRectGetMaxY(self.navigationController.navigationBar.frame), 250, 250)];
- }
- }
-
- CGFloat height = 44.0;
-
- if (@available(iOS 11.0, *))
- height += self.view.safeAreaInsets.bottom;
- if(CToolModelAnnotation == self.pdfListView.toolModel) {
- if (@available(iOS 11.0, *)) {
- self.annotationBar.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);
- } else {
- self.annotationBar.frame = CGRectMake(0, self.view.frame.size.height - height, self.view.frame.size.width, height);
- }
- } else {
- self.annotationBar.frame = CGRectMake(0, self.view.bounds.size.height, self.view.frame.size.width, height);
- }
-
- CGFloat tPosY = 0;
- CGFloat tBottomY = 0;
- if(CToolModelAnnotation == self.pdfListView.toolModel) {
- if (!self.navigationController.navigationBarHidden) {
- [UIView animateWithDuration:0.3 animations:^{
- CGRect frame = self.annotationBar.frame;
- frame.origin.y = self.view.bounds.size.height-frame.size.height;
- self.annotationBar.frame = frame;
- }];
- CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
- tPosY = self.navigationController.navigationBar.frame.size.height + rectStatus.size.height;
-
- tBottomY = self.annotationBar.frame.size.height;
- } else {
- [UIView animateWithDuration:0.3 animations:^{
- CGRect frame = self.annotationBar.frame;
- frame.origin.y = self.view.bounds.size.height;
- self.annotationBar.frame = frame;
- }];
- }
- } else {
- tPosY = 0;
- if (!self.navigationController.navigationBarHidden) {
- CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
- tPosY = self.navigationController.navigationBar.frame.size.height + rectStatus.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;
- } else{
- UIEdgeInsets inset = self.pdfListView.documentView.contentInset;
- inset.bottom = 0;
- self.pdfListView.documentView.contentInset = inset;
- }
- }
- #pragma mark - Public Methods
- - (void)selectDocumentRefresh {
- self.pdfListView.annotationMode = CPDFViewAnnotationModeNone;
- [self.annotationBar updatePropertiesButtonState];
- [self.annotationBar reloadData];
- [self.annotationBar updateUndoRedoState];
- }
- #pragma mark - Private Methods
- - (void)enterAnnotationMode {
- self.functionTypeState = CPDFToolFunctionTypeStateAnnotation;
- self.pdfListView.toolModel = CToolModelAnnotation;
- self.navigationTitle = NSLocalizedString(@"Annotation", nil);
- [self.titleButton setTitle:self.navigationTitle forState:UIControlStateNormal];
-
- CGFloat tPosY = 0;
- CGFloat tBottomY = 0;
- CGRect frame = self.annotationBar.frame;
- frame.origin.y = self.view.bounds.size.height-frame.size.height;
- self.annotationBar.frame = frame;
-
- CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
- tPosY = self.navigationController.navigationBar.frame.size.height + rectStatus.size.height;
- tBottomY = self.annotationBar.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;
- } else{
- UIEdgeInsets inset = self.pdfListView.documentView.contentInset;
- inset.bottom = 0;
- self.pdfListView.documentView.contentInset = inset;
- }
- }
- - (void)enterViewerMode {
- self.functionTypeState = CPDFToolFunctionTypeStateViewer;
- if (self.pdfListView.isEdited) {
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [self.pdfListView commitEditing];
- dispatch_async(dispatch_get_main_queue(), ^{
- [self.pdfListView endOfEditing];
- });
- });
- } else {
- [self.pdfListView endOfEditing];
- }
-
- 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;
- self.pdfListView.documentView.contentInset = inset;
- } else{
- UIEdgeInsets inset = self.pdfListView.documentView.contentInset;
- inset.bottom = 0;
- self.pdfListView.documentView.contentInset = inset;
- }
- }
- - (void)titleButtonClickd:(UIButton *) button {
- CPDFToolsViewController * toolsVc = [[CPDFToolsViewController alloc] initCustomizeWithToolArrays:@[@(CPDFToolFunctionTypeStateViewer),@(CPDFToolFunctionTypeStateAnnotation)]];
- toolsVc.delegate = self;
- AAPLCustomPresentationController *presentationController NS_VALID_UNTIL_END_OF_SCOPE;
- presentationController = [[AAPLCustomPresentationController alloc] initWithPresentedViewController:toolsVc presentingViewController:self];
- toolsVc.transitioningDelegate = presentationController;
- [self presentViewController:toolsVc animated:YES completion:nil];
- }
- - (void)buttonItemClicked_Bota:(id)sender {
- CPDFBOTAViewController *botaViewController = [[CPDFBOTAViewController alloc] initCustomizeWithPDFView:self.pdfListView navArrays:@[@(CPDFBOTATypeStateOutline),@(CPDFBOTATypeStateBookmark),@(CPDFBOTATypeStateAnnotation)]];
- botaViewController.delegate = self;
-
- AAPLCustomPresentationController *presentationController NS_VALID_UNTIL_END_OF_SCOPE;
-
- presentationController = [[AAPLCustomPresentationController alloc] initWithPresentedViewController:botaViewController presentingViewController:self];
- botaViewController.transitioningDelegate = presentationController;
-
- [self presentViewController:botaViewController animated:YES completion:nil];
- }
- - (void)setTitleRefresh {
- if (CPDFToolFunctionTypeStateAnnotation == self.functionTypeState) {
- [self enterAnnotationMode];
- } else {
- [self enterViewerMode];
- }
- }
- #pragma mark - CPDFViewDelegate
- - (void)PDFViewShouldBeginEditing:(CPDFView *)pdfView textView:(UITextView *)textView forAnnotation:(CPDFFreeTextAnnotation *)annotation {
- CPDFKeyboardToolbar *keyBoadrdToolbar = [[CPDFKeyboardToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 50)];
- keyBoadrdToolbar.delegate = self;
- [keyBoadrdToolbar bindToTextView:textView];
- }
- #pragma mark - CPDFListViewDelegate
- - (void)PDFListViewPerformTouchEnded:(CPDFListView *)pdfView {
- CGFloat tPosY = 0;
- CGFloat tBottomY = 0;
- if(CToolModelAnnotation == self.pdfListView.toolModel) {
- if (self.navigationController.navigationBarHidden) {
- [self.navigationController setNavigationBarHidden:NO animated:YES];
- [UIView animateWithDuration:0.3 animations:^{
- CGRect frame = self.annotationBar.frame;
- frame.origin.y = self.view.bounds.size.height-frame.size.height;
- self.annotationBar.frame = frame;
- self.pdfListView.pageSliderView.alpha = 1.0;
- self.annotationBar.topToolBar.alpha = 1.0;
- self.annotationBar.drawPencilFuncView.alpha = 1.0;
- }];
- CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
- tPosY = self.navigationController.navigationBar.frame.size.height + rectStatus.size.height;
-
- tBottomY = self.annotationBar.frame.size.height;
- } else {
- [self.navigationController setNavigationBarHidden:YES animated:YES];
- [UIView animateWithDuration:0.3 animations:^{
- CGRect frame = self.annotationBar.frame;
- frame.origin.y = self.view.bounds.size.height;
- self.annotationBar.frame = frame;
- self.pdfListView.pageSliderView.alpha = 0.0;
- self.annotationBar.topToolBar.alpha = 0.0;
- self.annotationBar.drawPencilFuncView.alpha = 0.0;
- }];
- }
- } else {
- CGFloat tPosY = 0;
- if (self.navigationController.navigationBarHidden) {
- [self.navigationController setNavigationBarHidden:NO animated:YES];
- [UIView animateWithDuration:0.3 animations:^{
- self.pdfListView.pageSliderView.alpha = 1.0;
- }];
- CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
- tPosY = self.navigationController.navigationBar.frame.size.height + rectStatus.size.height;
- } else {
- [self.navigationController setNavigationBarHidden:YES animated:YES];
- [UIView animateWithDuration:0.3 animations:^{
- self.pdfListView.pageSliderView.alpha = 0.0;
- }];
- }
- }
-
- 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)PDFListViewEditNote:(CPDFListView *)pdfListView forAnnotation:(CPDFAnnotation *)annotation {
- if([annotation isKindOfClass:[CPDFLinkAnnotation class]]) {
- [self.annotationBar buttonItemClicked_openAnnotation:self.titleButton];
- } else {
- CGRect rect = [self.pdfListView convertRect:annotation.bounds fromPage:annotation.page];
- CPDFNoteOpenViewController *noteVC = [[CPDFNoteOpenViewController alloc]initWithAnnotation:annotation];
- noteVC.delegate = self;
- [noteVC showViewController:self inRect:rect];
- }
- }
- - (void)PDFListViewChangedAnnotationType:(CPDFListView *)pdfListView forAnnotationMode:(CPDFViewAnnotationMode)annotationMode {
- [self.annotationBar reloadData];
- }
- - (void)PDFListViewPerformAddStamp:(CPDFListView *)pdfView atPoint:(CGPoint)point forPage:(CPDFPage *)page {
- [self.annotationBar addStampAnnotationWithPage:page point:point];
- }
- - (void)PDFListViewPerformAddImage:(CPDFListView *)pdfView atPoint:(CGPoint)point forPage:(CPDFPage *)page {
- [self.annotationBar addImageAnnotationWithPage:page point:point];
- }
- - (BOOL)PDFListViewerTouchEndedIsAudioRecordMedia:(CPDFListView *)pdfListView {
- if (CPDFMediaStateAudioRecord == [CPDFMediaManager shareManager].mediaState) {
- [self PDFListViewPerformTouchEnded:self.pdfListView];
- return YES;
- }
- return NO;
- }
- - (void)PDFListViewPerformCancelMedia:(CPDFListView *)pdfView atPoint:(CGPoint)point forPage:(CPDFPage *)page {
- [CPDFMediaManager shareManager].mediaState = CPDFMediaStateStop;
- }
- - (void)PDFListViewPerformRecordMedia:(CPDFListView *)pdfView atPoint:(CGPoint)point forPage:(CPDFPage *)page {
- if([self.soundPlayBar superview]) {
- if(self.soundPlayBar.soundState == CPDFSoundStatePlay) {
- [self.soundPlayBar stopAudioPlay];
- [self.soundPlayBar removeFromSuperview];
- } else if (self.soundPlayBar.soundState == CPDFSoundStateRecord) {
- [self.soundPlayBar stopRecord];
- [self.soundPlayBar removeFromSuperview];
- }
- }
-
- AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio];
- if (authStatus == AVAuthorizationStatusNotDetermined || authStatus == AVAuthorizationStatusDenied) {
- [AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL granted) {
- if (granted) {
-
- } else {
- NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
- if ([[UIApplication sharedApplication] canOpenURL:url]) {
- [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
- }
- }
- }];
- }
-
- if (authStatus == AVAuthorizationStatusAuthorized) {
- NSInteger pageindex = [self.pdfListView.document indexForPage:page];
- [CPDFMediaManager shareManager].mediaState = CPDFMediaStateAudioRecord;
- [CPDFMediaManager shareManager].pageNum = pageindex;
- [CPDFMediaManager shareManager].ptInPdf = point;
-
- _soundPlayBar = [[CPDFSoundPlayBar alloc] initWithStyle:self.annotationManage.annotStyle];
- _soundPlayBar.delegate = self;
- [_soundPlayBar showInView:self.pdfListView soundState:CPDFSoundStateRecord];
- [_soundPlayBar startAudioRecord];
-
- } else {
- return;
- }
- }
- - (void)PDFListViewPerformPlay:(CPDFListView *)pdfView forAnnotation:(CPDFSoundAnnotation *)annotation {
- NSString *filePath = [annotation mediaPath];
- if (filePath) {
- NSURL *URL = [NSURL fileURLWithPath:filePath];
-
- _soundPlayBar = [[CPDFSoundPlayBar alloc] initWithStyle:self.annotationManage.annotStyle];
- _soundPlayBar.delegate = self;
- [_soundPlayBar showInView:self.pdfListView soundState:CPDFSoundStatePlay];
- [_soundPlayBar setURL:URL];
- [_soundPlayBar startAudioPlay];
- [CPDFMediaManager shareManager].mediaState = CPDFMediaStateVedioPlaying;
- }
- }
- - (void)PDFListViewPerformSignatureWidget:(CPDFListView *)pdfView forAnnotation:(CPDFSignatureWidgetAnnotation *)annotation {
- [self.annotationBar openSignatureAnnotation:annotation];
- }
- - (void)PDFListViewEditProperties:(CPDFListView *)pdfListView forAnnotation:(CPDFAnnotation *)annotation {
- [self.annotationBar buttonItemClicked_openAnnotation:self.titleButton];
- }
- #pragma mark - CPDFKeyboardToolbarDelegate
- - (void)keyboardShouldDissmiss:(CPDFKeyboardToolbar *)toolbar {
- [self.pdfListView commitEditAnnotationFreeText];
- self.pdfListView.annotationMode = CPDFViewAnnotationModeNone;
- [self.annotationBar reloadData];
- }
- #pragma mark - CPDFBOTAViewControllerDelegate
- - (void)botaViewControllerDismiss:(CPDFBOTAViewController *)botaViewController {
- [self.navigationController dismissViewControllerAnimated:YES completion:nil];
- }
- #pragma mark - CPDFAnnotationBarDelegate
- - (void)annotationBarClick:(CPDFAnnotationToolBar *)annotationBar clickAnnotationMode:(CPDFViewAnnotationMode)annotationMode forSelected:(BOOL)isSelected forButton:(UIButton *)button {
- if(CPDFViewAnnotationModeInk == annotationMode || CPDFViewAnnotationModePencilDrawing == annotationMode) {
- CGFloat tPosY = 0;
- if(isSelected) {
- [self.navigationController setNavigationBarHidden:YES animated:YES];
- [UIView animateWithDuration:0.3 animations:^{
- CGRect frame = self.annotationBar.frame;
- frame.origin.y = self.view.bounds.size.height;
- self.annotationBar.frame = frame;
- self.pdfListView.pageSliderView.alpha = 0.0;
-
- UIEdgeInsets inset = self.pdfListView.documentView.contentInset;
- inset.bottom = 0;
- self.pdfListView.documentView.contentInset = inset;
- }];
- } else {
- [self.navigationController setNavigationBarHidden:NO animated:YES];
- [UIView animateWithDuration:0.3 animations:^{
- CGRect frame = self.annotationBar.frame;
- frame.origin.y = self.view.bounds.size.height-frame.size.height;
- self.annotationBar.frame = frame;
- self.pdfListView.pageSliderView.alpha = 1.0;
- }];
- CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
- tPosY = self.navigationController.navigationBar.frame.size.height + rectStatus.size.height;
- UIEdgeInsets inset = self.pdfListView.documentView.contentInset;
- inset.bottom = self.annotationBar.frame.size.height;
- self.pdfListView.documentView.contentInset = inset;
- }
- } else if (CPDFViewAnnotationModeSound == annotationMode && !isSelected) {
- if(CPDFSoundStateRecord == self.soundPlayBar.soundState) {
- [self.soundPlayBar stopRecord];
- } else if (CPDFSoundStatePlay== self.soundPlayBar.soundState) {
- [self.soundPlayBar stopAudioPlay];
- }
- }
- }
- #pragma mark - CPDFNoteOpenViewControllerDelegate
- - (void)getNoteOpenViewController:(CPDFNoteOpenViewController *)noteOpenVC content:(NSString *)content isDelete:(BOOL)isDelete {
- if (isDelete) {
- [noteOpenVC.annotation.page removeAnnotation:noteOpenVC.annotation];
- [self.pdfListView setNeedsDisplayForPage:noteOpenVC.annotation.page];
- if([self.pdfListView.activeAnnotations containsObject:noteOpenVC.annotation]) {
- NSMutableArray *activeAnnotations = [NSMutableArray arrayWithArray:self.pdfListView.activeAnnotations];
- [activeAnnotations removeObject:noteOpenVC.annotation];
- [self.pdfListView updateActiveAnnotations:activeAnnotations];
- }
- } else {
- if([noteOpenVC.annotation isKindOfClass:[CPDFMarkupAnnotation class]]) {
- CPDFMarkupAnnotation *markupAnnotation = (CPDFMarkupAnnotation *)noteOpenVC.annotation;
- [markupAnnotation setContents:content?:@""];
- } else if(([noteOpenVC.annotation isKindOfClass:[CPDFTextAnnotation class]])){
- if(content && content.length > 0) {
- noteOpenVC.annotation.contents = content?:@"";
- } else {
- if([self.pdfListView.activeAnnotations containsObject:noteOpenVC.annotation]) {
- [self.pdfListView updateActiveAnnotations:@[]];
- }
- [noteOpenVC.annotation.page removeAnnotation:noteOpenVC.annotation];
- [self.pdfListView setNeedsDisplayForPage:noteOpenVC.annotation.page];
- }
- } else {
- noteOpenVC.annotation.contents = content?:@"";
- }
- }
- }
- #pragma mark - CPDFSoundPlayBarDelegate
- - (void)soundPlayBarRecordFinished:(CPDFSoundPlayBar *)soundPlayBar withFile:(NSString *)filePath {
- CPDFPage *page = [self.pdfListView.document pageAtIndex:[CPDFMediaManager shareManager].pageNum];
- CPDFSoundAnnotation *annotation = [[CPDFSoundAnnotation alloc] initWithDocument:self.pdfListView.document];
-
- if ([annotation setMediaPath:filePath]) {
- CGRect bounds = annotation.bounds;
- bounds.origin.x = [CPDFMediaManager shareManager].ptInPdf.x-bounds.size.width/2.0;
- bounds.origin.y = [CPDFMediaManager shareManager].ptInPdf.y-bounds.size.height/2.0;
- annotation.bounds = bounds;
- [self.pdfListView addAnnotation:annotation forPage:page];
- }
- [CPDFMediaManager shareManager].mediaState = CPDFMediaStateStop;
- [self.pdfListView stopRecord];
- }
- - (void)soundPlayBarRecordCancel:(CPDFSoundPlayBar *)soundPlayBar {
- if(CPDFSoundStateRecord == self.soundPlayBar.soundState) {
- [self.pdfListView stopRecord];
- }
- [CPDFMediaManager shareManager].mediaState = CPDFMediaStateStop;
- }
- - (void)soundPlayBarPlayClose:(CPDFSoundPlayBar *)soundPlayBar {
- [CPDFMediaManager shareManager].mediaState = CPDFMediaStateStop;
- }
- #pragma mark - Notification
- - (void)PDFPageDidRemoveAnnotationNotification:(NSNotification *)notification {
- CPDFAnnotation *annotation = [notification object];
- if ([annotation isKindOfClass:[CPDFSoundAnnotation class]]) {
- [self.soundPlayBar stopAudioPlay];
- if ([self.soundPlayBar isDescendantOfView:self.view]) {
- [self.soundPlayBar removeFromSuperview];
- }
- }
- }
- #pragma mark - CPDFToolsViewControllerDelegate
- - (void)CPDFToolsViewControllerDismiss:(CPDFToolsViewController *) viewController selectItemAtIndex:(CPDFToolFunctionTypeState)selectIndex {
- if(CPDFToolFunctionTypeStateViewer == selectIndex) {
- //viewwer
- [self enterViewerMode];
- }else{
- //Annotation
- [self enterAnnotationMode];
- }
- }
- @end
|