1

I am loading a PDF file in UIWebView. The PDF file is password protected. But I don't want the UIWebView to prompt for a password. I already have password stored in my database. So I want to implicitly provide the password to UIWebView and load the PDF document without prompting the user for password.

clemens
  • 16,716
  • 11
  • 50
  • 65
Nirav
  • 119
  • 7

1 Answers1

3

You should use PDFKit and display your PDF with a PDFViewinstead of a UIWebView which is deprecated. PDFDocument has an unlock method. So you can display protected documents without displaying a password prompt.

Edit: PDFKit only available as of iOS 11. For older iOS versions you may draw the PDF with Core Graphics and CGPDFDocument (see https://stackoverflow.com/a/39758774/2352344). I would use the PDFKit for iOS 11 and only for the older iOS versions Core Graphics.

clemens
  • 16,716
  • 11
  • 50
  • 65