Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

enter image description here

Thanks in advance

like image 829
Bhargavi Avatar asked Jul 06 '17 09:07

Bhargavi


People also ask

Can you mark up PDFs on Iphone?

Tap the Camera button or the Document button , then look for the photo or PDF that you want to attach and mark up. Tap the attachment, then tap the gray arrow icon . Tap the Markup button to add your markup. Tap the plus button to add a signature, text, and more.

How do I remove markups from a PDF on my Iphone?

Change or delete markupOpen the PDF, then tap the Markup icon. Tap any markup to select it. A set of tools and commands also appears, with options including Copy and Delete.

How do I remove markups from a PDF on my IPAD?

Delete annotations Delete a single annotation: If you're annotating the document, tap the eraser tool, then tap the annotation. Otherwise, tap the annotation, then tap Delete. , then tap Erase All Smart Annotations.


1 Answers

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". Screenshot InstantMarkup0

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. Opened QLPreviewController from UIActivityViewController Opened QLPreviewController from UIActivityViewController. Instant Markup mode.

like image 156
Alexander Avatar answered Oct 22 '22 19:10

Alexander