public class

DocumentComparisonDialog

extends Object
java.lang.Object
   ↳ com.pspdfkit.document.processor.DocumentComparisonDialog

Class Overview

Dialog for visually comparing two versions of a document. This dialog offers a point selection wizard, that will guide users through the process of aligning two documents with each other, so that visual comparison can be performed. Show this dialog by calling show(FragmentActivity, PdfActivityConfiguration, ComparisonDocument, ComparisonDocument, File, ComparisonDialogListener). To make sure the dialog is restored properly across configuration changes, call restore(FragmentActivity, ComparisonDialogListener) within your activity's onCreate() method.


 class MyActivity : FragmentActivity(), ComparisonDialogListener {
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         if(savedInstanceState != null) {
             // If this activity is recreated after a configuration change, calling restore() ensures that the document will have the
             // correct callback (this activity) if it was shown before the configuration change. If no dialog was shown, this call is a
             // no-op.
             DocumentComparisonDialogImpl.restore(this, this)
         }
     }

     fun showComparisonDialog() {
        val outputFile = filesDir.resolve("comparison-result.pdf")
        val oldDocument = ComparisonDocument(oldDocumentSource, 0, Color.GREEN)
        val newDocument = ComparisonDocument(newDocumentSource, 0, Color.RED)
        DocumentComparisonDialog.show(this, configuration, oldDocument, newDocument, outputFile, this)
     }

     // ...
 }
 

Summary

Public Constructors
DocumentComparisonDialog()
Public Methods
static void restore(FragmentActivity fragmentActivity, ComparisonDialogListener listener)
Restores the document comparison dialog after a configuration change.
static void show(FragmentActivity fragmentActivity, PdfActivityConfiguration configuration, ComparisonDocument oldComparisonDocument, ComparisonDocument newComparisonDocument, File outputFile, ComparisonDialogListener listener)
Shows the document comparison dialog.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public DocumentComparisonDialog ()

Public Methods

public static void restore (FragmentActivity fragmentActivity, ComparisonDialogListener listener)

Restores the document comparison dialog after a configuration change. This method has to be called after recreating the hosting activity to reset the callback object. This should be called inside the activity's `onCreate()` method.


 class MyActivity : FragmentActivity(), ComparisonDialogListener {
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         if(savedInstanceState != null) {
             // If this activity is recreated after a configuration change, calling restore() ensures that the document will have the
             // correct callback (this activity) if it was shown before the configuration change. If no dialog was shown, this call is a
             // no-op.
             DocumentComparisonDialogImpl.restore(this, this)
         }
     }

     // ...
 }
 

Parameters
fragmentActivity Activity that hosts the document comparison dialog fragment.
listener ComparisonDialogListener to set on any visible comparison dialog.

public static void show (FragmentActivity fragmentActivity, PdfActivityConfiguration configuration, ComparisonDocument oldComparisonDocument, ComparisonDocument newComparisonDocument, File outputFile, ComparisonDialogListener listener)

Shows the document comparison dialog.

Parameters
fragmentActivity Activity to host the document comparison dialog fragment.
configuration PdfActivityConfiguration instance which defines the look and feel of the document comparison UI.
oldComparisonDocument ComparisonDocument representing the old document version used for comparison.
newComparisonDocument ComparisonDocument representing the new document version used for comparison.
outputFile Output File to which the comparison result will be written.
listener ComparisonDialogListener for reporting comparison success and errors.