usmanazizgroupdocs
4/21/2017 - 9:09 AM

RenderDocumentAsHtmlWithEnablePreciseRendering.cs

// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET
//Get Configurations
ViewerConfig config = Utilities.GetConfigurations();

// Create html handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);

// Guid implies that unique document name 
string guid = DocumentName;

//Instantiate the HtmlOptions object
HtmlOptions options = new HtmlOptions();

//to get html representations of pages with embedded resources
options.IsResourcesEmbedded = true;

// Set password if document is password protected. 
if (!String.IsNullOrEmpty(DocumentPassword))
    options.Password = DocumentPassword;

// Set pdf options to render content in precise mode
options.PdfOptions.EnablePreciseRendering = true; // Default value is false

//Get document pages in html form
List<PageHtml> pages = htmlHandler.GetPages(guid, options);

foreach (PageHtml page in pages)
{
    //Save each page at disk
    Utilities.SaveAsHtml(page.PageNumber + "_" + DocumentName, page.HtmlContent);
}