> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/xamarin/guides/viewer-components/file-comparison-a.md).

# File comparison in Xamarin

Learn how to visually compare pages in Xamarin.Android using standalone activity or comparison options dialog. Follow Android best practices for integration. The Apryse Xamarin SDK streamlines secure,

{% hint style="info" %}
**This tutorial only applies to Xamarin.Android. See Xamarin.iOS equivalent here .**
{% endhint %}

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](https://docs.apryse.com)
2. [Comparison options dialog](https://docs.apryse.com)

## Standalone activity

The [`DiffActivity`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Controls.DiffActivity.html) is a standalone component that handles from picking two files to generating the comparison result.

![](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-e0acc50b089b60d7a62919105114359fe5e7bbca%2F7e258cf5d39bf775c65ebdd01bd29a526bc05e25-600x1200.gif?alt=media)

1. Define the activity

{% hint style="warning" %}
\*\* Storage Permission \*\*

Please follow the latest Android best practices and guidelines outlined [here](https://developer.android.com/training/permissions/usage-notes/)
{% endhint %}

{% tabs %}
{% tab title="XML" %}
{% code lineNumbers="true" %}

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

{% endcode %}
{% endtab %}
{% endtabs %}

1. Show the activity

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
DiffActivity.Open(this);
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Comparison options dialog

If you have your own viewer already and only want to show the comparison options in your application, the [`DiffOptionsDialogFragment`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Dialog.Diffing.DiffOptionsDialogFragment.html) can be used.

![](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-dc20edcc3628942825e60d063a74ca64b7dbae9a%2F4bd7edf8d37e524b03207910636127cb026257fe-368x730.gif?alt=media)

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
public void Show(Context context, 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.PDFTronAppTheme);
    fragment.DiffOptionsConfirmed += (sender, e) =>
    {
        CompareFiles(context, files, e.Color1, e.Color2, e.BlendMode);
    };
    fragment.Show(fragmentManager, "diff_options_dialog");
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

where `compareFile` is:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
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
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/xamarin/guides/viewer-components/file-comparison-a.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
