Unable to set license of GroupDocs.Search

Hello, Do you have any update on this?

@Niteen_Jadhav

We have reviewed the examples you provided, and we were able to reproduce the issue on our end. We are currently working on possible solutions and will inform you as soon as we have results.

Thank you.

Hello, do we have any further updates?

@Niteen_Jadhav

This ticket is still being worked on.

I created a new project and implemented all the Groupdocs related API’s in that project, I want to highlight a particular text in viewer.

can you provide an API for that.(Version 20.8)

@Niteen_Jadhav

You can implement GroupDocs.Annotation for this purpose. Please explore how to add highlight annotation in a document.

But annotation is highlighting by point and I want to highlight it by searched text for e.g. I have a document of 100 pages and I want to highlighted a text (Mumbai). it should highlight based on text on all the pages

@Niteen_Jadhav

You can achieve this using GroupDocs.Search highlight search results feature. Please take a look at this GroupDocs.Search web application as well.

Highlighting not working with Png Viewer

my code below

string basePath = @"E:\Ibrahim\DocProDMSDevSoln\WebApp\TempFolder\Storage\Search";
string viewerCacheFolderPath = basePath + @"/Cache";
string indexFolder = basePath + @"/Index";
string documentsFolder = basePath;
string query = "Page";

// Creating an index in the specified folder
Index index = new Index(indexFolder);

// Indexing documents from the specified folder
index.Add(documentsFolder);

// Search in index
SearchResult result = index.Search(query);

//Utils.TraceResult(query, result);

// Generating HTML
FoundDocument foundDocument = result.GetFoundDocument(0);

string cachePath = Path.Combine(globalConfiguration.GetViewerConfiguration().GetFilesDirectory(), "Search", globalConfiguration.GetViewerConfiguration().GetCacheFolderName());

var htmlMode = "false";
var documentGuid = foundDocument.DocumentInfo.FilePath;
var fileFolderName = Path.GetFileName(documentGuid).Replace(".", "_");
string fileCacheSubFolder = Path.Combine(cachePath, fileFolderName);
IViewerCache cache = new FileViewerCache(cachePath, fileCacheSubFolder);
LoadDocumentEntity loadDocumentEntity;

if (htmlMode != "false")
{
    using (HtmlViewer htmlViewer = new HtmlViewer(documentGuid, cache, GetLoadOptions("")))
    {
        loadDocumentEntity = GetLoadDocumentEntity(true, documentGuid, fileCacheSubFolder, htmlViewer);
    }
}
else
{
    using (PngViewer pngViewer = new PngViewer(documentGuid, cache, GetLoadOptions("")))
    {
        loadDocumentEntity = GetLoadDocumentEntity(true, documentGuid, fileCacheSubFolder, pngViewer);
    }
}


IndexedFileInfo fileInfo = new IndexedFileInfo(viewerCacheFolderPath, foundDocument.DocumentInfo.FilePath);
HighlightService highlightService = new HighlightService(fileInfo, null);

// Highlighting in HTML
highlightService.Highlight(foundDocument, index.Dictionaries.Alphabet);

and from HighlightService highlightService = new HighlightService(fileInfo, null); code it is executing

using (var htmlViewer = new HtmlViewer(_fileInfo, _password))
{
    _pages = htmlViewer.GetPages();
    foreach (var page in _pages)
    {
        htmlViewer.CreateCacheForPage(page.Number);
    }
}

and this is only working for htmlViewer and not for pngViewer.

I am using png Viewer as well as html viewer and I want to highlight the text in Png Viewer as well as html viewer.

It will be a great help if I get a detailed solution.

Thank you.

@Niteen_Jadhav

Can you please share the source document and output that you get when rendering to PNG?

I am getting the error that no file found and the source file is Github

