0

I am new in IOS and I want to view a PDF file using Adobe Acrobat application which is installed on my iPhone.The Pdf file which I want to view in Adobe acrobat coming from web service in base64 format.I have converted in bytes than in .pdf format.My pdf is now in .pdf format.But now how to open this pdf in Adobe Acrobat. In my code temper is the path of my pdf.

  @IBAction func savePDF(_ sender: Any) {
        let pdfData = Data(base64Encoded: FilePDF, options: .ignoreUnknownCharacters)
        let array = pdfData?.withUnsafeBytes
        {
            [UInt8](UnsafeBufferPointer(start: $0, count: (pdfData?.count)!))
        }
        let data = NSData(bytes: array, length: (array?.count)!);
        let tmpDir = NSTemporaryDirectory()
        data.write(toFile: tmpDir.appending("HandyHR_File_YEAR.pdf"), atomically: true)
         print(array!)
        print(data)
        print(tmpDir)
      }
Sahil
  • 9,096
  • 3
  • 25
  • 29
rachna sharma
  • 111
  • 2
  • 3
  • 13

1 Answers1

0

Why do you want to use Acrobat when you can view it in your app? You can use a PDFView from PDFKit as documented here. It has a document property of type PDFDocument that you can init from a file or data.

If you want to open it in an external app you would probably want to look at UIActivityViewController so the user can select the app in which to open the PDF.

Michael
  • 8,891
  • 3
  • 29
  • 42