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.
Asked
Active
Viewed 907 times
1
-
Duplicate: https://stackoverflow.com/questions/10519122/pdf-file-in-uiwebview-with-password – El Tomato Feb 13 '18 at 06:18
1 Answers
3
You should use PDFKit and display your PDF with a PDFView
instead 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
-
thanks for the answer. However, PDFView requires minimum deployment target of iOS 11. I want to support iOS 9 and above. – Nirav Feb 13 '18 at 06:25
-
1