public void Render(IDocument doc, string outputFolder, bool ByMD5 = false) { if (doc == null) { throw new ArgumentException("Document is null!"); } _doc = doc; _bByMD5 = ByMD5; if (!String.IsNullOrEmpty(outputFolder)) { InitializeOutputFolder(outputFolder); } else { InitializeOutputFolder(_doc.GeneratorConfigurationSet.DefaultHtmlConfiguration.OutputFolder); } if (ByMD5 == false) { #region create html without md5 // Set the image output directory based on output folder if it is invalid path. if (!Directory.Exists(_imagesStreamManager.WorkingDirectory)) { _imagesStreamManager.WorkingDirectory = Path.Combine(_outputFolder, "images"); } // Set the start html file. _startHtmlFile = _outputFolder + START_PAGE_NAME; CopyTemplateFilesToOutputFolder(); // Generate document_data.js JsDocument jsDoc = new JsDocument(this); jsDoc.SaveToJsFile(); Guid currentPageGuid = _doc.GeneratorConfigurationSet.DefaultHtmlConfiguration.CurrentPage; if (currentPageGuid != Guid.Empty) { // Only generate current page. IPage currentPage = _doc.Pages[currentPageGuid]; if (currentPage != null) { bool isClosedPage = false; if (!currentPage.IsOpened) { isClosedPage = true; currentPage.Open(); } JsPage jsPage = new JsPage(this, currentPage); jsPage.SaveToJsFile(); if (isClosedPage) { currentPage.Close(); } } } else { // Generate all pages. foreach (IPage page in _doc.Pages) { bool isClosedPage = false; if (!page.IsOpened) { isClosedPage = true; page.Open(); } JsPage jsPage = new JsPage(this, page); jsPage.SaveToJsFile(); if (isClosedPage) { page.Close(); } } } // Generate all master pages. foreach (IPage page in _doc.MasterPages) { bool isClosedPage = false; if (!page.IsOpened) { isClosedPage = true; page.Open(); } JsPage jsPage = new JsPage(this, page); jsPage.SaveToJsFile(); if (isClosedPage) { page.Close(); } } #endregion } else { // Set the start Html file. _startHtmlFile = _outputFolder + START_PAGE_NAME; // Generate all pages. foreach (IPage page in _doc.Pages) { //this is just for debug test, delete it later Debug.WriteLine("===========================page md5 hash==========================="); string szhash = MD5HashManager.GetHash(page, true); Debug.WriteLine("====page md5:" + szhash + " ==========================="); bool isClosedPage = false; if (!page.IsOpened) { isClosedPage = true; page.Open(); } JsPage jsPage = new JsPage(this, page, _bByMD5); jsPage.SaveToJsFile(); if (isClosedPage) { page.Close(); } } // Generate all master pages. foreach (IPage page in _doc.MasterPages) { bool isClosedPage = false; if (!page.IsOpened) { isClosedPage = true; page.Open(); } //this is just for debug test, delete it later Debug.WriteLine("===========================page md5 hash==========================="); string szhash = MD5HashManager.GetHash(page, true); Debug.WriteLine("====page md5:" + szhash + " ==========================="); JsPage jsPage = new JsPage(this, page, true); jsPage.SaveToJsFile(); if (isClosedPage) { page.Close(); } } } if (ByMD5 == true) { _doc.ImagesStreamManager.ClearCachedStream(); } // Don't hold the document any more. _doc = null; // Reset image working directory. // _imagesStreamManager.WorkingDirectory = String.Empty; }