ios - 如何使用 pspdfkit 将 pdf 文件共享到电子邮件?

标签 ios swift

我想将已签名的 pdf 发送到其他人的电子邮件中。我该怎么办?

我的代码:

@objc func handleUploadPDF() {
    let fileURL = Bundle.main.bundleURL.appendingPathComponent("Exhibit-A-SAMPLE-CONTRACT.pdf")
    let writableURL = copyFileURLToDocumentFolder(fileURL)
    let document = PSPDFDocument(url: fileURL)
    let configuration = PSPDFConfiguration { builder in
        builder.thumbnailBarMode = .scrollable
    }

    let pdfController = PDFViewController(document: document, configuration: configuration)
    present(UINavigationController(rootViewController: pdfController), animated: true, completion:nil)

}

最佳答案

确保在 pdfViewController 的导航项的右栏按钮项数组中包含 emailButtonItem,如下所示:

@objc func handleUploadPDF() {
    let fileURL = Bundle.main.bundleURL.appendingPathComponent("Exhibit-A-SAMPLE-CONTRACT.pdf")
    let writableURL = copyFileURLToDocumentFolder(fileURL)
    let document = PSPDFDocument(url: fileURL)
    let configuration = PSPDFConfiguration { builder in
        builder.thumbnailBarMode = .scrollable
    }

    let pdfController = PDFViewController(document: document, configuration: configuration)
    pdfController.navigationItem.setRightBarButtonItems([pdfController.emailButtonItem], animated: false)
    present(UINavigationController(rootViewController: pdfController), animated: true, completion:nil)

}

enter image description here

有关如何自定义工具栏的更多详细信息,请查看https://pspdfkit.com/guides/ios/current/customizing-the-interface/customizing-the-toolbar/

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

关于ios - 如何使用 pspdfkit 将 pdf 文件共享到电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57177302/

相关文章:

ios - 带进度条的简单 URLSession uploadTask

objective-c - iOS 相机 UIView 在 iPad 上覆盖全屏?

iOS : Audio is missing in exported video

ios - 从 UITableViewCell : addChildViewController unrecognized selector sent to instance 呈现 UIViewController

iphone - 使用铃声作为 iOS 的自定义推送通知声音

swift - 在闭包中解构元组的元组

ios - 网址中的西里尔符号

swift - 如何以编程方式在 UINavigationController 的 leftbarbuttonitem 中显示 UISearchController 并在搜索后隐藏它?

ios - 如何为 iOS 9 设置 audioSession 类别?

ios - Swift 闭包作为字典中的值