Пример #1
0
        private void TestEmbeddedHtml(int number)
        {
            string         html    = Helper.GetSampleContents("Trifolia.Test.DocSamples.HTML.html" + number + ".html");
            OpenXmlElement element = HtmlToOpenXmlConverter.HtmlToOpenXml(tdb, mdp, html, true);

            ValidateOpenXml(element);
        }
Пример #2
0
        public void TestWhiteSpacePreservation()
        {
            string         html    = "<span>This is <bold>a test</bold> of bold text</span>";
            OpenXmlElement element = HtmlToOpenXmlConverter.HtmlToOpenXml(tdb, mdp, html, true);

            Paragraph para = element.FirstChild as Paragraph;

            Assert.IsNotNull(para);

            Run run = para.OfType <Run>().FirstOrDefault();

            Assert.IsNotNull(run);

            Text text = run.OfType <Text>().FirstOrDefault();

            Assert.IsNotNull(text);
            Assert.IsNotNull(text.Space);
            Assert.AreEqual(SpaceProcessingModeValues.Preserve, text.Space.Value);
            Assert.AreEqual("This is ", text.Text);
        }
Пример #3
0
        private void AddVolume1(bool includeAppendix)
        {
            if (!this.exportSettings.IncludeVolume1)
            {
                return;
            }

            string html = this.igSettings.GetSetting(IGSettingsManager.SettingProperty.Volume1Html);

            if (!string.IsNullOrEmpty(html))
            {
                var next = HtmlToOpenXmlConverter.HtmlToOpenXml(this._tdb, this.document.MainDocumentPart, html);

                if (next != null)
                {
                    foreach (OpenXmlElement cParsedChild in next.ChildElements)
                    {
                        OpenXmlElement cClonedParsedChild = cParsedChild.CloneNode(true);
                        this.document.MainDocumentPart.Document.Body.Append(cClonedParsedChild);
                    }
                }
            }
            else
            {
                foreach (var section in this.implementationGuide.Sections)
                {
                    bool isAppendix = section.Heading.ToLower().StartsWith("appendix");

                    if (isAppendix != includeAppendix)
                    {
                        continue;
                    }

                    string headingStyle = GetHeadingStyle(section.Level);

                    if (headingStyle == null)
                    {
                        continue;
                    }

                    // Add the heading
                    Paragraph heading = new Paragraph(
                        new ParagraphProperties(
                            new ParagraphStyleId()
                    {
                        Val = headingStyle
                    }),
                        new Run(
                            new Text(section.Heading)));
                    this.document.MainDocumentPart.Document.Body.AppendChild(heading);

                    // Add the Markdown converted to HTML, then OpenXml
                    var next = section.Content.MarkdownToOpenXml(this._tdb, this.document.MainDocumentPart, false);

                    if (next != null)
                    {
                        foreach (OpenXmlElement cParsedChild in next.ChildElements)
                        {
                            OpenXmlElement cClonedParsedChild = cParsedChild.CloneNode(true);
                            this.document.MainDocumentPart.Document.Body.Append(cClonedParsedChild);
                        }
                    }
                }
            }
        }