2017-08-04 78 views
0

我是IOS中的新成員,我想使用安裝在我的iPhone上的Adobe Acrobat應用程序查看PDF文件。我想查看的PDF文件Adobe acrobat來自web服務,採用base64格式。我已經以字節轉換,而不是.pdf格式。我的pdf格式現在是.pdf格式。但現在如何在Adobe Acrobat中打開此pdf。 在我的代碼中,脾氣是我的pdf的路徑。如何在swift中從我的iPhone應用程序在Adobe acrobat中查看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) 
     } 

回答

0

你爲什麼要使用Acrobat,當你可以在你的應用程序中查看它?您可以使用來自PDFKit的PDFView,如here所述。它有一個document屬性,類型爲PDFDocument,您可以從文件或數據中初始化。

如果您想在外部應用程序中打開它,您可能需要查看UIActivityViewController,以便用戶可以選擇打開PDF的應用程序。

相關問題