├── 001.pdf ├── 002.pdf ├── 003.pdf ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj ├── LaunchScreen.xib └── Main.storyboard ├── Images.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Info.plist ├── README.md ├── ZPDFListViewController.h ├── ZPDFListViewController.m ├── ZPDFPageController.h ├── ZPDFPageController.m ├── ZPDFPageModel.h ├── ZPDFPageModel.m ├── ZPDFReaderController.h ├── ZPDFReaderController.m ├── ZPDFView.h ├── ZPDFView.m └── main.m /001.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShadowLJia/PDFReader/3cc74b2dfd7bc5f1929cabda630a00456ec3f616/001.pdf -------------------------------------------------------------------------------- /002.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShadowLJia/PDFReader/3cc74b2dfd7bc5f1929cabda630a00456ec3f616/002.pdf -------------------------------------------------------------------------------- /003.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShadowLJia/PDFReader/3cc74b2dfd7bc5f1929cabda630a00456ec3f616/003.pdf -------------------------------------------------------------------------------- /AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // pdfReader 4 | // 5 | // Created by XuJackie on 15/6/6. 6 | // Copyright (c) 2015年 peter. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // pdfReader 4 | // 5 | // Created by XuJackie on 15/6/6. 6 | // Copyright (c) 2015年 peter. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ZPDFListViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | // Override point for customization after application launch. 21 | self.window.backgroundColor = [UIColor whiteColor]; 22 | [self.window makeKeyAndVisible]; 23 | //self.window.rootViewController = [[TestViewController alloc] init]; 24 | //self.window.rootViewController = [[DemoViewController alloc] init]; 25 | //self.window.rootViewController = [[JSDemoViewController alloc] init]; 26 | UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController: [[ZPDFListViewController alloc] init]]; 27 | self.window.rootViewController = navCtrl; 28 | //NSLog(@"__FUNCTION__ = %s",__FUNCTION__); 29 | return YES; 30 | } 31 | 32 | - (void)applicationWillResignActive:(UIApplication *)application { 33 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 34 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 35 | } 36 | 37 | - (void)applicationDidEnterBackground:(UIApplication *)application { 38 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 39 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 40 | } 41 | 42 | - (void)applicationWillEnterForeground:(UIApplication *)application { 43 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 44 | } 45 | 46 | - (void)applicationDidBecomeActive:(UIApplication *)application { 47 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 48 | } 49 | 50 | - (void)applicationWillTerminate:(UIApplication *)application { 51 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.peter.apps.pdfReader 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | pdfReader 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PDFReader 2 | 3 | 一个PDF阅读器 4 | -------------------------------------------------------------------------------- /ZPDFListViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZPDFListViewController.h 3 | // pdfReader 4 | // 5 | // Created by XuJackie on 15/6/6. 6 | // Copyright (c) 2015年 peter. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ZPDFListViewController : UIViewController 12 | { 13 | float view_width, view_height; 14 | NSArray *titleArray, *fileArray; 15 | UITableView *pdfTableView; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /ZPDFListViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZPDFListViewController.m 3 | // pdfReader 4 | // 5 | // Created by XuJackie on 15/6/6. 6 | // Copyright (c) 2015年 peter. All rights reserved. 7 | // 8 | 9 | #import "ZPDFListViewController.h" 10 | #import "ZPDFReaderController.h" 11 | 12 | @interface ZPDFListViewController () 13 | 14 | @end 15 | 16 | @implementation ZPDFListViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view. 21 | view_width = self.view.frame.size.width; 22 | view_height = self.view.frame.size.height; 23 | NSLog(@"self.view.frame = %@",NSStringFromCGRect(self.view.frame)); 24 | titleArray = @[@"iOS 开发笔记——PDF的显示和浏览",@"Objective-C和CoreFoundation对象相互转换的内存管理总结",@"HTML5从入门到精通"]; 25 | fileArray = @[@"001.pdf", @"002.pdf", @"003.pdf"]; 26 | CGRect frame = CGRectMake(10, 64, view_width-20, view_height-100); 27 | pdfTableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStylePlain]; 28 | pdfTableView.dataSource = self; 29 | pdfTableView.delegate = self; 30 | pdfTableView.tableHeaderView = [[UIView alloc] init]; 31 | pdfTableView.tableFooterView = [[UIView alloc] init]; 32 | [self.view addSubview:pdfTableView]; 33 | } 34 | 35 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 36 | return titleArray.count; 37 | } 38 | 39 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 40 | return 50; 41 | } 42 | 43 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 44 | static NSString *cellIdentifier = @"pdfTableView_cell"; 45 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 46 | if (cell == nil) { 47 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier]; 48 | } 49 | NSString *titleText = [titleArray objectAtIndex:indexPath.row]; 50 | cell.textLabel.text = titleText; 51 | return cell; 52 | } 53 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 54 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 55 | NSLog(@"didSelectRowAtIndexPath >>>> "); 56 | 57 | ZPDFReaderController *targetViewCtrl = [[ZPDFReaderController alloc] init]; 58 | targetViewCtrl.hidesBottomBarWhenPushed = YES;//从第一个页面跳到第二个页面时隐藏tabBar的设置方法 59 | targetViewCtrl.titleText = [titleArray objectAtIndex:indexPath.row]; 60 | targetViewCtrl.fileName = [fileArray objectAtIndex:indexPath.row]; 61 | [self.navigationController pushViewController:targetViewCtrl animated:YES]; 62 | } 63 | 64 | - (void)didReceiveMemoryWarning { 65 | [super didReceiveMemoryWarning]; 66 | // Dispose of any resources that can be recreated. 67 | } 68 | 69 | /* 70 | #pragma mark - Navigation 71 | 72 | // In a storyboard-based application, you will often want to do a little preparation before navigation 73 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 74 | // Get the new view controller using [segue destinationViewController]. 75 | // Pass the selected object to the new view controller. 76 | } 77 | */ 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /ZPDFPageController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZPDFPageController.h 3 | // pdfReader 4 | // 5 | // Created by XuJackie on 15/6/6. 6 | // Copyright (c) 2015年 peter. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ZPDFPageController : UIViewController 12 | // CGPDFDocumentRef pdfDocument; 13 | @property (assign, nonatomic) CGPDFDocumentRef pdfDocument; 14 | @property (assign, nonatomic) long pageNO; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ZPDFPageController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZPDFPageController.m 3 | // pdfReader 4 | // 5 | // Created by XuJackie on 15/6/6. 6 | // Copyright (c) 2015年 peter. All rights reserved. 7 | // 8 | 9 | #import "ZPDFPageController.h" 10 | #import "ZPDFView.h" 11 | 12 | @interface ZPDFPageController () 13 | 14 | @end 15 | 16 | @implementation ZPDFPageController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view. 21 | CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); 22 | ZPDFView *pdfView = [[ZPDFView alloc] initWithFrame:frame atPage:self.pageNO withPDFDoc:self.pdfDocument]; 23 | pdfView.backgroundColor=[UIColor whiteColor]; 24 | [self.view addSubview:pdfView]; 25 | 26 | } 27 | 28 | - (void)didReceiveMemoryWarning { 29 | [super didReceiveMemoryWarning]; 30 | // Dispose of any resources that can be recreated. 31 | } 32 | 33 | /* 34 | #pragma mark - Navigation 35 | 36 | // In a storyboard-based application, you will often want to do a little preparation before navigation 37 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 38 | // Get the new view controller using [segue destinationViewController]. 39 | // Pass the selected object to the new view controller. 40 | } 41 | */ 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /ZPDFPageModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZPDFPageModel.h 3 | // pdfReader 4 | // 5 | // Created by XuJackie on 15/6/6. 6 | // Copyright (c) 2015年 peter. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class ZPDFPageController; 13 | 14 | @interface ZPDFPageModel : NSObject 15 | { 16 | CGPDFDocumentRef pdfDocument; 17 | } 18 | //@property (assign, nonatomic) CGPDFDocumentRef pdfDocument; 19 | //@property (strong, nonatomic) NSArray *pageContent; 20 | -(id) initWithPDFDocument:(CGPDFDocumentRef) pdfDocument; 21 | 22 | - (ZPDFPageController *)viewControllerAtIndex:(NSUInteger)index; 23 | - (NSUInteger)indexOfViewController:(ZPDFPageController *)viewController; 24 | @end 25 | -------------------------------------------------------------------------------- /ZPDFPageModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZPDFPageModel.m 3 | // pdfReader 4 | // 5 | // Created by XuJackie on 15/6/6. 6 | // Copyright (c) 2015年 peter. All rights reserved. 7 | // 8 | 9 | #import "ZPDFPageModel.h" 10 | #import "ZPDFPageController.h" 11 | 12 | @implementation ZPDFPageModel 13 | 14 | -(id) initWithPDFDocument:(CGPDFDocumentRef) pdfDoc { 15 | self = [super init]; 16 | if (self) { 17 | pdfDocument = pdfDoc; 18 | } 19 | return self; 20 | } 21 | 22 | - (ZPDFPageController *)viewControllerAtIndex:(NSUInteger)pageNO { 23 | // Return the data view controller for the given index. 24 | long pageSum = CGPDFDocumentGetNumberOfPages(pdfDocument); 25 | if (pageSum== 0 || pageNO >= pageSum+1) { 26 | return nil; 27 | } 28 | // Create a new view controller and pass suitable data. 29 | ZPDFPageController *pageController = [[ZPDFPageController alloc] init]; 30 | pageController.pdfDocument = pdfDocument; 31 | pageController.pageNO = pageNO; 32 | return pageController; 33 | } 34 | 35 | - (NSUInteger)indexOfViewController:(ZPDFPageController *)viewController { 36 | return viewController.pageNO; 37 | } 38 | 39 | 40 | - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController { 41 | NSUInteger index = [self indexOfViewController: (ZPDFPageController *)viewController]; 42 | if ((index == 1) || (index == NSNotFound)) { 43 | return nil; 44 | } 45 | index--; 46 | return [self viewControllerAtIndex:index]; 47 | } 48 | 49 | - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController { 50 | NSUInteger index = [self indexOfViewController: (ZPDFPageController *)viewController]; 51 | if (index == NSNotFound) { 52 | return nil; 53 | } 54 | index++; 55 | long pageSum = CGPDFDocumentGetNumberOfPages(pdfDocument); 56 | if (index >= pageSum+1) { 57 | return nil; 58 | } 59 | return [self viewControllerAtIndex:index]; 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /ZPDFReaderController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZPDFReaderController.h 3 | // pdfReader 4 | // 5 | // Created by XuJackie on 15/6/6. 6 | // Copyright (c) 2015年 peter. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ZPDFPageModel.h" 11 | 12 | @interface ZPDFReaderController : UIViewController 13 | { 14 | UIPageViewController *pageViewCtrl; 15 | ZPDFPageModel *pdfPageModel; 16 | } 17 | @property(nonatomic,copy)NSString *titleText, *fileName; 18 | @end 19 | -------------------------------------------------------------------------------- /ZPDFReaderController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZPDFReaderController.m 3 | // pdfReader 4 | // 5 | // Created by XuJackie on 15/6/6. 6 | // Copyright (c) 2015年 peter. All rights reserved. 7 | // 8 | 9 | #import "ZPDFReaderController.h" 10 | #import "ZPDFPageController.h" 11 | 12 | @interface ZPDFReaderController () 13 | 14 | @end 15 | 16 | @implementation ZPDFReaderController 17 | @synthesize titleText, fileName; 18 | - (void) viewDidLoad { 19 | [super viewDidLoad]; 20 | self.view.backgroundColor = [UIColor whiteColor]; 21 | self.title = self.titleText; 22 | //CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("test.pdf"), NULL, NULL); 23 | CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), (__bridge CFStringRef)self.fileName, NULL, NULL); 24 | CGPDFDocumentRef pdfDocument = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL); 25 | CFRelease(pdfURL); 26 | pdfPageModel = [[ZPDFPageModel alloc] initWithPDFDocument:pdfDocument]; 27 | 28 | NSDictionary *options = [NSDictionary dictionaryWithObject: 29 | [NSNumber numberWithInteger: UIPageViewControllerSpineLocationMin] 30 | forKey: UIPageViewControllerOptionSpineLocationKey]; 31 | 32 | pageViewCtrl = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl 33 | navigationOrientation:UIPageViewControllerNavigationOrientationVertical 34 | options:options]; 35 | ZPDFPageController *initialViewController = [pdfPageModel viewControllerAtIndex:1]; 36 | NSArray *viewControllers = [NSArray arrayWithObject:initialViewController]; 37 | [pageViewCtrl setDataSource:pdfPageModel]; 38 | 39 | [pageViewCtrl setViewControllers:viewControllers 40 | direction:UIPageViewControllerNavigationDirectionReverse 41 | animated:NO 42 | completion:^(BOOL f){}]; 43 | [self addChildViewController:pageViewCtrl]; 44 | [self.view addSubview:pageViewCtrl.view]; 45 | [pageViewCtrl didMoveToParentViewController:self]; 46 | } 47 | 48 | - (void) viewDidUnload { 49 | 50 | [super viewDidUnload]; 51 | } 52 | - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { 53 | return YES; 54 | } 55 | 56 | - (void)didReceiveMemoryWarning { 57 | [super didReceiveMemoryWarning]; 58 | // Dispose of any resources that can be recreated. 59 | } 60 | 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /ZPDFView.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZPDFView.h 3 | // pdfReader 4 | // 5 | // Created by XuJackie on 15/6/6. 6 | // Copyright (c) 2015年 peter. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ZPDFView : UIView { 12 | CGPDFDocumentRef pdfDocument; 13 | int pageNO; 14 | } 15 | 16 | -(id)initWithFrame:(CGRect)frame atPage:(int)index withPDFDoc:(CGPDFDocumentRef) pdfDoc; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ZPDFView.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZPDFView.m 3 | // pdfReader 4 | // 5 | // Created by XuJackie on 15/6/6. 6 | // Copyright (c) 2015年 peter. All rights reserved. 7 | // 8 | 9 | #import "ZPDFView.h" 10 | 11 | @implementation ZPDFView 12 | 13 | -(id)initWithFrame:(CGRect)frame atPage:(int)index withPDFDoc:(CGPDFDocumentRef) pdfDoc{ 14 | self = [super initWithFrame:frame]; 15 | pageNO = index; 16 | pdfDocument = pdfDoc; 17 | return self; 18 | } 19 | 20 | -(void)drawInContext:(CGContextRef)context atPageNo:(int)page_no{ 21 | // PDF page drawing expects a Lower-Left coordinate system, so we flip the coordinate system 22 | // before we start drawing. 23 | CGContextTranslateCTM(context, 0.0, self.bounds.size.height); 24 | CGContextScaleCTM(context, 1.0, -1.0); 25 | 26 | int pageSum = CGPDFDocumentGetNumberOfPages(pdfDocument); 27 | NSLog(@"pageSum = %d", pageSum); 28 | if (pageNO == 0) { 29 | pageNO = 1; 30 | } 31 | CGPDFPageRef page = CGPDFDocumentGetPage(pdfDocument, pageNO); 32 | CGContextSaveGState(context); 33 | CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, self.bounds, 0, true); 34 | CGContextConcatCTM(context, pdfTransform); 35 | CGContextDrawPDFPage(context, page); 36 | CGContextRestoreGState(context); 37 | } 38 | 39 | - (void)drawRect:(CGRect)rect { 40 | [self drawInContext:UIGraphicsGetCurrentContext() atPageNo:pageNO]; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // pdfReader 4 | // 5 | // Created by XuJackie on 15/6/6. 6 | // Copyright (c) 2015年 peter. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | --------------------------------------------------------------------------------