首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用CGPDFDocumentRef显示下载的pdf文件?

如何用CGPDFDocumentRef显示下载的pdf文件?
EN

Stack Overflow用户
提问于 2012-03-12 19:34:46
回答 1查看 2.1K关注 0票数 1

我正在使用此代码从服务器下载pdf文件。

代码语言:javascript
复制
   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文件。

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-12 20:02:31

下载pdf后,将该pdf文件保存到document目录中,并从那里检索您的pdf并使用CGDocumentref显示,如下所示:

代码语言:javascript
复制
  CFURLRef pdfURL = (CFURLRef)[[NSURL alloc] initFileURLWithPath:[documentsDirectory stringByAppendingPathComponent:source]];
        //file ref
        CGPDFDocumentRef pdfRef = CGPDFDocumentCreateWithURL((CFURLRef) pdfURL);
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9666283

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档