Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Created August 16, 2019 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/f45159cf559053d41252a2069ec74425 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/f45159cf559053d41252a2069ec74425 to your computer and use it in GitHub Desktop.
// Set output directory for saving rendered pages
string pageFilePathFormat = Path.Combine("D:\\output", "page_{0}.html");
using (Viewer viewer = new Viewer("D:\\storage\\sample.docx"))
{
// Set options to get HTML with embedded resources
HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat);
// Render document
viewer.View(options);
}
ViewerConfig config = new ViewerConfig();
config.StoragePath = @"D:\\storage\\";
// Create HTML handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
// Guid implies that unique document name
string guid = "sample.docx";
// Instantiate the HtmlOptions object
HtmlOptions options = new HtmlOptions();
// To get HTML representations of pages with embedded resources
options.IsResourcesEmbedded = true;
// Get document pages in html form
List<PageHtml> pages = htmlHandler.GetPages(guid, options);
foreach (PageHtml page in pages)
{
// Access HTML of each page using page.HtmlContent property
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment