How to migrate to GroupDocs.Viewer 19.8 or higher
Leave feedback
This page describes migration to the 19.8 version or later from the previous one.
Why to migrate
The main reasons to use the 19.8 version or later are as follows:
The Viewer class is a single entry point to manage the document rendering process to any supported file format instead of the ViewerHtmlHander/ViewerImageHander classes from previous versions.
The rendering speed improved significantly by saving the rendered page as it is rendered, not when all pages are rendered.
Product architecture is redesigned from scratch to decrease memory usage from 10% to 400% depending on the document type.
Document rendering options are simplified, so you can easily instantiate the proper option class and control document rendering and saving processes.
How to migrate
Here is a brief comparison of how to display a document in HTML form using old and new versions.
The following code snippet shows the old coding style:
//Get ConfigurationsViewerConfigconfig=Utilities.GetConfigurations();// Create html handlerViewerHtmlHandlerhtmlHandler=newViewerHtmlHandler(config);// Guid implies that unique document name stringguid="sample.docx";//Instantiate the HtmlOptions objectHtmlOptionsoptions=newHtmlOptions();//to get html representations of pages with embedded resourcesoptions.IsResourcesEmbedded=true;// Set password if document is password protected. if(!String.IsNullOrEmpty(DocumentPassword))options.Password=DocumentPassword;//Get document pages in html formList<PageHtml>pages=htmlHandler.GetPages(guid,options);foreach(PageHtmlpageinpages){//Save each page at diskUtilities.SaveAsHtml(page.PageNumber+"_"+DocumentName,page.HtmlContent);}
'Get Configurations
DimconfigAsViewerConfig=Utilities.GetConfigurations()' Create html handler
DimhtmlHandlerAsViewerHtmlHandler=NewViewerHtmlHandler(config)' Guid implies that unique document name
DimguidAsString="sample.docx"'Instantiate the HtmlOptions object
DimoptionsAsHtmlOptions=NewHtmlOptions()'to get html representations of pages with embedded resources
options.IsResourcesEmbedded=True' Set password if document is password protected.
IfNot[String].IsNullOrEmpty(DocumentPassword)Thenoptions.Password=DocumentPassword'Get document pages in html form
DimpagesAsList(OfPageHtml)=htmlHandler.GetPages(guid,options)ForEachpageAsPageHtmlInpages'Save each page at disk
Utilities.SaveAsHtml(page.PageNumber.ToString()&"_"+DocumentName,page.HtmlContent)Next
The following code snippet shows the new coding style: