public static void Run() { string outputDirectory = Utils.GetOutputDirectoryPath(); // The {0} and {1} patterns will be replaced with current processing page number and resource name accordingly. string pageFilePathFormat = $"{outputDirectory}/page_{{0}}.html"; string resourceFilePathFormat = $"{outputDirectory}/page_{{0}}_{{1}}"; string resourceUrlFormat = $"{outputDirectory}/page_{{0}}_{{1}}"; using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DOCX)) { HtmlViewOptions options = HtmlViewOptions .ForExternalResources(pageFilePathFormat, resourceFilePathFormat, resourceUrlFormat); viewer.View(options); } Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); }
private HtmlViewOptions CreateHtmlViewOptions(int passedPageNumber = -1, int newAngle = 0) { HtmlViewOptions htmlViewOptions = HtmlViewOptions.ForExternalResources( pageNumber => { string fileName = $"p{pageNumber}.html"; string cacheFilePath = this.cache.GetCacheFilePath(fileName); return(File.Create(cacheFilePath)); }, (pageNumber, resource) => { string fileName = $"p{pageNumber}_{resource.FileName}"; string cacheFilePath = this.cache.GetCacheFilePath(fileName); return(File.Create(cacheFilePath)); }, (pageNumber, resource) => { var urlPrefix = "/viewer/resources/" + Path.GetFileName(this.filePath).Replace(".", "_"); return($"{urlPrefix}/p{ pageNumber}_{ resource.FileName}"); }); htmlViewOptions.SpreadsheetOptions = SpreadsheetOptions.ForOnePagePerSheet(); htmlViewOptions.SpreadsheetOptions.TextOverflowMode = TextOverflowMode.HideText; htmlViewOptions.SpreadsheetOptions.RenderGridLines = globalConfiguration.GetViewerConfiguration().GetShowGridLines(); htmlViewOptions.SpreadsheetOptions.RenderHeadings = true; SetWatermarkOptions(htmlViewOptions); if (passedPageNumber >= 0 && newAngle != 0) { Rotation rotationAngle = GetRotationByAngle(newAngle); htmlViewOptions.RotatePage(passedPageNumber, rotationAngle); } return(htmlViewOptions); }