예제 #1
0
        public static IEnumerable <OXmlElement> HtmlPagesToOXmlElements(HtmlToOXmlElements_v2 htmlToOXmlElements, IEnumerable <HtmlPage> pages, string footerText = null)
        {
            //HtmlToOXmlElements_v2 htmlToOXmlElements = HtmlToOXmlElements_v2.Create(configElement.zXPathElement("HtmlToDocx"), imageDirectory);

            IEnumerable <OXmlElement> elements =
                GetDocDefaults().Union(
                    GetStyles()).Union(
                    GetDocSection()).Union(
                    GetHeaderFooter(footerText));
            bool first = true;

            foreach (HtmlPage page in pages)
            {
                //Trace.WriteLine($"page \"{page.Title}\" date \"{page.Date}\"");
                if (!first)
                {
                    //elements = elements.Union(new OXmlElement[] { new OXmlBreakElement { BreakType = BreakValues.Page } });
                    elements = elements.Union(GetPageBreak());
                }
                first    = false;
                elements = elements.Union(GetTitle(page.Date + " : " + page.Title));
                //elements = elements.Union(HtmlToOXmlElements_v2.ToOXmlXElements(page.HtmlNodes, imageDirectory, page.WebImages));
                elements = elements.Union(htmlToOXmlElements.ToOXmlXElements(page.HtmlNodes, page.WebImages));
            }
            return(elements);
        }
예제 #2
0
        public static void Test_Trace_HtmlToOXml_v2(string file, string imageDirectory)
        {
            string traceFile = file + ".oxml.json";
            //HtmlToOXmlElements_v2.ToOXmlXElements(HtmlDocReader.ReadFile(file), imageDirectory).zSave(traceFile);
            //HtmlToOXmlElements_v2 htmlToOXmlElements = HtmlToOXmlElements_v2.Create(BlogDemoor_v4.GetConfigElement().zXPathElement("HtmlToDocx"), imageDirectory);
            HtmlToOXmlElements_v2 htmlToOXmlElements = CreateHtmlToOXmlElements(BlogDemoor_v4.GetConfigElement(), imageDirectory);

            htmlToOXmlElements.ToOXmlXElements(HtmlDocReader.ReadFile(file)).zSave(traceFile, jsonIndent: true);
        }
예제 #3
0
        public static IEnumerable <OXmlElement> HtmlPageToOXmlElements(HtmlToOXmlElements_v2 htmlToOXmlElements, HtmlPage page, string footerText = null)
        {
            IEnumerable <OXmlElement> elements =
                GetDocDefaults().Union(
                    GetStyles()).Union(
                    GetDocSection()).Union(
                    GetHeaderFooter(footerText));

            //Trace.WriteLine($"page \"{page.Title}\" date \"{page.Date}\"");
            elements = elements.Union(GetTitle(page.Date + " : " + page.Title));
            //elements = elements.Union(HtmlToOXmlElements_v2.ToOXmlXElements(page.HtmlNodes, imageDirectory, page.WebImages));
            elements = elements.Union(htmlToOXmlElements.ToOXmlXElements(page.HtmlNodes, page.WebImages));
            return(elements);
        }
예제 #4
0
        public static void Test_HtmlToDocx(string file, string imageDirectory, string title = null, string footerText = null)
        {
            IEnumerable <OXmlElement> elements =
                GetDocDefaults().Union(
                    GetStyles()).Union(
                    GetDocSection()).Union(
                    GetHeaderFooter(footerText));

            if (title != null)
            {
                elements = elements.Union(GetTitle(title));
            }
            //HtmlToOXmlElements_v2 htmlToOXmlElements = HtmlToOXmlElements_v2.Create(BlogDemoor_v4.GetConfigElement().zXPathElement("HtmlToDocx"), imageDirectory);
            HtmlToOXmlElements_v2 htmlToOXmlElements = CreateHtmlToOXmlElements(BlogDemoor_v4.GetConfigElement(), imageDirectory);

            //elements = elements.Union(HtmlToOXmlElements_v2.ToOXmlXElements(HtmlDocReader.ReadFile(file), imageDirectory));
            elements = elements.Union(htmlToOXmlElements.ToOXmlXElements(HtmlDocReader.ReadFile(file)));
            OXmlDoc.Create(file + ".docx", elements);
        }