Esempio n. 1
0
        public Task <bool> Html(int pagenumber, DirectoryInfo folder, string highlight)
        {
            string filename = Path.Combine(folder.FullName,
                                           Path.ChangeExtension(pagenumber.ToString(), html.ToString()));
            ISet <int> highlightedOffsets = string.IsNullOrWhiteSpace(highlight)
                ? new HashSet <int>()
                : SearchUtil.HighlightedOffsets(pagenumber, highlight, DataFolder);

            using (HtmlWriter writer = new HtmlWriter(new FileStream(filename, FileMode.Create, FileAccess.Write),
                                                      pagenumber, highlightedOffsets))
            {
                TocItem            item  = FindItem(pagenumber);
                IEnumerable <Page> pages = PageUtil.LoadPages(DataFolder.GetFileIgnoreCase(TextDki), item.Pagenumber,
                                                              item.Pagecount);
                foreach (Page page in pages)
                {
                    PageUtil.Parse(page, writer);
                }

                DumpImages(writer.ImageIdsToExtensions, folder);
            }

            return(Task.FromResult(true));
        }