【问题标题】:how can i let a user pick a local document?如何让用户选择本地文档?
【发布时间】:2021-03-11 10:45:25
【问题描述】:

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

【问题讨论】:

    标签: swift


    【解决方案1】:

    您可以使用PDFViewController 在 PSPDFKit 中显示 PDF 文档,如下所示:

    // 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)
    

    更多详情,请看以下guide here

    此外,要呈现最终用户选择的文档,请考虑使用文档选择器或文件浏览器。可运行的示例项目请参考DocumentPickerSidebarExample.swiftCatalogSwiftUI Document Browser

    以后,请通过 pspdfkit.com/support/request/ 访问我们的支持门户 - 我们很乐意为我们的商业 SDK 提供支持。

    【讨论】:

      猜你喜欢
      • 2018-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-07
      • 1970-01-01
      相关资源
      最近更新 更多