Steps to use license on existing project

We have a project which is developed by 2 Developers using .Net (Web Application). This application is used by 10 employees within our organization.

We have development, QA and Prod environment - which is hosted in our data centre in India. Dev and QA is hosted in Dev1 Server and Prod in Prod1 Server.

We have got licence “Words for .Net Developer Small
Business” ,Quantity : 2 we want to add it to our project .
Can you please guide us with steps to be followed and one license how we will be able to use at dev/Prod/QA environment and steps for that

@isha.r You should apply the license in your code using code like this:

Aspose.Words.License lic = new Aspose.Words.License();
lic.SetLicense(@"C:\Temp\Aspose.Words.NET.lic");

Please see our documentation to learn more about applying license:
https://docs.aspose.com/words/net/licensing/

You can keep the license file as a separate file or include it into your project as an embedded resource.
it is enough to apply license once per application domain, so you can apply the license on your application start event or in static constructor.

Thanks for the reply !
I tried applying the way you have mentioned but its not working ,still I am seeing watermark( Evaluation Only. Created with Aspose.Words. Copyright 2003-2023 Aspose Pty Ltd.) on my merged file.
Please help me understand if I am applying it in wrong place

in my startup.cs file i added below code:

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{

    app.UseEndpoints(endpoints =>
    {
        endpoints.MapControllerRoute(
            name: "default",
            pattern: "{controller=Home}/{action=Index}/{id?}");
    });

    SetAsposeLicense();
}
private void SetAsposeLicense()
{
    // Specify the path to your license file
    var licensePath = Path.Combine(_environment.ContentRootPath, "License", "Aspose.Words.NET.lic");
    //below is the original path where I have added license file in my project ,
    //var licensePath = @"C:\Users\35158\source\repos\WebApplication2_sp8\WebApplication2_sp8\License\Aspose.Words.NET.lic";  
    try
    {
        License license = new License();
        license.SetLicense(licensePath);
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Failed to set Aspose license: {ex.ToString()}");
    }
}

Method I am calling for merge functionality in controller is:

[HttpPost]
public IActionResult MergeComments(List<IFormFile> files)
{
    if (files.Count < 2)
    {
        ViewBag.Error = "Please upload at least two Word documents.";
        return View("Index");
    }

    try
    {
        var uploadsFolder = Path.Combine(_environment.WebRootPath, "uploads");
        Directory.CreateDirectory(uploadsFolder); // Create the "uploads" directory if it doesn't exist

        var documentPaths = new List<string>();

        // Save the uploaded files to the server and collect their paths
        foreach (var file in files)
        {
            var filePath = Path.Combine(uploadsFolder, file.FileName);

            using (var fileStream = new FileStream(filePath, FileMode.Create))
            {
                file.CopyTo(fileStream);
            }

            documentPaths.Add(filePath);
        }

        // Create copies of the original documents to perform merging and comparison
        var documentCopies = new List<Document>();

        foreach (var documentPath in documentPaths)
        {
            var doc = new Document(documentPath);
            var copyPath = Path.Combine(uploadsFolder, "copy_" + Path.GetFileName(documentPath));

            // Save a copy of the document
            doc.Save(copyPath);
            documentCopies.Add(new Document(copyPath));

            // Accept all revisions in the original document
            doc.AcceptAllRevisions();
        }

        // Merge comments from multiple documents
        Document mergedDocument = null;

        foreach (var doc in documentCopies)
        {
            if (mergedDocument == null)
            {
                mergedDocument = doc;
            }
            else
            {
                // Compare and merge the current document into the mergedDocument
                mergedDocument.AcceptAllRevisions();
                doc.AcceptAllRevisions();
                mergedDocument.Compare(doc, "test", DateTime.Now);
            }
        }

        // Get authors and text of the comments from the merged document
        var comments = new List<string>();
        foreach (Comment c in mergedDocument.GetChildNodes(NodeType.Comment, true))
        {
            comments.Add($"{c.Author}: {c.ToString(SaveFormat.Text).Trim()}");
        }

        // Save the merged document with comments
        var outputPath = Path.Combine(_environment.WebRootPath, "merged", "out.docx");
        mergedDocument.Save(outputPath);

        // Provide the merged document for download
        var mergedFileName = "MergedDocument.docx";
        return File(System.IO.File.ReadAllBytes(outputPath), "application/vnd.openxmlformats-officedocument.wordprocessingml.document", mergedFileName);
    }
    catch (Exception ex)
    {
        ViewBag.Error = $"An error occurred: {ex.Message}";
        return View("Index");
    }
}

@isha.r Please check the following points:

  • Make sure your call to SetLicense gets executed. Step through in the debugger.
  • Make sure your code does not catch an exception thrown by Aspose.Words licensing code. For example, Aspose.Words will throw if it cannot find the license.
  • Make sure the input documents do not already have the evaluation message. Aspose.Words does not delete existing evaluation messages.
  • Make sure SetLicense is executed before you instantiate any Document object.

If nothing from the above helps, please try applying license in the static constructor of the same class as MergeComments method belongs to.