我是 IOS 新手,我想使用 iPhone 上安装的 Adobe Acrobat 应用程序查看 PDF 文件。我想在 Adobe acrobat 中查看来自 Web 服务的 Base64 格式的 Pdf 文件。我已将其转换为字节数比 .pdf 格式大。我的 pdf 现在是 .pdf 格式。但是现在如何在 Adobe Acrobat 中打开此 pdf。 在我的代码中temper是我的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 所示。 。它有一个 PDFDocument
类型的 document
属性,您可以从文件或数据中初始化该属性。
如果您想在外部应用程序中打开它,您可能需要查看UIActivityViewController
,以便用户可以选择在其中打开 PDF 的应用程序。
关于swift - 如何从我的 iPhone 应用程序快速查看 Adobe acrobat 中的 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45499146/