Compare files with overlay

Apryse SDK allows you to compare files visually using overlays.

Overlay PDFs to find differences in Xamarin.Android

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

Standalone activity

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

Apryse Docs Image
  1. Define the activity

Storage Permission

Please follow the latest Android best practices and guidelines outlined here

XML

1<activity android:name="com.pdftron.pdf.controls.DiffActivity" android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize" android:theme="@style/PDFTronAppTheme" android:windowSoftInputMode="adjustPan" />
  1. Show the activity

C#

1DiffActivity.Open(this);

Comparison 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.

Apryse Docs Image

C#

1public void Show(Context context, FragmentManager fragmentManager, List<Android.Net.Uri> files)
2{
3 var fragment = pdftron.PDF.Dialog.Diffing.DiffOptionsDialogFragment.NewInstance(
4 files[0], files[1]
5 );
6 fragment.SetStyle((int)DialogFragmentStyle.Normal, Resource.Style.PDFTronAppTheme);
7 fragment.DiffOptionsConfirmed += (sender, e) =>
8 {
9 CompareFiles(context, files, e.Color1, e.Color2, e.BlendMode);
10 };
11 fragment.Show(fragmentManager, "diff_options_dialog");
12}

where compareFile is:

C#

1private void CompareFiles(Context context, List<Android.Net.Uri> files, int color1, int color2, int blendMode)
2{
3 Android.Net.Uri uri = pdftron.PDF.Dialog.Diffing.DiffUtils.CompareFilesImpl(context, files, color1, color2, blendMode);
4 // do something with the output
5}

AsyncTask pattern can be used instead of Disposable pattern if desired.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales