|
2 | 2 | title: Clean Resources After Page Previews |
3 | 3 | linktitle: Clean Resources After Page Previews |
4 | 4 | second_title: GroupDocs.Comparison .NET API |
5 | | -description: |
| 5 | +description: Learn how to compare documents using GroupDocs.Comparison for .NET step by step. Enhance your .NET applications with efficient document management. |
6 | 6 | type: docs |
7 | 7 | weight: 13 |
8 | 8 | url: /net/document-comparison/clean-resources-after-page-previews/ |
9 | 9 | --- |
| 10 | +## Introduction |
| 11 | +In the world of .NET development, managing and comparing documents efficiently is essential for various applications, from legal firms to educational institutions. Fortunately, with tools like GroupDocs.Comparison for .NET, developers can streamline the process of comparing documents with ease. In this tutorial, we'll explore how to utilize GroupDocs.Comparison for .NET to compare documents step by step. |
| 12 | +## Prerequisites |
| 13 | +Before diving into the tutorial, make sure you have the following prerequisites in place: |
| 14 | +1. GroupDocs.Comparison for .NET: Download and install the library from [here](https://releases.groupdocs.com/comparison/net/). |
| 15 | +2. .NET Development Environment: Ensure you have a working .NET development environment set up on your machine. |
| 16 | +3. Document Samples: Prepare the source and target documents you want to compare. |
| 17 | + |
| 18 | +## Import Namespaces |
| 19 | +In your .NET project, begin by importing the necessary namespaces to access the functionalities of GroupDocs.Comparison for .NET. |
10 | 20 |
|
11 | | -## Complete Source Code |
12 | 21 | ```csharp |
13 | 22 | using System; |
14 | 23 | using System.IO; |
| 24 | +``` |
15 | 25 |
|
16 | | -namespace GroupDocs.Comparison.Examples.CSharp.AdvancedUsage |
| 26 | +## Step 1: Define Output Directory and File Name |
| 27 | +```csharp |
| 28 | +string outputDirectory = "Your Document Directory"; |
| 29 | +string outputFileName = Path.Combine(outputDirectory, "RESULT.pptx"); |
| 30 | +``` |
| 31 | +## Step 2: Initialize Comparer and Add Documents |
| 32 | +```csharp |
| 33 | +using (Comparer comparer = new Comparer("SOURCE.pptx")) |
17 | 34 | { |
18 | | - using GroupDocs.Comparison; |
19 | | - using GroupDocs.Comparison.Options; |
20 | | - |
21 | | - /// <summary> |
22 | | - /// This example demonstrates how to get document previews with user memory clean code |
23 | | - /// </summary> |
24 | | - class GetPagePreviewsResouresCleaning |
| 35 | + comparer.Add("TARGET.pptx"); |
| 36 | +``` |
| 37 | +## Step 3: Perform Comparison and Generate Output |
| 38 | +```csharp |
| 39 | + comparer.Compare(File.Create(outputFileName)); |
| 40 | +``` |
| 41 | +## Step 4: Generate Document Previews |
| 42 | +```csharp |
| 43 | + Document document = new Document(File.OpenRead(outputFileName)); |
| 44 | + PreviewOptions previewOptions = new PreviewOptions(pageNumber => |
25 | 45 | { |
26 | | - /// <summary> |
27 | | - /// User example code for releasing image stream memory |
28 | | - /// </summary> |
29 | | - /// <param name="pageNumber"></param> |
30 | | - /// <param name="stream"></param> |
31 | | - private static void UserReleaseStreamMethod(int pageNumber, Stream stream) |
32 | | - { |
33 | | - Console.WriteLine($"Releasing memory for page: {pageNumber}"); |
34 | | - stream.Close(); |
35 | | - } |
36 | | - |
37 | | - public static void Run() |
38 | | - { |
39 | | - Console.WriteLine("\n--------------------------------------------------------------------------------------------------------------------"); |
40 | | - Console.WriteLine("[Example Advanced Usage] # GetPagePreviewsResouresCleaning : how to get document previews with user memory clean code\n"); |
41 | | - |
42 | | - string outputDirectory = "Your Document Directory"; |
43 | | - string outputFileName = Path.Combine(outputDirectory, "RESULT.pptx"); |
44 | | - |
45 | | - using (Comparer comparer = new Comparer("SOURCE.pptx")) |
46 | | - { |
47 | | - comparer.Add("TARGET.pptx"); |
48 | | - comparer.Compare(File.Create(outputFileName)); |
49 | | - Document document = new Document(File.OpenRead(outputFileName)); |
50 | | - PreviewOptions previewOptions = new PreviewOptions(pageNumber => |
51 | | - { |
52 | | - var pagePath = Path.Combine(Constants.SamplesPath, $"result_{pageNumber}.png"); |
53 | | - return File.Create(pagePath); |
54 | | - }); |
55 | | - previewOptions.PreviewFormat = PreviewFormats.PNG; |
56 | | - previewOptions.PageNumbers = new int[] { 1, 2 }; |
57 | | - previewOptions.ReleasePageStream = UserReleaseStreamMethod; |
58 | | - document.GeneratePreview(previewOptions); |
59 | | - } |
60 | | - Console.WriteLine($"\nDocument previews generated successfully.\nCheck output in {outputDirectory}."); |
61 | | - } |
62 | | - } |
| 46 | + var pagePath = Path.Combine(Constants.SamplesPath, $"result_{pageNumber}.png"); |
| 47 | + return File.Create(pagePath); |
| 48 | + }); |
| 49 | + previewOptions.PreviewFormat = PreviewFormats.PNG; |
| 50 | + previewOptions.PageNumbers = new int[] { 1, 2 }; |
| 51 | + previewOptions.ReleasePageStream = UserReleaseStreamMethod; |
| 52 | + document.GeneratePreview(previewOptions); |
63 | 53 | } |
64 | | - |
65 | 54 | ``` |
| 55 | +## Step 5: Display Success Message |
| 56 | +```csharp |
| 57 | +Console.WriteLine($"\nDocument previews generated successfully.\nCheck output in {outputDirectory}."); |
| 58 | +``` |
| 59 | + |
| 60 | +## Conclusion |
| 61 | +In conclusion, GroupDocs.Comparison for .NET provides a robust solution for comparing documents effortlessly within .NET applications. By following the steps outlined in this tutorial, developers can seamlessly integrate document comparison functionality into their projects, enhancing productivity and efficiency. |
| 62 | +## FAQ's |
| 63 | +### Is GroupDocs.Comparison for .NET compatible with different document formats? |
| 64 | +Yes, GroupDocs.Comparison for .NET supports a wide range of document formats, including DOCX, PPTX, XLSX, PDF, and more. |
| 65 | +### Can I customize the output format of compared documents? |
| 66 | +Absolutely, GroupDocs.Comparison for .NET offers flexibility in choosing the output format according to your requirements. |
| 67 | +### Is there a trial version available for testing purposes? |
| 68 | +Yes, you can explore the features of GroupDocs.Comparison for .NET with a free trial available [here](https://releases.groupdocs.com/). |
| 69 | +### How can I get support for any issues or queries related to GroupDocs.Comparison for .NET? |
| 70 | +You can seek assistance from the GroupDocs.Comparison community forum [here](https://forum.groupdocs.com/c/comparison/12). |
| 71 | +### Where can I purchase a license for GroupDocs.Comparison for .NET? |
| 72 | +You can purchase a license for GroupDocs.Comparison for .NET from [this link](https://purchase.groupdocs.com/buy). |
0 commit comments