public void Highlight(FoundDocument foundDocument, Alphabet alphabet)
{
    foreach (var page in _pages)
    {
        var pageFilePath = _fileInfo.GetHtmlPageFilePath(page.Number);

        var text = File.ReadAllText(pageFilePath);

        var result = HtmlHighlighter.Handle(
            text,
            false,
            alphabet,
            foundDocument.Terms,
            foundDocument.TermSequences);

        // Inserting the highlighting style
        int index = result.IndexOf(Key);
        if (index > 0 && index + Key.Length < result.Length)
        {
            result = result.Insert(index + Key.Length, HighlightStyle);
        }

        File.WriteAllText(pageFilePath, result);
    }
}

this code → _fileInfo.GetHtmlPageFilePath(page.Number); expectes html page but I am working with bot html as well as png pages

@Niteen_Jadhav

The highlight feature provided by GroupDocs.Search is only supported for HTML. It is not supported for PNG.

Can you please share the sample code to convert png to html and html to png

@Niteen_Jadhav

The code is the same for the both conversions. In case you would like to use Viewer please check

For Conversion:

@Niteen_Jadhav

The root issue appears to be that Visual Studio attempts to optimize dependency versions by applying binding redirects, but this can be problematic when different GroupDocs products specify different versions of dependencies. In some cases, these version conflicts may be complex and require manual investigation and configuration.

In recent releases of GroupDocs.Total, we have mitigated such compatibility issues by delivering all GroupDocs products as a single GroupDocs.Total.dll, rather than separate NuGet packages as was done previously. Therefore, we recommend updating GroupDocs.Total to the latest version.

If upgrading immediately is not feasible, please refer to the attached file GROUPDOCS_TOTAL_PACKAGE_fixed.7z (4.2 KB). This package contains a project that has been configured to use a compatible set of dependencies and optimized binding redirects.

Here are the steps we took to resolve the compatibility issue you encountered:

  • Set AutoGenerateBindingRedirects in the .csproj file to false, since Visual Studio was generating incorrect binding redirects, requiring manual corrections.
  • Updated the Aspose.PDF dependency from version 19.9 to 19.10.
  • Updated the Aspose.Words dependency from version 19.9 to 20.1.
  • Modified the App.config file to include binding redirects with versions compatible with both explicit and implicit dependencies, correcting misinterpretations by Visual Studio’s automatic dependency resolution algorithms.

Please let us know if this solution resolves the issue or if you need further assistance.
Best regards.

Update: There are few problems I am facing with Groupdocs Search.

highlightService.Highlight(foundDocument, index.Dictionaries.Alphabet, true); this function is taking huge amount of time while highlighting the text in the document. and sometimes not even highlighting the text for e.g. sharing HTML file (181.0 KB) in which after searching for a word “Nulla” it is not getting highlighted

PDF (22.6 KB) while searching on this PDF when I search Page it is working fine but when I search Page 1 it is not highlighting anything.

Please Note: I using png Viewer in my current application and hence I am converting png files into html file for highlighting and after that I am converting these html files into png so that the user can view these files.

sharing my complete code for you

@Niteen_Jadhav

We have begun investigating this issue and will provide updates as soon as we have more information.

Update:

Thank you for your quick response, after debuging more I found that the issue is not coming on Version Groupdocs.total 20.8 but on my trial version Groupdocs.total 24.5 and the line is converter.Convert($"{tempFile}.png", options); not highlightService.Highlight(foundDocument, index.Dictionaries.Alphabet, true); actually I am using png viewer and I am converting the png file to html and highlighting the file and after that again converting the file into png file.

below is my complete api code

