1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- //
- // CPDFViewController.m
- // PDFViewer
- //
- // Created by kdan on 2022/11/15.
- //
- #import <ComPDFKit/ComPDFKit.h>
- #import <ComPDFKit/CPDFWatermark.h>
- #import <ComPDFKit/CPDFHeaderFooter.h>
- #import "CPDFViewController.h"
- @interface CPDFViewController () <UIActionSheetDelegate>
- @end
- @implementation CPDFViewController
- - (instancetype)initWithPath:(NSString *)inPath {
- if (self = [super init]) {
- _path = inPath;
- }
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- //add UIBarButtonItem in Navigation
- self.navigationController.toolbarHidden = NO;
- UIImage *btnMore = [UIImage imageNamed:@"btn_more"];
- UIBarButtonItem *ringhtBarItem = [[UIBarButtonItem alloc] initWithImage:btnMore style:UIBarButtonItemStylePlain target:self action:@selector(onClickedOkbtn)];
- self.navigationItem.rightBarButtonItem = ringhtBarItem;
- //setting URL
- NSURL *url = [NSURL fileURLWithPath:_path];
- CPDFDocument *document = [[CPDFDocument alloc] initWithURL:url];
- CPDFView *pdfView = [[CPDFView alloc] initWithFrame:self.view.bounds];
- pdfView.document = document;
- pdfView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- [self.view addSubview:pdfView];
- }
- - (void)onClickedOkbtn {
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
- UIAlertAction *addWatermarkAction = [UIAlertAction actionWithTitle:@"Add Watermark" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- NSLog(@"addWatermarkAction");
- }];
- UIAlertAction *addHeaderfooterAction = [UIAlertAction actionWithTitle:@"Add Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- NSLog(@"addHeaderfooterAction");
- }];
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- NSLog(@"Cancel Action");
- }];
- [alertController addAction:addWatermarkAction];
- [alertController addAction:addHeaderfooterAction];
- [alertController addAction:cancelAction];
- [self presentViewController:alertController animated:YES completion:nil];
- }
- @end
|