> 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/uwp/get-started/samples/visualcomparisontest.md).

# VisualComparisonTest

Sample C# code for using Apryse SDK to overlay two PDF files allowing for a visual color difference between them. This is commonly used to see changes between two document revisions or in drawing blue

Sample C# code for using Apryse SDK to overlay two PDF files allowing for a visual color difference between them. This is commonly used to see changes between two document revisions or in drawing blueprints that are overlayed with updated data.

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

```csharp
//
// Copyright (c) 2001-2020 by PDFTron Systems Inc. All Rights Reserved.
//

using System;
using System.IO;
using System.Threading.Tasks;
using Windows.Foundation;

using pdftron.PDF;
using pdftron.SDF;

using PDFNetUniversalSamples.ViewModels;

namespace PDFNetSamples
{
    public sealed class VisualComparisionTest : Sample
    {
        public VisualComparisionTest() :
            base("VisualComparision", "PDFNet can generate a visual comparison between two different documents. The comparison result itself is a resolution independent PDF -- well suited for adding high-quality diff support into existing app workflows.")
        {
        }

        public override IAsyncAction RunAsync()
        {
            return Task.Run(new System.Action(async () => {
                WriteLine("--------------------------------");
                WriteLine("Starting Visual Comparision Test...");
                WriteLine("--------------------------------\n");

                bool error = await DiffingTestAsync();

                if (error)
                {
                    WriteLine("Visual Comparision failed");
                }
                else
                {
                    WriteLine("Visual Comparision succeeded");
                }

                WriteLine("\n--------------------------------");
                WriteLine("Done Visual Comparision Test.");
                WriteLine("--------------------------------\n");
            })).AsAsyncAction();
        }

        private async Task<bool> DiffingTestAsync()
        {
            bool error = false;

            string firstDocumentPath = Path.Combine(InputPath, "diff_doc_1.pdf");
            string secondDocumentPath = Path.Combine(InputPath, "diff_doc_2.pdf");
            string outputDocumentPath = Path.Combine(OutputPath, "VisualComparision.pdf");

            if ((!File.Exists(firstDocumentPath)) || (!File.Exists(secondDocumentPath)))
            {
                WriteLine("Atleast one input file does not exist. Aborting.");
                error = true;
                return error;
            }

            try
            {
				using (PDFDoc firstDocument = new PDFDoc(firstDocumentPath))
				using (PDFDoc secondDocument = new PDFDoc(secondDocumentPath))
				{
					Page firstDocumentPage = firstDocument.GetPage(1);
					Page secondDocumentPage = secondDocument.GetPage(1);

					DiffOptions diffOptions = new DiffOptions();
					diffOptions.SetColorA(new ColorPt(1, 0, 0));
					diffOptions.SetColorB(new ColorPt(0, 0, 0));
					diffOptions.SetBlendMode(GStateBlendMode.e_bl_normal);

					PDFDoc outputDocument = new PDFDoc();
					outputDocument.AppendVisualDiff(firstDocumentPage, secondDocumentPage, diffOptions);
					await outputDocument.SaveAsync(outputDocumentPath, SDFDocSaveOptions.e_linearized);
                    await AddFileToOutputList(outputDocumentPath).ConfigureAwait(false);
                }
            }
            catch (Exception e)
            {
                WriteLine(GetExceptionMessage(e));
                error = true;
            }

            return error;
        }
    }
}
```

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


---

# 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/uwp/get-started/samples/visualcomparisontest.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.
