Reputation: 515
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
Upvotes: 14
Views: 1859
Reputation: 1288
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".
P.S.
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.
Upvotes: 2