[HttpPost]
[Route("api/GroupDocsApi/HighlightTextInViewer")]
public async Task<SPResponse> HighlightTextInViewer(DocPro.DMS.BusinessEntities.Request.GroupDocs.GetDocumentInfoRequest request)
{
    Program p = new Program();
    var storagePath = p.GetStoragePath();
    string basePath = storagePath + "\\Search";
    if (!Directory.Exists(basePath))
    {
        Directory.CreateDirectory(basePath);
    }

    var fileGuidWithStoragePath = Path.Combine(storagePath, request.GUID);
    var fileGuidWithSearchPath = Path.Combine(basePath, request.GUID);
    if (System.IO.File.Exists(fileGuidWithSearchPath))
    {
        System.IO.File.Delete(fileGuidWithSearchPath);
    }
    File.Copy(fileGuidWithStoragePath, fileGuidWithSearchPath);

    string viewerCacheFolderPath = basePath + @"\Cache";
    string indexFolder = basePath + @"\Index";
    string documentsFolder = basePath;
    string query = request.TextData;

    // Creating an index in the specified folder
    Index index = new Index(indexFolder);

    // Indexing documents from the specified folder
    index.Add(documentsFolder);

    // Search in index
    GroupDocs.Search.Options.SearchOptions searchOptions = new GroupDocs.Search.Options.SearchOptions();
    searchOptions.UseCaseSensitiveSearch = false; // Adjust based on your requirement
    SearchResult result = index.Search(query, searchOptions);

    //Utils.TraceResult(query, result);

    // Generating HTML
    FoundDocument foundDocument = null;

    // Iterate through the found documents

    int documentCount = result.DocumentCount;
    if (documentCount == 0)
    {
        return new SPResponse() { ReturnStatus = "-1" };
    }
    for (int i = 0; i < documentCount; i++)
    {
        FoundDocument document = result.GetFoundDocument(i);
        if (document.DocumentInfo.FilePath.Equals(fileGuidWithSearchPath, StringComparison.OrdinalIgnoreCase))
        {
            foundDocument = document;
            break;
        }
    }


    var documentGuid = foundDocument.DocumentInfo.FilePath;
    var fileFolderName = Path.GetFileName(documentGuid).Replace(".", "_");

    string cachePath = Path.Combine(p.GetStoragePath(), "Search");
    cachePath = Path.Combine(cachePath, "Cache");
    //cachePath = Path.Combine(cachePath, fileFolderName);

    string fileCacheSubFolder = Path.Combine(cachePath, fileFolderName);
    IViewerCache cache = new FileViewerCache(cachePath, fileCacheSubFolder);
    LoadDocumentEntity loadDocumentEntity;

    using (HtmlViewer htmlViewer = new HtmlViewer(documentGuid, cache, GetLoadOptions("")))
    {
        loadDocumentEntity = GetLoadDocumentEntity(true, documentGuid, fileCacheSubFolder, htmlViewer, viewerCacheFolderPath);
    }

    IndexedFileInfo fileInfo = new IndexedFileInfo(viewerCacheFolderPath, foundDocument.DocumentInfo.FilePath);
    HighlightService highlightService = new HighlightService(fileInfo, null, cache);

    // Highlighting in HTML
    highlightService.Highlight(foundDocument, index.Dictionaries.Alphabet, true);

    if (!request.IsHtmlMode)
    {
        var pagesBuilder = await GD.Utilities.GetDocumentInfoByFilePathAsync(fileGuidWithSearchPath);
        var pages = pagesBuilder.ToString();
        var noOfPages = pages.Split(',').Last();
        var tempFilesPath = Path.Combine(cachePath, fileFolderName);

        for (int i = 1; i <= int.Parse(noOfPages); i++)
        {
            var tempFile = Path.Combine(tempFilesPath, $"p{i}");
            using (var converter = new Converter($"{tempFile}.html"))
            {
                try
                {
                    var options = new ImageConvertOptions { Format = GroupDocs.Conversion.FileTypes.ImageFileType.Png };
                    converter.Convert($"{tempFile}.png", options);
                    File.Delete($"{tempFile}.html");
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
        }
    }
    File.Delete(fileGuidWithSearchPath);
    return new SPResponse() { ReturnStatus = "0" };
}

Error I am getting

Method ‘GetBarcodeImage’ in type ‘’ from assembly ‘GroupDocs.Total, Version=24.5.0.0,
Culture=neutral, PublicKeyToken=716fcc553a201e56’ does not have an implementation.

@Niteen_Jadhav
Thanks for reporting the issue, we are investigating it now