Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use IOS Pdf reader Api to view remote pdf files via Url?

I have used iOS PDF Reader Core Api to create an iPhone app that displays pdf files on my device file system..

My doubt is how to use this api to view remote pdf files by giving a url path. The ReaderDocument object only accepts file paths to be specified.

Please help me..

like image 851
Abi Avatar asked Nov 04 '22 06:11

Abi


1 Answers

I don't believe there's a way to do this. I'm not very familiar with the framework you linked to, but I work full-time on the PSPDFKit iOS PDF SDK. To render PDF's on iOS, they need to be fully downloaded. You basically create a CGPDFDocument at some point either via

CGPDFDocumentCreateWithURL(...)
(or)
CGPDFDocumentCreateWithProvider(...)

Now CoreGraphics will throw out some cryptic error 15 if you try to feed CGPDFDocumentCreateWithURL with a remote URL (although it does work for /localhost/ remote URLs)

You theoretically could write a CGDataProvider that downloads the document on the fly, but the trouble is that iOS still will read and parse the whole PDF before it can display it - and I went through the trouble of writing a custom provider myself (one that supports AES256 and decrypts PDF content on the fly for extra security). It's really tricky to get it right.

tl,dr: You need to download the PDF. For example with this neat AFNetworking extension I wrote - it even supports resume.

like image 144
steipete Avatar answered Nov 14 '22 19:11

steipete