Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// 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
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
You can’t perform that action at this time.