24

How to read and display PDF in Objective-C?

Matas Vaitkevicius
  • 58,075
  • 31
  • 238
  • 265
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,322
  • 27
  • 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,426
  • 43
  • 60
  • 69
4

the easiset way is with the UIDocumentInteractionController

Drawback: you need a local file-url

akjoshi
  • 15,374
  • 13
  • 103
  • 121
Karsten
  • 1,869
  • 22
  • 38