Failed to download and open a PDF file with error failed to find PDF header in ios

前端 未结 2 912
迷失自我
迷失自我 2020-12-18 15:30

I am having an app in which I am opening a PDF file from a url.

I am successfully able to open it in a webView.

Now I want to download that PDF file and sa

2条回答
  •  不知归路
    2020-12-18 16:02

    If convert to string server response, that you got in NSData *pdfData, you will see next:

    
    
    
        iOS Developer Library
        
        
        
    
    
    
    
    
    

    This only web page, which, as I can assume, will forward you to document with another URI: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebView_Class/UIWebView_Class.pdf. So you must use this url if you want to download .pdf file

    Also, pay attention on @pawan's answer, and use his approach to avoid download files in main thread

提交回复
热议问题