简体   繁体   中英

how to open pdf markup programmatically in ios 11

the Markup as pdf is a new options in share sheet in iOS 11, i would to give a button for that action in my UI so that when the user clicks that button the pdf markup view(refer the pic below) shows up.

在此输入图像描述

Thanks in advance

I've been trying to find out a solution for several hours. I presented UIDocumentInteractionController, SFSafariViewController, UIActivityViewController, QLPreviewController.

And for now, there is NO WAY to call Instant Markup programmatically.

The only near solution is to present UIActivityViewController with UIActivityType.markupAsPDF ( Documentation link )

func showMenu()
{
    if let pdfUrl = Bundle.main.url(forResource: "Martin", withExtension: "pdf") {
        let activityController = UIActivityViewController(activityItems: [pdfUrl], applicationActivities:nil)
        ctra.excludedActivityTypes = [
            UIActivityType.postToFacebook,
            UIActivityType.postToTwitter,
            UIActivityType.postToWeibo,
            UIActivityType.message,
            UIActivityType.mail,
            UIActivityType.copyToPasteboard,
            UIActivityType.assignToContact,
            UIActivityType.saveToCameraRoll,
            UIActivityType.addToReadingList,
            UIActivityType.postToFlickr,
            UIActivityType.postToVimeo,
            UIActivityType.postToTencentWeibo,
            UIActivityType.airDrop,
            UIActivityType.openInIBooks,
    ]
    // These activity types shouldn't be excluded
    // UIActivityType.print,
    // UIActivityType.markupAsPDF

    self.present(activityController, animated: true, completion: nil)
    }
}

In the bottom line of extension apps, you will see "Create PDF". 截图InstantMarkup0

PS

As you can see following screenshots, Apple uses QLPreviewController. I've tried to present QLPreviewController, but it shows without Instant Markup button. It could be that Apple will provide us the required API later, but I have doubts about it. 从UIActivityViewController打开QLPreviewController 从UIActivityViewController打开QLPreviewController。即时标记模式。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM