Clear reference to PDFTron fragment on back

Product: native android sdk

Product Version: 9.3.1

Please give a brief summary of your issue:
Reference to previous created fragment or settings not clearing

Please describe your issue and provide steps to reproduce it:
When opening a PdfViewCtrlTabHostFragment2 by placing in a FrameLayout and then hitting the back button to go back, it seems to be holding references to some settings and when going back into the document some annotations aren’t rendering correctly afterwards

Please provide a link to a minimal sample where the issue is reproducible:

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi @seth.pacheco

We’re not sure if we’re understanding your issue. Could you elaborate on what you mean by holding references? Could you please provide a video and runnable sample project demonstrating the issue you are having?

Thanks,
Andrew.

Hey @ama,

When we open the document we then add the annotations from xfdf string. When we navigate away from the document going back to a files list and then go back into our fragment to view the file with annotations again, sometimes our annotations are not being displayed correctly even though we are merging the annotations to the document the same time.

I’m curious if there’s a reference being held in PDFTron somewhere to the originally opened document so there’s an error with the same annotation id?

Hopefully this helps

Hi @seth.pacheco ,

Unfortunately the description you gave is not enough for us to determine what issue you are having. Could you please provide a video and runnable sample project so we can better assist you?

Thanks,
Andrew.

Hi Seth,

In this case since you are merging XFDF individually, could you try calling:
pdfViewCtrl?.update(true) after merging? Note the boolean true in the parameters.

Could you give this a try and let us know if this resolves the issue?

Regards,
Branden

1 Like

This appears to work. However, when we exit the document, we get the following error:

E/PDFNet: Exception: 
    	 Message: Incremental save is not supported in admin-undo-own collaboration mode
    	 Conditional expression: !(flags & (SDFDoc::e_incremental_data_only | SDFDoc::e_incremental))
    	 Version      : 9.3.1-c6e5f486f8
    	 Platform     : Android
    	 Architecture : Arm
    	 Filename     : SDFDocImpl.cpp
    	 Function     : ConfirmIncremental
    	 Linenumber   : 964

Is there a way to get this error fixed? It does not seem to cause any problems, but it fills up the logcat.

Hi Jenny,

After reviewing the code in your sample project it looks like you are using fdfMerge, then you are not making use of our annotation manager, is there any reason why you need to enable the annotation manager?

If you remove this line that should resolve the error:
toolManager.enableAnnotManager(if (hasAnnotationPermission) userID else "-1")

Best Regards,
Eamon

We do this @emallon because we do not allow users to edit annotations they did not create. For example there can be a team of people all looking at a document but they can only edit/delete annotations they create and not of others on the team.

toolManager.enableAnnotManager(if (hasAnnotationPermission) userID else "-1")

This line up code :point_up: was the only way we could figure out how to disable the delete and edit option when another user tapped on an annotation that wasn’t theirs.

Is there a better way to go about this??

Hi Seth,

Based what you have said, what you are doing is fine, however you need to call setSavingEnabled(fasle) in onTabHostShown() and onTabChanged(p0: String?)
Please see sample code below:

            override fun onTabHostShown() {
                mPdfViewCtrlTabHostFragment?.currentPdfViewCtrlFragment?.setSavingEnabled(false)
            }

            override fun onTabChanged(p0: String?) {
                mPdfViewCtrlTabHostFragment?.currentPdfViewCtrlFragment?.setSavingEnabled(false)

                handleTabChanged(p0)
            }

Please let us know if this resolves your issue.

Best Regards,
Eamon