Package com.pspdfkit.document.processor
Class DocumentComparisonDialog
-
- All Implemented Interfaces:
public class DocumentComparisonDialog
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. To make sure the dialog is restored properly across configuration changes, call restore 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) } // ... }
-
-
Constructor Summary
Constructors Constructor Description DocumentComparisonDialog()
-
Method Summary
Modifier and Type Method Description static void
show(@NonNull() FragmentActivity fragmentActivity, @NonNull() PdfActivityConfiguration configuration, @NonNull() ComparisonDocument oldComparisonDocument, @NonNull() ComparisonDocument newComparisonDocument, @NonNull() File outputFile, @NonNull() ComparisonDialogListener listener)
Shows the document comparison dialog. static void
restore(@NonNull() FragmentActivity fragmentActivity, @NonNull() ComparisonDialogListener listener)
Restores the document comparison dialog after a configuration change. -
-
Method Detail
-
show
static void show(@NonNull() FragmentActivity fragmentActivity, @NonNull() PdfActivityConfiguration configuration, @NonNull() ComparisonDocument oldComparisonDocument, @NonNull() ComparisonDocument newComparisonDocument, @NonNull() File outputFile, @NonNull() 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.
-
restore
static void restore(@NonNull() FragmentActivity fragmentActivity, @NonNull() ComparisonDialogListener listener)
Restores the document comparison dialog after a configuration change. This method has to be called after recreating the hosting
activity
to reset thecallback
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.
-
-
-
-