我正在使用此代码从服务器下载pdf文件。
NSString *urlString = @"https://developer.apple.com/library/ios/documentation/uikit/reference/UILabel_Class/UILabel_Class.pdf";
NSURL *url = [NSURL URLWithString:urlString];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"UILabel.pdf"]];
[request setDelegate:self];
[request startAsynchronous];下载功能工作正常。但我需要用CGPDFDocumentRef显示下载的pdf文件。
提前谢谢。
发布于 2012-03-12 20:02:31
下载pdf后,将该pdf文件保存到document目录中,并从那里检索您的pdf并使用CGDocumentref显示,如下所示:
CFURLRef pdfURL = (CFURLRef)[[NSURL alloc] initFileURLWithPath:[documentsDirectory stringByAppendingPathComponent:source]];
//file ref
CGPDFDocumentRef pdfRef = CGPDFDocumentCreateWithURL((CFURLRef) pdfURL);https://stackoverflow.com/questions/9666283
复制相似问题