如何在swift中从我的iPhone应用程序在Adobe acrobat中查看pdf
问题描述:
我是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)
}
答
你为什么要使用Acrobat,当你可以在你的应用程序中查看它?您可以使用来自PDFKit的PDFView
,如here所述。它有一个document
属性,类型为PDFDocument
,您可以从文件或数据中初始化。
如果您想在外部应用程序中打开它,您可能需要查看UIActivityViewController
,以便用户可以选择打开PDF的应用程序。