24

How to read and display PDF in Objective-C?

Matas Vaitkevicius
  • 54,146
  • 29
  • 227
  • 241
meoden8x
  • 273
  • 1
  • 2
  • 3

3 Answers3

26

If you just want to display it, the easiest way is to load it in a UIWebView.

Morten Fast
  • 6,292
  • 26
  • 36
  • are you able to control the height of the UIWebView, Im having problems to get that fit my entire screen on an iPhone 5 – valbu17 Jul 20 '14 at 17:16
  • Apple will stop accepting submissions of app updates that use UIWebView APIs starting from December 2020. You may see https://developer.apple.com/documentation/uikit/uiwebview for more information. – Panayot Apr 22 '20 at 11:44
10

If you want to solely read and display PDFs to users, as the Mail app does on your iOS device with all the scrolling and zooming done for you, then I would use a UIDocumentInteractionController.

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIDocumentInteractionController_class/Reference/Reference.html

You'll find some useful code in one of my recent questions, here:

UIDocumentInteractionController crashing upon exit

Hope this helps.

Community
  • 1
  • 1
Luke
  • 11,400
  • 43
  • 61
  • 68
4

the easiset way is with the UIDocumentInteractionController

Drawback: you need a local file-url

akjoshi
  • 14,989
  • 13
  • 101
  • 119
Karsten
  • 1,786
  • 19
  • 37