Some test text!

menu
Overlay comparisonkeyboard_arrow_down

Compare files with overlay

PDFTron SDK allows you to compare files visually using overlays.

File comparison

This tutorial only applies to Xamarin.Android. See Xamarin.iOS equivalent here.

You can visually compare pages. This resolution independent comparison allows you to quickly spot differences between pages.

There are two main ways to integrate the out-of-box UI components in your application:

  1. standalone activity
  2. comparison options dialog.

linkStandalone activity

The DiffActivity is a standalone component that handles from picking two files to generating the comparison result.

diff-activity
  1. Define the activity
android.permission.WRITE_EXTERNAL_STORAGE permission is required.
<activity
    android:name="com.pdftron.pdf.controls.DiffActivity"
    android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize"
    android:theme="@style/CustomAppTheme"
    android:windowSoftInputMode="adjustPan" />
  1. Show the activity
DiffActivity.Open(this);

linkComparison options dialog

If you have your own viewer already and only want to show the comparison options in your application, the DiffOptionsDialogFragment can be used.

diff-frag
public void Show(Context context, Android.Support.V4.App.FragmentManager fragmentManager, List<Android.Net.Uri> files)
{
    var fragment = pdftron.PDF.Dialog.Diffing.DiffOptionsDialogFragment.NewInstance(
        files[0], files[1]
    );
    fragment.SetStyle((int)DialogFragmentStyle.Normal, Resource.Style.CustomAppTheme);
    fragment.DiffOptionsConfirmed += (sender, e) =>
    {
        CompareFiles(context, files, e.Color1, e.Color2, e.BlendMode);
    };
    fragment.Show(fragmentManager, "diff_options_dialog");
}

where compareFile is:

private void CompareFiles(Context context, List<Android.Net.Uri> files, int color1, int color2, int blendMode)
{
    Android.Net.Uri uri = pdftron.PDF.Dialog.Diffing.DiffUtils.CompareFilesImpl(context, files, color1, color2, blendMode);
    // do something with the output
}
AsyncTask pattern can be used instead of Disposable pattern if desired.

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.