Help with "Share" option when comparing 2 docs

20 views
Skip to first unread message

Randy Haid

unread,
Mar 29, 2021, 9:48:59 PM3/29/21
to PDFTron SDK
Hi!

I'm using v8.1.2 of the iOS SDK and running into a problem that I just can't seem to figure out...

What I did:
1. Rolled a totally new project,
2. Added PDFTron via SPM
3. I initialize with my PDFTron key in the appdelegate
4. Added a button to the view controller that Xcode gave me with the new project and hooked it up to call my test method....

    @IBAction func compareButtonPressed(_ sender: UIButton)
    {
        let doc1 = PTPDFDoc(filepath: Bundle.main.url(forResource: "pdfDoc1", withExtension: "pdf")?.path)!
        let doc2 = PTPDFDoc(filepath: Bundle.main.url(forResource: "pdfDoc2", withExtension: "pdf")?.path)!
        let compareDoc = self.pdfCompareDoc(docA: doc1, docB: doc2, colorA: PTColorDefaults.colorPt(from: UIColor.blue), colorB: PTColorDefaults.colorPt(from: UIColor.red), blendMode: e_ptbl_darken)
        
        let documentController = PTDocumentController()
        let navigationController = UINavigationController(rootViewController: documentController)
        documentController.openDocument(with: compareDoc)
        self.present(navigationController, animated: true, completion: nil)
    }

Now that DOES do the compare and presents the expected UI.  So far this is all good.

The problem I'm running into is when I tap on the "..." in the upper right (the "more" button), and then select the "Share" menu options, nothing happens.  The menu simply disappears.

It's bizarre too, because the "Share" menu option works if all I do is open one of the docs.  it's only when I present it like above for comparing two docs.

Any help is greatly appreciated, thanks!

Randy Haid

unread,
Mar 29, 2021, 9:52:19 PM3/29/21
to PDFTron SDK
Apologies, I left out the other method that I copied verbatim from the docs:

    func pdfCompareDoc(docA: PTPDFDoc, docB: PTPDFDoc, colorA: PTColorPt, colorB: PTColorPt, blendMode: PTBlendMode) -> PTPDFDoc
    {
        let pageA = docA.getPage(1)
        let pageB = docB.getPage(1)

        let diffOptions:PTDiffOptions = PTDiffOptions()
        diffOptions.setColorA(colorA)
        diffOptions.setColorB(colorB)
        diffOptions.setBlendMode(blendMode)

        let doc:PTPDFDoc = PTPDFDoc()
        doc.appendVisualDiff(pageA, p2: pageB, opts: diffOptions)
        return doc
    }

Randy Haid

unread,
Mar 29, 2021, 10:14:59 PM3/29/21
to PDFTron SDK
I'm kind of wondering if it's something along the lines of "that compare doc doesn't have a file name"....

That popped into my head because I'm now looking at the next ticket in my backlog where files that are shared basically have the incorrect name. i.e. The file DOES get shared, but it's emailed with a really ugly file name with no PDF extension.  I'm opening files stored at AWS links, and I've noticed that PDFTron SDK appears to be grabbing the tail end of my URL and using that as the file name.  Those URLs have really long, nonsense components, so I see "file names" like "iusej$%aerljs2233zous" or whatever with no "pdf" extension.

So I'm wondering if showing me how to simply tell the SDK "hey, this file I just gave you, please call it this...", might get two birds with one stone?

David

unread,
Mar 31, 2021, 7:15:12 PM3/31/21
to PDFTron SDK
Hello,

When opening an in-memory PDFDoc in a PTDocumentController, it is currently not possible to share the document. However, if you save the document to disk and then open the document using its file URL, then sharing should work as expected.

Is saving the document to disk possible in your use case? We can also investigate the issue of sharing a "raw" PDFDoc from the PTDocumentController class.

You also mentioned that you are opening documents stored at AWS links - how are these documents being downloaded (HTTP(s) URLs passed to a PTDocumentController, or downloaded manually, etc.)?

Randy Haid

unread,
Mar 31, 2021, 7:55:18 PM3/31/21
to PDFTron SDK
Hi, thanks for the quick response!

Saving the document to disk might be an option.  I will explore that and see if I can make it work.

For the AWS download, yes, I'm just passing the URL directly into PTDocumentController's openDocument method.  I did at one point try to "cache" the documents on disk so that it would be faster, but I ran into various display issues when loading from disk rather than from the URL.  I don't remember what those issues were at the moment, but they were definitely odd things.  I *think* one issue was the top toolbar area that has the dropdown for selecting your mode, would not appear at first; you had to tap on the doc once to make it "full screen" and then tap again to leave "full screen" in order to make that toolbar appear again.

Reply all
Reply to author
Forward
0 new messages