现在的位置: 首页 > 综合 > 正文

PDF以及iOS库以及FastPDFkit 续

2013年09月14日 ⁄ 综合 ⁄ 共 3189字 ⁄ 字号 评论关闭

上回说到这个FastPDF还是不错的,至少用于demo学习,足以。下载:Download now FastPdfKit

FastPdfKit is available in 4 versions: Free, Basic, Plus and Extra, all availables throgh the public repository on github. 目前来说有4个版本,均可以在github得到下载

In the repository you'll find a sample Xcode project with many targets that you can customize based on your needs. To start you can try the static version distributed as framework (click
here
 for project direct download) that will let you add pdf support in your applications with a single step. (通过添加静态库,然后使用的方式就可以通过简单的步骤让你的APP支持PDF,当然不是仅仅浏览了)

With the free version you can use every FastPdfKit features for an unlimited period. The single limitation is a Splash Screen with FastPdfKit logo when you open every pubblication.You can obviously use this version to distribute applications on the App Store,
no limits. 使用免费版本,你能够得到所有FastPDFkit的特性,只不过需要看到一个弹出界面,同时你还可以使用free的版本,单发布到App store,这个是完全可以的。

http://fastpdfkit.com/ios-framework:

Precise
zoom
 on annotations and page parts 这个算个feature,可以在批注上zoom//

Auto
mode
: single page in portrait and double page in landscape: 这个就自动布局,如果是landscape就双栏显示

Added
a method to retrieve annotations from the document and provide them as overlays, 在2011的某个版本中,增加了获取批注并以overlay的方式呈现的功能:


在下载的代码中:

  MenuViewController *aMenuViewController = nil;
	
	if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
			aMenuViewController = [[MenuViewController alloc]initWithNibName:@"MenuView_pad" bundle:[NSBundle mainBundle]];
	} else {
			aMenuViewController = [[MenuViewController alloc]initWithNibName:@"MenuView_phone" bundle:[NSBundle mainBundle]];
	}

 要实现下面截图的功能,啥也不用干,采用一个readerview,再加一个documentmanager

 

基本步骤3steps:

1. 把下载得到的所有library和build信息,xcconfig,整个目录copy到你自己的项目中

2. 修改project configuration info,选择fastodfkitframework,

3,完成代码,调用vc,打开PDF文件

    /** Present the pdf on screen in a modal view */

    [self
presentModalViewController:pdfViewController
animated:YES]; 

ReaderVC->MFDocumentmanger->NSURL->DocumentName:

会自动把缩略图生成到目录下,且后续能够点击缩略图后关联navigate到特定page

 /** Set resources folder on the manager */

    documentManager.resourceFolder = thumbnailsPath;

==============

NSFileManager *manager = [NSFileManager
defaultManager];

   
NSDirectoryEnumerator
*direnum = [manager enumeratorAtPath:thumbnailsPath];

    

   
NSString
*filename;

    

   
while
((filename = [direnum nextObject] )) {

        

       
NSLog
(@"%@",filename);

                

    }

=========

关于PDF缩略图,方法一直接从PDF文件中获取,方法二,自己利用一些方法产生(例如using quartz) ,然后保存下来:方法二:

- (UIImage *)imageFromPDFWithDocumentRef :( CGPDFDocumentRef)documentRef {
    CGPDFPageRef pageRef = CGPDFDocumentGetPage(documentRef, 1);
    CGRect pageRect = CGPDFPageGetBoxRect(pageRef, kCGPDFCropBox);

    UIGraphicsBeginImageContext(pageRect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextTranslateCTM(context, CGRectGetMinX(pageRect),CGRectGetMaxY(pageRect));
    CGContextScaleCTM(context, 1, -1);  
    CGContextTranslateCTM(context, -(pageRect.origin.x), -(pageRect.origin.y));
    CGContextDrawPDFPage(context, pageRef);

    UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return finalImage;
} 

Change
the above function to this: <code> - (UIImage *)imageFromPDFWithDocumentRef:(CGPDFDocumentRef)documentRef and PageNumber:(int)pageNumber { CGPDFPageRef pageRef = CGPDFDocumentGetPage(documentRef, pageNumber);</code> then call it in a loop.

看另外一个代码,通过新起thread来处理,并且cache image:

However If you are targeting iOS 4 or above I would strongly recommend using blocks. (Also graphics contexts are thread safe since 4).

抱歉!评论已关闭.