【发布时间】:2012-09-24 07:09:57
【问题描述】:
目前我正在使用 iPhone 应用程序,我在资源文件夹(本地 pdf 文件)中有一个 pdf 文件,然后我成功读取了该 pdf 文件(paper.pdf),下面我提到了读取本地 pdf 文件供您参考。
例子:
CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("paper.pdf"), NULL, NULL);
pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
CFRelease(pdfURL);
然后我尝试将pdf文件(来自URL)存储在NSDocument目录中,存储成功。
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://www.msy.com.au/Parts/PARTS.pdf"]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"myPDF11.pdf"];
[pdfData writeToFile:filePath atomically:YES];
然后我尝试读取该 pdf 文件(来自 NSDocument 目录),但我不知道,请帮助我。
提前致谢
【问题讨论】:
标签: iphone ios multithreading nsdocumentdirectory pdf-reader