1
votes

I am downloading pdf file from server using this code.

   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];

Download functionality is working fine. But i need to show the downloaded pdf with CGPDFDocumentRef.

Thanks in advance.

1

1 Answers

3
votes

After downloading your pdf save that pdf file into document directory and from there retrive your pdf and display using CGDocumentref as below:

  CFURLRef pdfURL = (CFURLRef)[[NSURL alloc] initFileURLWithPath:[documentsDirectory stringByAppendingPathComponent:source]];
        //file ref
        CGPDFDocumentRef pdfRef = CGPDFDocumentCreateWithURL((CFURLRef) pdfURL);