We're sorry GroupDocs doesn't work properply without JavaScript enabled.

Free Support Forum - groupdocs.com

Error while updating Viewer API from 19.6 to 20.8

I am using groupdocs in my application the version is 19.6

I updated the version to 20.8, groupdocs.annotations, groupdocs.signature works fine
now I updated viewer from 19.6 to 20.8, but I am facing lots of issues in my custom codes for ex

Viewer EX:

    public static DocumentInfoContainer GetDocumentInfoByFilePath(string filePath)
    {
        try
        {
            ViewerConfig config = Utilities.GetConfigurations();
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
            using (System.IO.FileStream fs = System.IO.File.OpenRead(filePath))
            {
                DocumentInfoOptions options = new DocumentInfoOptions();
                DocumentInfoContainer documentInfo = htmlHandler.GetDocumentInfo(fs, options);
                return documentInfo;
            }
        }
        catch (System.Exception exp)
        {
            Console.WriteLine(exp.Message);
        }
        return null;
    }


public static DocumentInfoContainer GetDocumentInfoByFileBytes(byte[] fileBytes)
{
    try
    {
        ViewerConfig config = Utilities.GetConfigurations();
        ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
        using (System.IO.MemoryStream stream = new MemoryStream(fileBytes))
        {
            DocumentInfoOptions options = new DocumentInfoOptions();
            DocumentInfoContainer documentInfo = htmlHandler.GetDocumentInfo(stream, options);
            return documentInfo;
        }
    }
    catch (System.Exception exp)
    {
        Console.WriteLine(exp.Message);
    }
    return null;
    }

now I know that config and handler api’s has been removed but I don’t know what should I use in the above scenarios as it is a custom code I cannot find anything in the example which I downloaded from github.


This Topic is created by Atir_Tahir using Email to Topic tool.

@Niteen_Jadhav

Can you please share a sample application so we could reproduce the same issue at or side?

Its not an issue, I just don’t understand what should I use Instead of config, helper classes in my new version

@Niteen_Jadhav

Please check this sample-app.zip (86.9 KB) where I’ve updated these two methods so they can be run with 20.8.

 private static ViewInfo GetDocumentInfoByFilePath(string fileName)
 {
     using (Viewer viewer = new Viewer(fileName))
     {
         ViewInfoOptions viewOptions = ViewInfoOptions.ForHtmlView();
         ViewInfo viewInfo = viewer.GetViewInfo(viewOptions);
 
         return viewInfo;
     }
 }

//

 private static ViewInfo GetDocumentInfoByFileBytes(byte[] fileBytes)
 {
     using (Viewer viewer = new Viewer(() => new MemoryStream(fileBytes)))
     {
         ViewInfoOptions viewOptions = ViewInfoOptions.ForHtmlView();
         ViewInfo viewInfo = viewer.GetViewInfo(viewOptions);
 
         return viewInfo;
     }
 }