首页 > 解决方案 > 如何让用户选择本地文档?

问题描述

我应该以允许用户打开本地保存的 pdf 文件的方式测试 PSPDFKit。为此,我需要文件 url(例如路径,我猜)。如何让用户选择本地文档?有人可以帮帮我吗?我正在使用故事板和swift。

标签: swift

解决方案


您可以使用类似的方法在 PSPDFKit 中呈现 PDF 文档PDFViewController

// Create the `Document`.
let fileURL = Bundle.main.url(forResource: "Document", withExtension: "pdf")!
let document = Document(url: fileURL)

// Create the PDF view controller.
let pdfController = PDFViewController(document: document)

// Present the PDF view controller within a `UINavigationController` to enable the toolbar.
present(UINavigationController(rootViewController: pdfController), animated: true)

有关更多详细信息,请在此处查看以下指南

此外,要呈现最终用户选择的文档,请考虑使用文档选择器或文件浏览器。有关可运行的示例项目,请参阅CatalogSwiftUI 文档浏览器中的DocumentPickerSidebarExample.swift 。

将来,请通过 pspdfkit.com/support/request/ 联系我们的支持门户 - 我们很高兴在那里为我们的商业 SDK 提供支持。


推荐阅读