internal void Process(Run element, DocxNode node)
		{
			RunProperties properties = element.RunProperties;
			
			if (properties == null)
			{
				properties = new RunProperties();
			}
			
			//Order of assigning styles to run property is important. The order should not change.
            CheckFonts(node, properties);

            string color = node.ExtractStyleValue(DocxColor.color);
			
			if (!string.IsNullOrEmpty(color))
			{
				DocxColor.ApplyColor(color, properties);
			}

            CheckFontStyle(node, properties);

            ProcessBackGround(node, properties);

            ProcessVerticalAlign(node, properties);

			if (element.RunProperties == null && properties.HasChildren)
			{
				element.RunProperties = properties;
			}
		}
Example #2
0
 protected Run GenerateRun(RunProperties runProperties, string text)
 {
     SetFontRunProperties(runProperties);
     var run = new Run() { RunProperties = runProperties };
     run.AppendChild(new Text(text));
     return run;
 }
        private void ProcessVerticalAlign(DocxNode node, RunProperties properties)
        {
            string verticalAlign = node.ExtractStyleValue(DocxAlignment.verticalAlign);

            if(!string.IsNullOrEmpty(verticalAlign))
            {
                DocxAlignment.ApplyVerticalTextAlign(verticalAlign, properties);
            }
        }
Example #4
0
 protected void SetFontRunProperties(RunProperties runProperties)
 {
     runProperties.RunFonts = new RunFonts()
     {
         Ascii = "Times New Roman"
     };
     runProperties.FontSize = new FontSize()
     {
         Val = "24"
     };
 }
        private void ProcessBackGround(DocxNode node, RunProperties properties)
        {
            string backgroundColor = node.ExtractStyleValue(DocxColor.backGroundColor);
            string backGround = DocxColor.ExtractBackGround(node.ExtractStyleValue(DocxColor.backGround));

            if (!string.IsNullOrEmpty(backgroundColor))
            {
                DocxColor.ApplyBackGroundColor(backgroundColor, properties);
            }
            else if (!string.IsNullOrEmpty(backGround))
            {
                DocxColor.ApplyBackGroundColor(backGround, properties);
            }
        }
Example #6
0
        protected void AddParagraph(Body body, JustificationValues justification, RunProperties runProperties, string text)
        {
            SetFontRunProperties(runProperties);
            var paragraph = body.AppendChild(new Paragraph()
            {
                ParagraphProperties = new ParagraphProperties()
                {
                    Justification = new Justification() { Val = justification }
                }
            });

            var run = paragraph.AppendChild(new Run() { RunProperties = runProperties });
            run.AppendChild(new Text(text));
        }
Example #7
0
        private Paragraph CreateCodeParagraph(CodeVM code)
        {
            Paragraph paragraph1 = new Paragraph();

            ParagraphProperties paragraphProperties1 = new ParagraphProperties();
            Indentation indentation1 = new Indentation(){ FirstLine = "210", FirstLineChars = 100 };

            paragraphProperties1.Append(indentation1);

            Run run1 = new Run();

            RunProperties runProperties1 = new RunProperties();
            RunFonts runFonts1 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties1.Append(runFonts1);
            Text text1 = new Text();
            text1.Text = code.Value;
            run1.Append(runProperties1);
            run1.Append(text1);

            Run run2 = new Run();

            RunProperties runProperties2 = new RunProperties();
            RunFonts runFonts2 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties2.Append(runFonts2);
            TabChar tabChar1 = new TabChar();

            run2.Append(runProperties2);
            run2.Append(tabChar1);

            Run run3 = new Run();

            RunProperties runProperties3 = new RunProperties();
            RunFonts runFonts3 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties3.Append(runFonts3);
            Text text2 = new Text();
            text2.Text = code.Label;

            run3.Append(runProperties3);
            run3.Append(text2);

            paragraph1.Append(paragraphProperties1);
            paragraph1.Append(run1);
            paragraph1.Append(run2);
            paragraph1.Append(run3);
            return paragraph1;
        }
        private void CheckFontStyle(DocxNode node, RunProperties properties)
		{
            string fontSize = node.ExtractStyleValue(DocxFontStyle.fontSize);
            string textDecoration = node.ExtractStyleValue(DocxFontStyle.textDecoration);
			
			if (!string.IsNullOrEmpty(fontSize))
			{
				DocxFontStyle.ApplyFontSize(fontSize, properties);
			}
			
			if (!string.IsNullOrEmpty(textDecoration))
			{
				DocxFontStyle.ApplyTextDecoration(textDecoration, properties);
			}
		}
Example #9
0
        public Paragraph AddAlphaRow()
        {
            var paragraph1 = new Paragraph {RsidParagraphMarkRevision = "005205ED", RsidParagraphAddition = "00A01149", RsidParagraphProperties = "005205ED", RsidRunAdditionDefault = "00E7001C"};

            var paragraphProperties1 = new ParagraphProperties();
            var spacingBetweenLines1 = new SpacingBetweenLines {After = "60", Line = "240", LineRule = LineSpacingRuleValues.Auto};
            var justification1 = new Justification {Val = JustificationValues.Center};

            var paragraphMarkRunProperties1 = new ParagraphMarkRunProperties();
            var runFonts1 = new RunFonts {ComplexScriptTheme = ThemeFontValues.MinorHighAnsi};
            var bold1 = new Bold();
            var fontSize1 = new FontSize {Val = "32"};
            var fontSizeComplexScript1 = new FontSizeComplexScript {Val = "32"};

            paragraphMarkRunProperties1.Append(runFonts1);
            paragraphMarkRunProperties1.Append(bold1);
            paragraphMarkRunProperties1.Append(fontSize1);
            paragraphMarkRunProperties1.Append(fontSizeComplexScript1);

            paragraphProperties1.Append(new KeepNext());
            paragraphProperties1.Append(spacingBetweenLines1);
            paragraphProperties1.Append(justification1);
            paragraphProperties1.Append(paragraphMarkRunProperties1);

            var run1 = new Run {RsidRunProperties = "005205ED"};

            var runProperties1 = new RunProperties();
            var runFonts2 = new RunFonts {ComplexScriptTheme = ThemeFontValues.MinorHighAnsi};
            var bold2 = new Bold();
            var fontSize2 = new FontSize {Val = "32"};
            var fontSizeComplexScript2 = new FontSizeComplexScript {Val = "32"};

            runProperties1.Append(runFonts2);
            runProperties1.Append(bold2);
            runProperties1.Append(fontSize2);
            runProperties1.Append(fontSizeComplexScript2);
            var text1 = new Text();
            text1.Text = FamilyName.Substring(0, 1);

            run1.Append(runProperties1);
            run1.Append(text1);

            paragraph1.Append(paragraphProperties1);
            paragraph1.Append(run1);
            return paragraph1;
        }
        /// <summary>
        /// Apply all the current Html tag (Run properties) to the specified run.
        /// </summary>
        public override void ApplyTags(OpenXmlCompositeElement run)
        {
            if (tags.Count == 0 && DefaultRunStyle == null) return;

            RunProperties properties = run.GetFirstChild<RunProperties>();
            if (properties == null) run.PrependChild<RunProperties>(properties = new RunProperties());

            var en = tags.GetEnumerator();
            while (en.MoveNext())
            {
                TagsAtSameLevel tagsOfSameLevel = en.Current.Value.Peek();
                foreach (OpenXmlElement tag in tagsOfSameLevel.Array)
                    properties.Append(tag.CloneNode(true));
            }

            if (this.DefaultRunStyle != null)
                properties.Append(new RunStyle() { Val = this.DefaultRunStyle });
        }
        public static StyleDefinitionsPart ApplyStyle(this StyleDefinitionsPart part, IStyle mystyle)
        {
            var pRp = new RunProperties();
            var color = new Color()
            {
                Val = mystyle.Color
            };
            var fonts = new RunFonts
            {
                Ascii = mystyle.FontName
            };
            pRp.Append(color);
            pRp.Append(fonts);

            if (mystyle.Bold)
            {
                pRp.Append(new Bold());
            }

            pRp.Append(new FontSize()
            {
                Val = mystyle.FontSize.ToString()
            });

            var style = new Style { StyleId = mystyle.Id };
            style.Append(new Name() { Val = mystyle.Name });
            style.Append(new BasedOn() { Val = mystyle.BasedOn });
            style.Append(new NextParagraphStyle() { Val = "Normal" });

            style.Append(pRp);

            if (part.Styles == null)
            {
                part.Styles = new Styles();
            }

            part.Styles.Append(style);
            part.Styles.Save();

            return part;
        }
		private void CheckFonts(DocxNode node, RunProperties properties)
		{
            string fontFamily = node.ExtractStyleValue(DocxFontStyle.fontFamily);
            string fontWeight = node.ExtractStyleValue(DocxFontStyle.fontWeight);
            string fontStyle = node.ExtractStyleValue(DocxFontStyle.fontStyle);
			
			if (!string.IsNullOrEmpty(fontFamily))
			{
				DocxFontStyle.ApplyFontFamily(fontFamily, properties);
			}
			
			if (!string.IsNullOrEmpty(fontWeight))
			{
				DocxFontStyle.ApplyFontWeight(fontWeight, properties);
			}
				
			if (!string.IsNullOrEmpty(fontStyle))
			{
				DocxFontStyle.ApplyFontStyle(fontStyle, properties);
			}
		}
 protected static IEnumerable<Run> CreateTextContent(IEnumerable<string> content, RunProperties runProperties = null)
 {
     return content
         .SelectMany(x => x.Split(new[] {Environment.NewLine}, StringSplitOptions.None))
         .SelectMany((contentLine, index) => index == 0
                                                 ? new[]
                                                   	{
                                                   		new Run(new Text(contentLine) {Space = SpaceProcessingModeValues.Preserve})
                                                   			{
                                                   				RunProperties = CloneRunPropertiesIfNotNull(runProperties)
                                                   			}
                                                   	}
                                                 : new[]
                                                   	{
                                                   		new Run(new Break()) {RunProperties = CloneRunPropertiesIfNotNull(runProperties)},
                                                   		new Run(new Text(contentLine) {Space = SpaceProcessingModeValues.Preserve})
                                                   			{
                                                   				RunProperties = CloneRunPropertiesIfNotNull(runProperties)
                                                   			}
                                                   	})
         .ToList();
 }
Example #14
0
        private void GenerateChapterEight()
        {
            var paraProp = new ParagraphProperties();
            var paragraph = new Paragraph();
            var runProp = new RunProperties();
            var run = new Run();

            var chapterEight = _sessionObjects.ChapterEight;
            run.Append(new Text(chapterEight.Header));
            paraProp = GetParagraphProperties("Header1");
            GenerateParagraph(run, paraProp);

            for (var i = 0; i < chapterEight.Provision.Rows.Count; i++)
            {
                paraProp = GetParagraphProperties("StyleWithoutIndentation");
                run = new Run();
                var str = String.Format("{0}. {1}", i, chapterEight.Provision.Rows[i]["Text"].ToString());
                run.Append(new Text(str));
                GenerateParagraph(run, paraProp);
            }
            GenerateParagraph();
        }
        private static RunProperties CreateRun(Model.Text text)
        {
            RunProperties runProperties = new RunProperties();
            if (text.Font == null) return null;

            FontSize size = new FontSize()
            {
                Val = Utilities.GetHPSValue(text.Font.Size)
            };

            runProperties.Append(size);

            foreach (var format in text.Font.Formats)
            {
                switch (format)
                {
                    case Model.FontFormats.Bold: runProperties.Append(new Bold()); break;
                    case Model.FontFormats.Italic: runProperties.Append(new Italic()); break;
                    case Model.FontFormats.Underlined: runProperties.Append(new Underline() { Val = UnderlineValues.Single}); break;
                }
            }

            return runProperties;
        }
        private Paragraph GenerateReportDataHeadParagraph()
        {
            Paragraph paragraph1 = new Paragraph() { RsidParagraphMarkRevision = "00F24BD4", RsidParagraphAddition = "0073701D", RsidParagraphProperties = "00D25DD5", RsidRunAdditionDefault = "00D25DD5" };

            ParagraphProperties paragraphProperties1 = new ParagraphProperties();
            ParagraphStyleId paragraphStyleId1 = new ParagraphStyleId() { Val = "Heading1" };
            SpacingBetweenLines spacingBetweenLines1 = new SpacingBetweenLines() { Before = "120", After = "120" };
            Justification justification1 = new Justification() { Val = JustificationValues.Center };

            ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties();
            RunFonts runFonts1 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize1 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript1 = new FontSizeComplexScript() { Val = "36" };

            paragraphMarkRunProperties1.Append(runFonts1);
            paragraphMarkRunProperties1.Append(fontSize1);
            paragraphMarkRunProperties1.Append(fontSizeComplexScript1);

            paragraphProperties1.Append(paragraphStyleId1);
            paragraphProperties1.Append(spacingBetweenLines1);
            paragraphProperties1.Append(justification1);
            paragraphProperties1.Append(paragraphMarkRunProperties1);

            Run run1 = new Run() { RsidRunProperties = "00F24BD4" };

            RunProperties runProperties1 = new RunProperties();
            RunFonts runFonts2 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize2 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript2 = new FontSizeComplexScript() { Val = "36" };

            runProperties1.Append(runFonts2);
            runProperties1.Append(fontSize2);
            runProperties1.Append(fontSizeComplexScript2);
            Text text1 = new Text();
            text1.Text = "管";

            run1.Append(runProperties1);
            run1.Append(text1);

            Run run2 = new Run() { RsidRunAddition = "00F24BD4" };

            RunProperties runProperties2 = new RunProperties();
            RunFonts runFonts3 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize3 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript3 = new FontSizeComplexScript() { Val = "36" };

            runProperties2.Append(runFonts3);
            runProperties2.Append(fontSize3);
            runProperties2.Append(fontSizeComplexScript3);
            Text text2 = new Text() { Space = SpaceProcessingModeValues.Preserve };
            text2.Text = " ";

            run2.Append(runProperties2);
            run2.Append(text2);

            Run run3 = new Run() { RsidRunProperties = "00F24BD4" };

            RunProperties runProperties3 = new RunProperties();
            RunFonts runFonts4 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize4 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript4 = new FontSizeComplexScript() { Val = "36" };

            runProperties3.Append(runFonts4);
            runProperties3.Append(fontSize4);
            runProperties3.Append(fontSizeComplexScript4);
            Text text3 = new Text();
            text3.Text = "材";

            run3.Append(runProperties3);
            run3.Append(text3);

            Run run4 = new Run() { RsidRunAddition = "00F24BD4" };

            RunProperties runProperties4 = new RunProperties();
            RunFonts runFonts5 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize5 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript5 = new FontSizeComplexScript() { Val = "36" };

            runProperties4.Append(runFonts5);
            runProperties4.Append(fontSize5);
            runProperties4.Append(fontSizeComplexScript5);
            Text text4 = new Text() { Space = SpaceProcessingModeValues.Preserve };
            text4.Text = " ";

            run4.Append(runProperties4);
            run4.Append(text4);

            Run run5 = new Run() { RsidRunProperties = "00F24BD4" };

            RunProperties runProperties5 = new RunProperties();
            RunFonts runFonts6 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize6 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript6 = new FontSizeComplexScript() { Val = "36" };

            runProperties5.Append(runFonts6);
            runProperties5.Append(fontSize6);
            runProperties5.Append(fontSizeComplexScript6);
            Text text5 = new Text();
            text5.Text = "单";

            run5.Append(runProperties5);
            run5.Append(text5);

            Run run6 = new Run() { RsidRunAddition = "00F24BD4" };

            RunProperties runProperties6 = new RunProperties();
            RunFonts runFonts7 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize7 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript7 = new FontSizeComplexScript() { Val = "36" };

            runProperties6.Append(runFonts7);
            runProperties6.Append(fontSize7);
            runProperties6.Append(fontSizeComplexScript7);
            Text text6 = new Text() { Space = SpaceProcessingModeValues.Preserve };
            text6.Text = " ";

            run6.Append(runProperties6);
            run6.Append(text6);

            Run run7 = new Run() { RsidRunProperties = "00F24BD4" };

            RunProperties runProperties7 = new RunProperties();
            RunFonts runFonts8 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize8 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript8 = new FontSizeComplexScript() { Val = "36" };

            runProperties7.Append(runFonts8);
            runProperties7.Append(fontSize8);
            runProperties7.Append(fontSizeComplexScript8);
            Text text7 = new Text();
            text7.Text = "根";

            run7.Append(runProperties7);
            run7.Append(text7);

            Run run8 = new Run() { RsidRunAddition = "00F24BD4" };

            RunProperties runProperties8 = new RunProperties();
            RunFonts runFonts9 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize9 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript9 = new FontSizeComplexScript() { Val = "36" };

            runProperties8.Append(runFonts9);
            runProperties8.Append(fontSize9);
            runProperties8.Append(fontSizeComplexScript9);
            Text text8 = new Text() { Space = SpaceProcessingModeValues.Preserve };
            text8.Text = " ";

            run8.Append(runProperties8);
            run8.Append(text8);

            Run run9 = new Run() { RsidRunProperties = "00F24BD4" };

            RunProperties runProperties9 = new RunProperties();
            RunFonts runFonts10 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize10 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript10 = new FontSizeComplexScript() { Val = "36" };

            runProperties9.Append(runFonts10);
            runProperties9.Append(fontSize10);
            runProperties9.Append(fontSizeComplexScript10);
            Text text9 = new Text();
            text9.Text = "检";

            run9.Append(runProperties9);
            run9.Append(text9);

            Run run10 = new Run() { RsidRunAddition = "00F24BD4" };

            RunProperties runProperties10 = new RunProperties();
            RunFonts runFonts11 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize11 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript11 = new FontSizeComplexScript() { Val = "36" };

            runProperties10.Append(runFonts11);
            runProperties10.Append(fontSize11);
            runProperties10.Append(fontSizeComplexScript11);
            Text text10 = new Text() { Space = SpaceProcessingModeValues.Preserve };
            text10.Text = " ";

            run10.Append(runProperties10);
            run10.Append(text10);

            Run run11 = new Run() { RsidRunProperties = "00F24BD4" };

            RunProperties runProperties11 = new RunProperties();
            RunFonts runFonts12 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize12 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript12 = new FontSizeComplexScript() { Val = "36" };

            runProperties11.Append(runFonts12);
            runProperties11.Append(fontSize12);
            runProperties11.Append(fontSizeComplexScript12);
            Text text11 = new Text();
            text11.Text = "验";

            run11.Append(runProperties11);
            run11.Append(text11);

            Run run12 = new Run() { RsidRunAddition = "00F24BD4" };

            RunProperties runProperties12 = new RunProperties();
            RunFonts runFonts13 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize13 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript13 = new FontSizeComplexScript() { Val = "36" };

            runProperties12.Append(runFonts13);
            runProperties12.Append(fontSize13);
            runProperties12.Append(fontSizeComplexScript13);
            Text text12 = new Text() { Space = SpaceProcessingModeValues.Preserve };
            text12.Text = " ";

            run12.Append(runProperties12);
            run12.Append(text12);

            Run run13 = new Run() { RsidRunProperties = "00F24BD4" };

            RunProperties runProperties13 = new RunProperties();
            RunFonts runFonts14 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize14 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript14 = new FontSizeComplexScript() { Val = "36" };

            runProperties13.Append(runFonts14);
            runProperties13.Append(fontSize14);
            runProperties13.Append(fontSizeComplexScript14);
            Text text13 = new Text();
            text13.Text = "信";

            run13.Append(runProperties13);
            run13.Append(text13);

            Run run14 = new Run() { RsidRunAddition = "00F24BD4" };

            RunProperties runProperties14 = new RunProperties();
            RunFonts runFonts15 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize15 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript15 = new FontSizeComplexScript() { Val = "36" };

            runProperties14.Append(runFonts15);
            runProperties14.Append(fontSize15);
            runProperties14.Append(fontSizeComplexScript15);
            Text text14 = new Text() { Space = SpaceProcessingModeValues.Preserve };
            text14.Text = " ";

            run14.Append(runProperties14);
            run14.Append(text14);

            Run run15 = new Run() { RsidRunProperties = "00F24BD4" };

            RunProperties runProperties15 = new RunProperties();
            RunFonts runFonts16 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize16 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript16 = new FontSizeComplexScript() { Val = "36" };

            runProperties15.Append(runFonts16);
            runProperties15.Append(fontSize16);
            runProperties15.Append(fontSizeComplexScript16);
            Text text15 = new Text();
            text15.Text = "息";

            run15.Append(runProperties15);
            run15.Append(text15);

            Run run16 = new Run() { RsidRunAddition = "00F24BD4" };

            RunProperties runProperties16 = new RunProperties();
            RunFonts runFonts17 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize17 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript17 = new FontSizeComplexScript() { Val = "36" };

            runProperties16.Append(runFonts17);
            runProperties16.Append(fontSize17);
            runProperties16.Append(fontSizeComplexScript17);
            Text text16 = new Text() { Space = SpaceProcessingModeValues.Preserve };
            text16.Text = " ";

            run16.Append(runProperties16);
            run16.Append(text16);

            Run run17 = new Run() { RsidRunProperties = "00F24BD4" };

            RunProperties runProperties17 = new RunProperties();
            RunFonts runFonts18 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize18 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript18 = new FontSizeComplexScript() { Val = "36" };

            runProperties17.Append(runFonts18);
            runProperties17.Append(fontSize18);
            runProperties17.Append(fontSizeComplexScript18);
            Text text17 = new Text();
            text17.Text = "统";

            run17.Append(runProperties17);
            run17.Append(text17);

            Run run18 = new Run() { RsidRunAddition = "00F24BD4" };

            RunProperties runProperties18 = new RunProperties();
            RunFonts runFonts19 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize19 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript19 = new FontSizeComplexScript() { Val = "36" };

            runProperties18.Append(runFonts19);
            runProperties18.Append(fontSize19);
            runProperties18.Append(fontSizeComplexScript19);
            Text text18 = new Text() { Space = SpaceProcessingModeValues.Preserve };
            text18.Text = " ";

            run18.Append(runProperties18);
            run18.Append(text18);

            Run run19 = new Run() { RsidRunProperties = "00F24BD4" };

            RunProperties runProperties19 = new RunProperties();
            RunFonts runFonts20 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize20 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript20 = new FontSizeComplexScript() { Val = "36" };

            runProperties19.Append(runFonts20);
            runProperties19.Append(fontSize20);
            runProperties19.Append(fontSizeComplexScript20);
            Text text19 = new Text();
            text19.Text = "计";

            run19.Append(runProperties19);
            run19.Append(text19);

            Run run20 = new Run() { RsidRunAddition = "00F24BD4" };

            RunProperties runProperties20 = new RunProperties();
            RunFonts runFonts21 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize21 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript21 = new FontSizeComplexScript() { Val = "36" };

            runProperties20.Append(runFonts21);
            runProperties20.Append(fontSize21);
            runProperties20.Append(fontSizeComplexScript21);
            Text text20 = new Text() { Space = SpaceProcessingModeValues.Preserve };
            text20.Text = " ";

            run20.Append(runProperties20);
            run20.Append(text20);
            BookmarkStart bookmarkStart1 = new BookmarkStart() { Name = "_GoBack", Id = "0" };
            BookmarkEnd bookmarkEnd1 = new BookmarkEnd() { Id = "0" };

            Run run21 = new Run() { RsidRunProperties = "00F24BD4" };

            RunProperties runProperties21 = new RunProperties();
            RunFonts runFonts22 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微软雅黑", HighAnsi = "微软雅黑", EastAsia = "微软雅黑" };
            FontSize fontSize22 = new FontSize() { Val = "36" };
            FontSizeComplexScript fontSizeComplexScript22 = new FontSizeComplexScript() { Val = "36" };

            runProperties21.Append(runFonts22);
            runProperties21.Append(fontSize22);
            runProperties21.Append(fontSizeComplexScript22);
            Text text21 = new Text();
            text21.Text = "表";

            run21.Append(runProperties21);
            run21.Append(text21);

            paragraph1.Append(paragraphProperties1);
            paragraph1.Append(run1);
            paragraph1.Append(run2);
            paragraph1.Append(run3);
            paragraph1.Append(run4);
            paragraph1.Append(run5);
            paragraph1.Append(run6);
            paragraph1.Append(run7);
            paragraph1.Append(run8);
            paragraph1.Append(run9);
            paragraph1.Append(run10);
            paragraph1.Append(run11);
            paragraph1.Append(run12);
            paragraph1.Append(run13);
            paragraph1.Append(run14);
            paragraph1.Append(run15);
            paragraph1.Append(run16);
            paragraph1.Append(run17);
            paragraph1.Append(run18);
            paragraph1.Append(run19);
            paragraph1.Append(run20);
            paragraph1.Append(bookmarkStart1);
            paragraph1.Append(bookmarkEnd1);
            paragraph1.Append(run21);
            return paragraph1;
        }
        private TableCell BuildNullableBolleanCell(bool? v)
        {
            TableCell cell = BuildCell(v.HasValue ? (v.Value ? "合格" : "不合格") : "/");

            if (v.HasValue && !v.Value)
            {
                Run r = cell.Descendants<Run>().FirstOrDefault();
                RunProperties runProperties1 = r.Descendants<RunProperties>().FirstOrDefault();
                if (runProperties1 == null)
                {
                    runProperties1 = new RunProperties();
                    r.Append(runProperties1);
                }

                Color color1 = new Color() { Val = "FF0000" };
                runProperties1.Append(color1);
            }

            return cell;
        }
Example #18
0
        //.....................................................................
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private TableCell MakeElem5( )
        {
            //---------------------------------------------
            TableCell tableCell5 = new TableCell( );

            //---------------------------------------------
            TableCellProperties tableCellProperties5 = new TableCellProperties( );

            TableCellWidth tableCellWidth5 = new TableCellWidth( )
            {
                Width = "2841", Type = TableWidthUnitValues.Dxa
            };
            TableCellVerticalAlignment tableCellVerticalAlignment5 = new TableCellVerticalAlignment( )
            {
                Val = TableVerticalAlignmentValues.Center
            };

            tableCellProperties5.Append(tableCellWidth5);
            tableCellProperties5.Append(tableCellVerticalAlignment5);

            //---------------------------------------------
            Paragraph paragraph5 = new Paragraph( )
            {
                RsidParagraphMarkRevision = "00422B84", RsidParagraphAddition = "00B721D5", RsidRunAdditionDefault = "00B721D5"
            };

            ParagraphProperties paragraphProperties5 = new ParagraphProperties( );

            //---------------------------------------------
            ParagraphMarkRunProperties paragraphMarkRunProperties4 = new ParagraphMarkRunProperties( );
            Bold   bold7   = new Bold( );
            Strike strike1 = new Strike( );

            paragraphMarkRunProperties4.Append(bold7);
            paragraphMarkRunProperties4.Append(strike1);

            paragraphProperties5.Append(paragraphMarkRunProperties4);

            //---------------------------------------------
            ProofError proofError1 = new ProofError( )
            {
                Type = ProofingErrorValues.SpellStart
            };

            //---------------------------------------------
            Run run5 = new Run( )
            {
                RsidRunProperties = "00422B84"
            };

            RunProperties runProperties5 = new RunProperties( );
            Bold          bold8          = new Bold( );
            Strike        strike2        = new Strike( );

            runProperties5.Append(bold8);
            runProperties5.Append(strike2);

            Text text5 = new Text( );

            text5.Text = "Wu";

            run5.Append(runProperties5);
            run5.Append(text5);

            //---------------------------------------------
            Run run6 = new Run( )
            {
                RsidRunProperties = "00422B84"
            };

            RunProperties runProperties6 = new RunProperties( );
            RunFonts      runFonts3      = new RunFonts( )
            {
                Hint = FontTypeHintValues.EastAsia
            };
            Bold   bold9   = new Bold( );
            Strike strike3 = new Strike( );

            runProperties6.Append(runFonts3);
            runProperties6.Append(bold9);
            runProperties6.Append(strike3);
            Text text6 = new Text( );

            text6.Text = "jianhua";

            run6.Append(runProperties6);
            run6.Append(text6);

            //---------------------------------------------
            ProofError proofError2 = new ProofError( )
            {
                Type = ProofingErrorValues.SpellEnd
            };

            paragraph5.Append(paragraphProperties5);
            paragraph5.Append(proofError1);
            paragraph5.Append(run5);
            paragraph5.Append(run6);
            paragraph5.Append(proofError2);

            tableCell5.Append(tableCellProperties5);
            tableCell5.Append(paragraph5);

            return(tableCell5);
        }
Example #19
0
        //.....................................................................
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private static TableCell MakeElem1( )
        {
            TableCell tableCell1 = new TableCell( );

            TableCellProperties tableCellProperties1 = new TableCellProperties( );

            TableCellWidth tableCellWidth1 = new TableCellWidth( )
            {
                Width = "2840", Type = TableWidthUnitValues.Dxa
            };

            TableCellVerticalAlignment tableCellVerticalAlignment1 = new TableCellVerticalAlignment( )
            {
                Val = TableVerticalAlignmentValues.Center
            };

            tableCellProperties1.Append(tableCellWidth1);
            tableCellProperties1.Append(tableCellVerticalAlignment1);

            //---------------------------------------------
            Paragraph paragraph1 = new Paragraph( )
            {
                RsidParagraphMarkRevision = "00B721D5", RsidParagraphAddition = "00B721D5", RsidParagraphProperties = "00B721D5", RsidRunAdditionDefault = "00B721D5"
            };

            ParagraphProperties paragraphProperties1 = new ParagraphProperties( );
            Justification       justification1       = new Justification( )
            {
                Val = JustificationValues.Center
            };

            ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties( );
            Bold  bold1  = new Bold( );
            Color color1 = new Color( )
            {
                Val = "FF0000"
            };

            paragraphMarkRunProperties1.Append(bold1);
            paragraphMarkRunProperties1.Append(color1);

            paragraphProperties1.Append(justification1);
            paragraphProperties1.Append(paragraphMarkRunProperties1);

            //---------------------------------------------
            Run run1 = new Run( )
            {
                RsidRunProperties = "00B721D5"
            };

            RunProperties runProperties1 = new RunProperties( );
            RunFonts      runFonts1      = new RunFonts( )
            {
                Hint = FontTypeHintValues.EastAsia
            };
            Bold  bold2  = new Bold( );
            Color color2 = new Color( )
            {
                Val = "FF0000"
            };

            runProperties1.Append(runFonts1);
            runProperties1.Append(bold2);
            runProperties1.Append(color2);

            Text text1 = new Text( );

            text1.Text = "序号";

            run1.Append(runProperties1);
            run1.Append(text1);

            //---------------------------------------------
            paragraph1.Append(paragraphProperties1);
            paragraph1.Append(run1);

            tableCell1.Append(tableCellProperties1);
            tableCell1.Append(paragraph1);

            return(tableCell1);
        }
Example #20
0
        public IActionResult Create(Processo modelo)
        {
            using (MemoryStream mem = new MemoryStream())
            {
                using (WordprocessingDocument wordDoc = WordprocessingDocument.Create(mem, DocumentFormat.OpenXml.WordprocessingDocumentType.Document, true))
                {
                    wordDoc.AddMainDocumentPart();
                    // siga a ordem
                    Document doc  = new Document();
                    Body     body = new Body();

                    // 1 paragrafo
                    Paragraph para = new Paragraph();

                    ParagraphProperties paragraphProperties1 = new ParagraphProperties();
                    ParagraphStyleId    paragraphStyleId1    = new ParagraphStyleId()
                    {
                        Val = "Normal"
                    };
                    Justification justification1 = new Justification()
                    {
                        Val = JustificationValues.Center
                    };
                    ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties();

                    paragraphProperties1.Append(paragraphStyleId1);
                    paragraphProperties1.Append(justification1);
                    paragraphProperties1.Append(paragraphMarkRunProperties1);

                    Run           run            = new Run();
                    RunProperties runProperties1 = new RunProperties();

                    Text text = new Text()
                    {
                        Text = "EXCELENTÍSSIMO SENHOR DOUTOR JUIZ DE DIREITO DA MMª " + modelo.Vara + " DA COMARCA DE " + modelo.Comarca
                    };

                    // siga a ordem
                    run.Append(runProperties1);
                    run.Append(text);
                    para.Append(paragraphProperties1);
                    para.Append(run);

                    // 2 paragrafo
                    Paragraph para2 = new Paragraph();

                    ParagraphProperties paragraphProperties2 = new ParagraphProperties();
                    ParagraphStyleId    paragraphStyleId2    = new ParagraphStyleId()
                    {
                        Val = "Normal"
                    };
                    Justification justification2 = new Justification()
                    {
                        Val = JustificationValues.Start
                    };
                    ParagraphMarkRunProperties paragraphMarkRunProperties2 = new ParagraphMarkRunProperties();

                    paragraphProperties2.Append(paragraphStyleId2);
                    paragraphProperties2.Append(justification2);
                    paragraphProperties2.Append(paragraphMarkRunProperties2);

                    Run           run2           = new Run();
                    RunProperties runProperties3 = new RunProperties();

                    run2.AppendChild(new Break());
                    run2.AppendChild(new Text("PROC. PROCESSO. " + modelo.NrProcessoCnj));
                    run2.AppendChild(new Break());
                    run2.AppendChild(new Break());
                    run2.AppendChild(new Text(modelo.BancoNome + ", por seus advogados, nos autos da " + modelo.Acao + " que move em face de " + modelo.ClienteNome +
                                              " em trâmite nesta MMª Vara Cível, processo supra, em atenção ao R. Despacho de fls.  , respeitosamente vem expor e requerer o quanto segue:"));
                    run2.AppendChild(new Break());
                    run2.AppendChild(new Break());
                    run2.AppendChild(new Text("01. A composição amigável entre as partes foi realizada por meio da Agência Bancária do Executado, o que ocasionou a não formalização de termo " +
                                              " de acordo para que o Autor possa juntar aos autos. "));
                    run2.AppendChild(new Break());
                    run2.AppendChild(new Break());
                    run2.AppendChild(new Text("02. Cumpre informar as condições do acordo firmado entre as partes, por meio do qual o Requerido efetuará o pagamento da dívida pela importância de R$ " +
                                              modelo.TotalDivida.ToString("C") + "(" + ConverteParaExtenso.ValorParaExtenso2(modelo.TotalDivida) + ") sendo entrada de R$ " + modelo.ValorEntrada.ToString("C") +
                                              "(" + ConverteParaExtenso.ValorParaExtenso2(modelo.ValorEntrada) + ") paga em " + modelo.DataVencimento.ToString("dd/MM/yyyy") + " mais " +
                                              modelo.NrParcelas + "(" + ConverteParaExtenso.NumeroParaExtenso(modelo.NrParcelas) + ") parcelas de R$ " + modelo.ValorParcela.ToString("C") + "(" +
                                              ConverteParaExtenso.ValorParaExtenso2(modelo.ValorParcela) + ") nos meses subsequentes, sendo certo que não há intenção de renovação da dívida ante " +
                                              " a ausência de manifestação nesse sentido."));
                    run2.AppendChild(new Break());
                    run2.AppendChild(new Break());
                    run2.AppendChild(new Text("03. Assim, requer a SUSPENSÃO DA AÇÃO PELO PRAZO CONCEDIDO AO REQUERIDO PARA QUE CUMPRA A OBRIGAÇÃO PACTUADA, nos termos, do art. 792, do Código de Processo Civil.  "));
                    run2.AppendChild(new Break());
                    run2.AppendChild(new Break());
                    run2.AppendChild(new Text("04. Por fim, tendo em vista o convênio existente entre o SERASA e o Poder Judiciário, requer a expedição de ofício àquele órgão para exclusão do " +
                                              " nome do Requerido, efetivado em razão do ajuizamento da presente ação. "));

                    para2.Append(paragraphProperties2);
                    para2.Append(run2);

                    // todos os 2 paragrafos no main body
                    body.Append(para);
                    body.Append(para2);

                    doc.Append(body);

                    wordDoc.MainDocumentPart.Document = doc;

                    wordDoc.Close();
                }

                return(File(mem.ToArray(), "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "ABC.docx"));
            }
        }
Example #21
0
        public IActionResult AddTable()
        {
            using (var stream = new MemoryStream())
            {
                using (var wordDocument = WordprocessingDocument.Create(stream,
                                                                        WordprocessingDocumentType.Document, true))
                {
                    wordDocument.AddMainDocumentPart();

                    var document = new Document();
                    var body     = new Body();

                    var table = new Table();

                    var tableWidth = new TableWidth()
                    {
                        Width = "5000", Type = TableWidthUnitValues.Pct
                    };
                    var borderColor = "FF8000";

                    var tableProperties = new TableProperties();
                    var tableBorders    = new TableBorders();

                    var topBorder = new TopBorder();
                    topBorder.Val   = new EnumValue <BorderValues>(BorderValues.Thick);
                    topBorder.Color = borderColor;

                    var bottomBorder = new BottomBorder();
                    bottomBorder.Val   = new EnumValue <BorderValues>(BorderValues.Thick);
                    bottomBorder.Color = borderColor;

                    var rightBorder = new RightBorder();
                    rightBorder.Val   = new EnumValue <BorderValues>(BorderValues.Thick);
                    rightBorder.Color = borderColor;

                    var leftBorder = new LeftBorder();
                    leftBorder.Val   = new EnumValue <BorderValues>(BorderValues.Thick);
                    leftBorder.Color = borderColor;

                    var insideHorizontalBorder = new InsideHorizontalBorder();
                    insideHorizontalBorder.Val   = new EnumValue <BorderValues>(BorderValues.Thick);
                    insideHorizontalBorder.Color = borderColor;

                    var insideVerticalBorder = new InsideVerticalBorder();
                    insideVerticalBorder.Val   = new EnumValue <BorderValues>(BorderValues.Thick);
                    insideVerticalBorder.Color = borderColor;

                    tableBorders.AppendChild(topBorder);
                    tableBorders.AppendChild(bottomBorder);
                    tableBorders.AppendChild(rightBorder);
                    tableBorders.AppendChild(leftBorder);
                    tableBorders.AppendChild(insideHorizontalBorder);
                    tableBorders.AppendChild(insideVerticalBorder);

                    tableProperties.Append(tableWidth);
                    tableProperties.AppendChild(tableBorders);

                    table.AppendChild(tableProperties);

                    //////////

                    var row1        = new TableRow();
                    var cell11      = new TableCell();
                    var paragraph11 = new Paragraph(new Run(new Text("Luis")));

                    cell11.Append(paragraph11);
                    row1.Append(cell11);
                    /////

                    var cell12          = new TableCell();
                    var paragraph12     = new Paragraph();
                    var run12           = new Run();
                    var runProperties12 = new RunProperties();
                    runProperties12.Bold = new Bold();

                    run12.Append(runProperties12);
                    run12.Append(new Text("400"));
                    paragraph12.Append(run12);
                    cell12.Append(paragraph12);
                    row1.Append(cell12);
                    /////

                    table.Append(row1);

                    var random = new Random();

                    for (int i = 1; i < 5; i++)
                    {
                        var row = new TableRow();

                        var cell1     = new TableCell();
                        var paragraph = new Paragraph(new Run(new Text($"Employee {i}")));
                        cell1.Append(paragraph);

                        var cell2                = new TableCell();
                        var paragraph2           = new Paragraph();
                        var paragraphProperties2 = new ParagraphProperties();
                        paragraphProperties2.Justification = new Justification()
                        {
                            Val = JustificationValues.Center
                        };
                        paragraph2.Append(paragraphProperties2);
                        paragraph2.Append(new Run(new Text(random.Next(100, 500).ToString())));
                        cell2.Append(paragraph2);

                        row.Append(cell1);
                        row.Append(cell2);

                        table.Append(row);
                    }

                    body.Append(table);

                    document.Append(body);
                    wordDocument.MainDocumentPart.Document = document;
                    wordDocument.Close();
                }

                return(File(stream.ToArray(), docxMIMEType,
                            "Word Document Table Example.docx"));
            }
        }
Example #22
0
        IEnumerable <OpenXmlElement> Span2Elements(MarkdownSpan md, bool nestedSpan = false)
        {
            reporter.CurrentSpan = md;
            if (md.IsLiteral)
            {
                var mdl = md as MarkdownSpan.Literal;
                var s   = MarkdownUtilities.UnescapeLiteral(mdl);
                foreach (var r in Literal2Elements(s, nestedSpan))
                {
                    yield return(r);
                }
            }

            else if (md.IsStrong || md.IsEmphasis)
            {
                IEnumerable <MarkdownSpan> spans = (md.IsStrong ? (md as MarkdownSpan.Strong).body : (md as MarkdownSpan.Emphasis).body);

                // Workaround for https://github.com/tpetricek/FSharp.formatting/issues/389 - the markdown parser
                // turns *this_is_it* into a nested Emphasis["this", Emphasis["is"], "it"] instead of Emphasis["this_is_it"]
                // What we'll do is preprocess it into Emphasis["this_is_it"]
                if (md.IsEmphasis)
                {
                    var spans2 = spans.Select(s =>
                    {
                        var _ = "";
                        if (s.IsEmphasis)
                        {
                            s = (s as MarkdownSpan.Emphasis).body.Single();
                            _ = "_";
                        }
                        if (s.IsLiteral)
                        {
                            return(_ + (s as MarkdownSpan.Literal).text + _);
                        }

                        reporter.Error("MD15", $"something odd inside emphasis '{s.GetType().Name}' - only allowed emphasis and literal"); return("");
                    });
                    spans = new List <MarkdownSpan>()
                    {
                        MarkdownSpan.NewLiteral(string.Join("", spans2), FSharpOption <MarkdownRange> .None)
                    };
                }

                // Convention is that ***term*** is used to define a term.
                // That's parsed as Strong, which contains Emphasis, which contains one Literal
                string  literal = null;
                TermRef termdef = null;
                if (!nestedSpan && md.IsStrong && spans.Count() == 1 && spans.First().IsEmphasis)
                {
                    var spans2 = (spans.First() as MarkdownSpan.Emphasis).body;
                    if (spans2.Count() == 1 && spans2.First().IsLiteral)
                    {
                        literal = (spans2.First() as MarkdownSpan.Literal).text;
                        termdef = new TermRef(literal, reporter.Location);
                        if (context.Terms.ContainsKey(literal))
                        {
                            var def = context.Terms[literal];
                            reporter.Warning("MD16", $"Term '{literal}' defined a second time");
                            reporter.Warning("MD16b", $"Here was the previous definition of term '{literal}'", def.Loc);
                        }
                        else
                        {
                            context.Terms.Add(literal, termdef);
                            context.TermKeys.Clear();
                        }
                    }
                }

                // Convention inside our specs is that emphasis only ever contains literals,
                // either to emphasis some human-text or to refer to an ANTLR-production
                ProductionRef prodref = null;
                if (!nestedSpan && md.IsEmphasis && (spans.Count() != 1 || !spans.First().IsLiteral))
                {
                    reporter.Error("MD17", $"something odd inside emphasis");
                }

                if (!nestedSpan && md.IsEmphasis && spans.Count() == 1 && spans.First().IsLiteral)
                {
                    literal = (spans.First() as MarkdownSpan.Literal).text;
                    prodref = productions.FirstOrDefault(pr => pr.Names.Contains(literal));
                    context.Italics.Add(new ItalicUse(literal, prodref != null ? ItalicUse.ItalicUseKind.Production : ItalicUse.ItalicUseKind.Italic, reporter.Location));
                }

                if (prodref != null)
                {
                    var props = new RunProperties(new Color {
                        Val = "6A5ACD"
                    }, new Underline {
                        Val = UnderlineValues.Single
                    });
                    var run = new Run(new Text(literal)
                    {
                        Space = SpaceProcessingModeValues.Preserve
                    })
                    {
                        RunProperties = props
                    };
                    var link = new Hyperlink(run)
                    {
                        Anchor = prodref.BookmarkName
                    };
                    yield return(link);
                }
                else if (termdef != null)
                {
                    context.MaxBookmarkId.Value += 1;
                    yield return(new BookmarkStart {
                        Name = termdef.BookmarkName, Id = context.MaxBookmarkId.Value.ToString()
                    });

                    var props = new RunProperties(new Italic(), new Bold());
                    yield return(new Run(new Text(literal)
                    {
                        Space = SpaceProcessingModeValues.Preserve
                    })
                    {
                        RunProperties = props
                    });

                    yield return(new BookmarkEnd {
                        Id = context.MaxBookmarkId.Value.ToString()
                    });
                }
                else
                {
                    foreach (var e in Spans2Elements(spans, true))
                    {
                        var style = (md.IsStrong ? new Bold() as OpenXmlElement : new Italic());
                        var run   = e as Run;
                        if (run != null)
                        {
                            run.InsertAt(new RunProperties(style), 0);
                        }

                        yield return(e);
                    }
                }
            }

            else if (md.IsInlineCode)
            {
                var mdi  = md as MarkdownSpan.InlineCode;
                var code = mdi.code;

                var txt = new Text(BugWorkaroundDecode(code))
                {
                    Space = SpaceProcessingModeValues.Preserve
                };
                var props = new RunProperties(new RunStyle {
                    Val = "CodeEmbedded"
                });
                var run = new Run(txt)
                {
                    RunProperties = props
                };
                yield return(run);
            }

            else if (md.IsLatexInlineMath)
            {
                var latex = md as MarkdownSpan.LatexInlineMath;
                var code  = latex.code;

                // TODO: Make this look nice - if we actually need it. It's possible that it's only present
                // before subscripts are replaced.
                var txt = new Text(BugWorkaroundDecode(code))
                {
                    Space = SpaceProcessingModeValues.Preserve
                };
                var props = new RunProperties(new RunStyle {
                    Val = "CodeEmbedded"
                });
                var run = new Run(txt)
                {
                    RunProperties = props
                };
                yield return(run);
            }

            else if (md.IsDirectLink || md.IsIndirectLink)
            {
                IEnumerable <MarkdownSpan> spans;
                string url = "", alt = "";
                if (md.IsDirectLink)
                {
                    var mddl = md as MarkdownSpan.DirectLink;
                    spans = mddl.body;
                    url   = mddl.link;
                    alt   = mddl.title.Option();
                }
                else
                {
                    var mdil     = md as MarkdownSpan.IndirectLink;
                    var original = mdil.original;
                    var id       = mdil.key;
                    spans = mdil.body;
                    if (markdownDocument.DefinedLinks.ContainsKey(id))
                    {
                        url = markdownDocument.DefinedLinks[id].Item1;
                        alt = markdownDocument.DefinedLinks[id].Item2.Option();
                    }
                }

                var anchor = "";
                if (spans.Count() == 1 && spans.First().IsLiteral)
                {
                    anchor = MarkdownUtilities.UnescapeLiteral(spans.First() as MarkdownSpan.Literal);
                }
                else if (spans.Count() == 1 && spans.First().IsInlineCode)
                {
                    anchor = (spans.First() as MarkdownSpan.InlineCode).code;
                }
                else
                {
                    reporter.Error("MD18", $"Link anchor must be Literal or InlineCode, not '{md.GetType().Name}'");
                    yield break;
                }

                if (sections.ContainsKey(url))
                {
                    var section = sections[url];
                    // If we're linking to something with a section number, we know what the link text should be.
                    // (There are a few links that aren't to numbered sections, e.g. to "Annex C".)
                    if (section.Number is object)
                    {
                        var expectedAnchor = "§" + section.Number;
                        if (anchor != expectedAnchor)
                        {
                            reporter.Warning("MD19", $"Mismatch: link anchor is '{anchor}', should be '{expectedAnchor}'");
                        }
                    }

                    var txt = new Text(anchor)
                    {
                        Space = SpaceProcessingModeValues.Preserve
                    };
                    var run = new Hyperlink(new Run(txt))
                    {
                        Anchor = section.BookmarkName
                    };
                    yield return(run);
                }
                else if (url.StartsWith("http:") || url.StartsWith("https:"))
                {
                    var style = new RunStyle {
                        Val = "Hyperlink"
                    };
                    var hyperlink = new Hyperlink {
                        DocLocation = url, Tooltip = alt
                    };
                    foreach (var element in Spans2Elements(spans))
                    {
                        var run = element as Run;
                        if (run != null)
                        {
                            run.InsertAt(new RunProperties(style), 0);
                        }

                        hyperlink.AppendChild(run);
                    }
                    yield return(hyperlink);
                }
                else
                {
                    // TODO: Make this report an error unconditionally once the subscript "latex-like" Markdown is removed.
                    if (url != "")
                    {
                        reporter.Error("MD28", $"Hyperlink url '{url}' unrecognized - not a recognized heading, and not http");
                    }
                }
            }

            else if (md.IsHardLineBreak)
            {
                // I've only ever seen this arise from dodgy markdown parsing, so I'll ignore it...
            }

            else
            {
                reporter.Error("MD20", $"Unrecognized markdown element {md.GetType().Name}");
                yield return(new Run(new Text($"[{md.GetType().Name}]")));
            }
        }
Example #23
0
        IEnumerable <OpenXmlCompositeElement> Paragraph2Paragraphs(MarkdownParagraph md)
        {
            reporter.CurrentParagraph = md;
            if (md.IsHeading)
            {
                var mdh   = md as MarkdownParagraph.Heading;
                var level = mdh.size;
                var spans = mdh.body;
                var sr    = sections[new SectionRef(mdh, filename).Url];
                reporter.CurrentSection = sr;
                var properties = new List <OpenXmlElement>
                {
                    new ParagraphStyleId {
                        Val = $"Heading{level}"
                    }
                };
                if (sr.Number is null)
                {
                    properties.Add(new NumberingProperties(new NumberingLevelReference {
                        Val = 0
                    }, new NumberingId {
                        Val = 0
                    }));
                }
                var props = new ParagraphProperties(properties);
                var p     = new Paragraph {
                    ParagraphProperties = props
                };
                context.MaxBookmarkId.Value += 1;
                p.AppendChild(new BookmarkStart {
                    Name = sr.BookmarkName, Id = context.MaxBookmarkId.Value.ToString()
                });
                p.Append(Span2Elements(MarkdownSpan.NewLiteral(sr.TitleWithoutNumber, FSharpOption <MarkdownRange> .None)));
                p.AppendChild(new BookmarkEnd {
                    Id = context.MaxBookmarkId.Value.ToString()
                });
                yield return(p);

                var    i = sr.Url.IndexOf("#");
                string currentSection = $"{sr.Url.Substring(0, i)} {new string('#', level)} {sr.Title} [{sr.Number}]";
                reporter.Log(currentSection);
                yield break;
            }

            else if (md.IsParagraph)
            {
                var mdp   = md as MarkdownParagraph.Paragraph;
                var spans = mdp.body;
                yield return(new Paragraph(Spans2Elements(spans)));

                yield break;
            }

            else if (md.IsQuotedBlock)
            {
                var mdq = md as MarkdownParagraph.QuotedBlock;
                // TODO: Actually make this a block quote.
                // See https://github.com/ECMA-TC49-TG2/conversion-to-markdown/issues/123
                foreach (var paragraph in mdq.paragraphs.SelectMany(Paragraph2Paragraphs))
                {
                    yield return(paragraph);
                }
                yield break;
            }

            else if (md.IsListBlock)
            {
                var mdl  = md as MarkdownParagraph.ListBlock;
                var flat = FlattenList(mdl);

                // Let's figure out what kind of list it is - ordered or unordered? nested?
                var format0 = new[] { "1", "1", "1", "1" };
                foreach (var item in flat)
                {
                    format0[item.Level] = (item.IsBulletOrdered ? "1" : "o");
                }

                var format = string.Join("", format0);

                var numberingPart = wordDocument.MainDocumentPart.NumberingDefinitionsPart ?? wordDocument.MainDocumentPart.AddNewPart <NumberingDefinitionsPart>("NumberingDefinitionsPart001");
                if (numberingPart.Numbering == null)
                {
                    numberingPart.Numbering = new Numbering();
                }

                Func <int, bool, Level> createLevel;
                createLevel = (level, isOrdered) =>
                {
                    var numformat = NumberFormatValues.Bullet;
                    var levelText = new[] { "·", "o", "·", "o" }[level];
                    if (isOrdered && level == 0)
                    {
                        numformat = NumberFormatValues.Decimal; levelText = "%1.";
                    }
                    if (isOrdered && level == 1)
                    {
                        numformat = NumberFormatValues.LowerLetter; levelText = "%2.";
                    }
                    if (isOrdered && level == 2)
                    {
                        numformat = NumberFormatValues.LowerRoman; levelText = "%3.";
                    }
                    if (isOrdered && level == 3)
                    {
                        numformat = NumberFormatValues.LowerRoman; levelText = "%4.";
                    }
                    var r = new Level {
                        LevelIndex = level
                    };
                    r.Append(new StartNumberingValue {
                        Val = 1
                    });
                    r.Append(new NumberingFormat {
                        Val = numformat
                    });
                    r.Append(new LevelText {
                        Val = levelText
                    });
                    r.Append(new ParagraphProperties(new Indentation {
                        Left = (540 + 360 * level).ToString(), Hanging = "360"
                    }));
                    if (levelText == "·")
                    {
                        r.Append(new NumberingSymbolRunProperties(new RunFonts {
                            Hint = FontTypeHintValues.Default, Ascii = "Symbol", HighAnsi = "Symbol", EastAsia = "Times new Roman", ComplexScript = "Times new Roman"
                        }));
                    }

                    if (levelText == "o")
                    {
                        r.Append(new NumberingSymbolRunProperties(new RunFonts {
                            Hint = FontTypeHintValues.Default, Ascii = "Courier New", HighAnsi = "Courier New", ComplexScript = "Courier New"
                        }));
                    }

                    return(r);
                };
                var level0 = createLevel(0, format[0] == '1');
                var level1 = createLevel(1, format[1] == '1');
                var level2 = createLevel(2, format[2] == '1');
                var level3 = createLevel(3, format[3] == '1');

                var abstracts = numberingPart.Numbering.OfType <AbstractNum>().Select(an => an.AbstractNumberId.Value).ToList();
                var aid       = (abstracts.Count == 0 ? 1 : abstracts.Max() + 1);
                var aabstract = new AbstractNum(new MultiLevelType()
                {
                    Val = MultiLevelValues.Multilevel
                }, level0, level1, level2, level3)
                {
                    AbstractNumberId = aid
                };
                numberingPart.Numbering.InsertAt(aabstract, 0);

                var instances   = numberingPart.Numbering.OfType <NumberingInstance>().Select(ni => ni.NumberID.Value);
                var nid         = (instances.Count() == 0 ? 1 : instances.Max() + 1);
                var numInstance = new NumberingInstance(new AbstractNumId {
                    Val = aid
                })
                {
                    NumberID = nid
                };
                numberingPart.Numbering.AppendChild(numInstance);

                // We'll also figure out the indentation(for the benefit of those paragraphs that should be
                // indendent with the list but aren't numbered). I'm not sure what the indent comes from.
                // in the docx, each AbstractNum that I created has an indent for each of its levels,
                // defaulted at 900, 1260, 1620, ... but I can't see where in the above code that's created?
                Func <int, string> calcIndent = level => (540 + level * 360).ToString();

                foreach (var item in flat)
                {
                    var content = item.Paragraph;
                    if (content.IsParagraph || content.IsSpan)
                    {
                        var spans = (content.IsParagraph ? (content as MarkdownParagraph.Paragraph).body : (content as MarkdownParagraph.Span).body);
                        if (item.HasBullet)
                        {
                            yield return(new Paragraph(Spans2Elements(spans))
                            {
                                ParagraphProperties = new ParagraphProperties(new NumberingProperties(new ParagraphStyleId {
                                    Val = "ListParagraph"
                                }, new NumberingLevelReference {
                                    Val = item.Level
                                }, new NumberingId {
                                    Val = nid
                                }))
                            });
                        }
                        else
                        {
                            yield return(new Paragraph(Spans2Elements(spans))
                            {
                                ParagraphProperties = new ParagraphProperties(new Indentation {
                                    Left = calcIndent(item.Level)
                                })
                            });
                        }
                    }
                    else if (content.IsQuotedBlock || content.IsCodeBlock)
                    {
                        foreach (var p in Paragraph2Paragraphs(content))
                        {
                            var props = p.GetFirstChild <ParagraphProperties>();
                            if (props == null)
                            {
                                props = new ParagraphProperties();
                                p.InsertAt(props, 0);
                            }
                            var indent = props?.GetFirstChild <Indentation>();
                            if (indent == null)
                            {
                                indent = new Indentation();
                                props.Append(indent);
                            }
                            indent.Left = calcIndent(item.Level);
                            yield return(p);
                        }
                    }
                    else if (content.IsTableBlock)
                    {
                        foreach (var p in Paragraph2Paragraphs(content))
                        {
                            var table = p as Table;
                            if (table == null)
                            {
                                yield return(p);

                                continue;
                            }
                            var tprops  = table.GetFirstChild <TableProperties>();
                            var tindent = tprops?.GetFirstChild <TableIndentation>();
                            if (tindent == null)
                            {
                                throw new Exception("Ooops! Table is missing indentation");
                            }

                            tindent.Width = int.Parse(calcIndent(item.Level));
                            yield return(table);
                        }
                    }
                    else
                    {
                        reporter.Error("MD08", $"Unexpected item in list '{content.GetType().Name}'");
                    }
                }
            }

            else if (md.IsCodeBlock)
            {
                var mdc  = md as MarkdownParagraph.CodeBlock;
                var code = mdc.code;
                var lang = mdc.language;
                code = BugWorkaroundDecode(code);
                var runs        = new List <Run>();
                var onFirstLine = true;
                IEnumerable <ColorizedLine> lines;
                switch (lang)
                {
                case "csharp":
                case "c#":
                case "cs":
                    lines = Colorize.CSharp(code);
                    break;

                case "vb":
                case "vbnet":
                case "vb.net":
                    lines = Colorize.VB(code);
                    break;

                case "":
                case "console":
                case "xml":
                    lines = Colorize.PlainText(code);
                    break;

                case "ANTLR":
                case "antlr":
                    lines = Antlr.ColorizeAntlr(code);
                    break;

                default:
                    reporter.Error("MD09", $"unrecognized language {lang}");
                    lines = Colorize.PlainText(code);
                    break;
                }

                foreach (var line in lines)
                {
                    if (onFirstLine)
                    {
                        onFirstLine = false;
                    }
                    else
                    {
                        runs.Add(new Run(new Break()));
                    }

                    foreach (var word in line.Words)
                    {
                        var run   = new Run();
                        var props = new RunProperties();
                        if (word.Red != 0 || word.Green != 0 || word.Blue != 0)
                        {
                            props.Append(new Color {
                                Val = $"{word.Red:X2}{word.Green:X2}{word.Blue:X2}"
                            });
                        }

                        if (word.IsItalic)
                        {
                            props.Append(new Italic());
                        }

                        if (props.HasChildren)
                        {
                            run.Append(props);
                        }

                        run.Append(new Text(word.Text)
                        {
                            Space = SpaceProcessingModeValues.Preserve
                        });
                        runs.Add(run);
                    }
                }
                if (lang == "antlr")
                {
                    var p = new Paragraph()
                    {
                        ParagraphProperties = new ParagraphProperties(new ParagraphStyleId {
                            Val = "Grammar"
                        })
                    };
                    var prodref = productions.Single(prod => prod.Code == code);
                    context.MaxBookmarkId.Value += 1;
                    p.AppendChild(new BookmarkStart {
                        Name = prodref.BookmarkName, Id = context.MaxBookmarkId.Value.ToString()
                    });
                    p.Append(runs);
                    p.AppendChild(new BookmarkEnd {
                        Id = context.MaxBookmarkId.Value.ToString()
                    });
                    yield return(p);
                }
                else
                {
                    var p = new Paragraph()
                    {
                        ParagraphProperties = new ParagraphProperties(new ParagraphStyleId {
                            Val = "Code"
                        })
                    };
                    p.Append(runs);
                    yield return(p);
                }
            }

            else if (md.IsTableBlock)
            {
                var mdt    = md as MarkdownParagraph.TableBlock;
                var header = mdt.headers.Option();
                var align  = mdt.alignments;
                var rows   = mdt.rows;
                var table  = new Table();
                if (header == null)
                {
                    reporter.Error("MD10", "Github requires all tables to have header rows");
                }

                if (!header.Any(cell => cell.Length > 0))
                {
                    header = null; // even if Github requires an empty header, we can at least cull it from Docx
                }

                var tstyle = new TableStyle {
                    Val = "TableGrid"
                };
                var tindent = new TableIndentation {
                    Width = 360, Type = TableWidthUnitValues.Dxa
                };
                var tborders = new TableBorders();
                tborders.TopBorder = new TopBorder {
                    Val = BorderValues.Single
                };
                tborders.BottomBorder = new BottomBorder {
                    Val = BorderValues.Single
                };
                tborders.LeftBorder = new LeftBorder {
                    Val = BorderValues.Single
                };
                tborders.RightBorder = new RightBorder {
                    Val = BorderValues.Single
                };
                tborders.InsideHorizontalBorder = new InsideHorizontalBorder {
                    Val = BorderValues.Single
                };
                tborders.InsideVerticalBorder = new InsideVerticalBorder {
                    Val = BorderValues.Single
                };
                var tcellmar = new TableCellMarginDefault();
                tcellmar.Append();
                table.Append(new TableProperties(tstyle, tindent, tborders));
                var ncols = align.Length;
                for (int irow = -1; irow < rows.Length; irow++)
                {
                    if (irow == -1 && header == null)
                    {
                        continue;
                    }

                    var mdrow = (irow == -1 ? header : rows[irow]);
                    var row   = new TableRow();
                    for (int icol = 0; icol < Math.Min(ncols, mdrow.Length); icol++)
                    {
                        var mdcell = mdrow[icol];
                        var cell   = new TableCell();
                        var pars   = Paragraphs2Paragraphs(mdcell).ToList();
                        for (int ip = 0; ip < pars.Count; ip++)
                        {
                            var p = pars[ip] as Paragraph;
                            if (p == null)
                            {
                                cell.Append(pars[ip]);
                                continue;
                            }
                            var props = new ParagraphProperties(new ParagraphStyleId {
                                Val = "TableCellNormal"
                            });
                            if (align[icol].IsAlignCenter)
                            {
                                props.Append(new Justification {
                                    Val = JustificationValues.Center
                                });
                            }

                            if (align[icol].IsAlignRight)
                            {
                                props.Append(new Justification {
                                    Val = JustificationValues.Right
                                });
                            }

                            p.InsertAt(props, 0);
                            cell.Append(pars[ip]);
                        }
                        if (pars.Count == 0)
                        {
                            cell.Append(new Paragraph(new ParagraphProperties(new SpacingBetweenLines {
                                After = "0"
                            }), new Run(new Text(""))));
                        }

                        row.Append(cell);
                    }
                    table.Append(row);
                }
                yield return(new Paragraph(new Run(new Text("")))
                {
                    ParagraphProperties = new ParagraphProperties(new ParagraphStyleId {
                        Val = "TableLineBefore"
                    })
                });

                yield return(table);

                yield return(new Paragraph(new Run(new Text("")))
                {
                    ParagraphProperties = new ParagraphProperties(new ParagraphStyleId {
                        Val = "TableLineAfter"
                    })
                });
            }
            else
            {
                reporter.Error("MD11", $"Unrecognized markdown element {md.GetType().Name}");
                yield return(new Paragraph(new Run(new Text($"[{md.GetType().Name}]"))));
            }
        }
 public PlatformRunProperties(RunProperties run)
     : base(run)
 {
     this.xmlElement = run;
 }
Example #25
0
    public void ProcessRequest(System.Data.DataTable dt, string docFileName)
    {
        {
            using (MemoryStream mem = new MemoryStream())
            {
                using (WordprocessingDocument doc = WordprocessingDocument.Create(mem, WordprocessingDocumentType.Document, true))
                {
                    MainDocumentPart     mainPart  = doc.AddMainDocumentPart();
                    StyleDefinitionsPart stylePart = mainPart.AddNewPart <StyleDefinitionsPart>();

                    RunProperties rPrNormal = new RunProperties();
                    RunFonts      rFont1    = new RunFonts();
                    rPrNormal.Append(new DocumentFormat.OpenXml.Wordprocessing.FontSize()
                    {
                        Val = "24"
                    });
                    DocumentFormat.OpenXml.Wordprocessing.Style style1 = new DocumentFormat.OpenXml.Wordprocessing.Style();
                    style1.StyleId = "myText";
                    style1.Append(new Name()
                    {
                        Val = "text"
                    });
                    style1.Append(rPrNormal);
                    stylePart.Styles = new Styles();
                    stylePart.Styles.Append(style1);

                    RunProperties rPr   = new RunProperties();
                    Color         color = new Color()
                    {
                        Val = "FF0000"
                    };
                    RunFonts rFont = new RunFonts();
                    //rFont.Ascii = "Times New Roman";
                    //rPr.Append(color);
                    //rPr.Append(rFont);
                    rPr.Append(new Bold());
                    rPr.Append(new DocumentFormat.OpenXml.Wordprocessing.FontSize()
                    {
                        Val = "24"
                    });
                    DocumentFormat.OpenXml.Wordprocessing.Style style = new DocumentFormat.OpenXml.Wordprocessing.Style();
                    style.StyleId = "myHeading1";
                    style.Append(new Name()
                    {
                        Val = "My Heading 1"
                    });
                    style.Append(new NextParagraphStyle()
                    {
                        Val = "Normal"
                    });
                    style.Append(rPr);
                    stylePart.Styles = new Styles();
                    stylePart.Styles.Append(style);
                    stylePart.Styles.Save();

                    mainPart.Document = new DocumentFormat.OpenXml.Wordprocessing.Document();

                    Body body = mainPart.Document.AppendChild(new Body());


                    ParagraphProperties pptemp        = new ParagraphProperties();
                    Paragraph           template      = body.AppendChild(new Paragraph());
                    Justification       templatealign = new Justification()
                    {
                        Val = JustificationValues.Center
                    };
                    pptemp.Append(templatealign);
                    template.Append(pptemp);
                    Run runtemp = template.AppendChild(new Run());
                    if (dt.Rows[0][17].ToString() == "Annual")
                    {
                        runtemp.AppendChild(new Text("Template B"));
                    }
                    else if (dt.Rows[0][17].ToString() == "Upfront Payment")
                    {
                        runtemp.AppendChild(new Text("Template A"));
                    }
                    else if (dt.Rows[0][17].ToString() == "Royalty" && dt.Rows[0][8].ToString() != "&nbsp;")
                    {
                        runtemp.AppendChild(new Text("Template D2"));
                    }
                    else if (dt.Rows[0][17].ToString() == "Royalty" && dt.Rows[0][8].ToString() == "&nbsp;")
                    {
                        runtemp.AppendChild(new Text("Template D1"));
                    }

                    ParagraphProperties ppDate    = new ParagraphProperties();
                    Paragraph           paraDate  = body.AppendChild(new Paragraph());
                    Justification       dateAlign = new Justification()
                    {
                        Val = JustificationValues.Right
                    };
                    ppDate.Append(dateAlign);
                    paraDate.Append(ppDate);
                    Run runDate = paraDate.AppendChild(new Run());
                    runDate.AppendChild(new Text("Date : " + DateTime.Now.ToShortDateString()));

                    ParagraphProperties Normal_pPr = new ParagraphProperties(new ParagraphStyleId()
                    {
                        Val = "myText"
                    });

                    Paragraph paraTo = body.AppendChild(new Paragraph());
                    Run       runTo  = paraTo.AppendChild(new Run());
                    runTo.AppendChild(new Text("To"));
                    runTo.AppendChild(new Break());
                    runTo.AppendChild(new Break());
                    if (dt.Rows[0][8].ToString() != "&nbsp;")
                    {
                        runTo.AppendChild(new Text("Project Accounts"));
                        runTo.AppendChild(new Break());
                        runTo.AppendChild(new Text("ICSR"));
                    }
                    else
                    {
                        //Paragraph tocustdet = body.AppendChild(new Paragraph());
                        //Run runtodetails = tocustdet.AppendChild(new Run());
                        //Justification center1 = new Justification() { Val = JustificationValues.Center };
                        //runtodetails.AppendChild(center1);
                        runTo.AppendChild(new Text(dt.Rows[0][10].ToString()));
                        runTo.AppendChild(new Break());
                        runTo.AppendChild(new Text(dt.Rows[0][11].ToString()));
                        runTo.AppendChild(new Break());
                        runTo.AppendChild(new Text(dt.Rows[0][12].ToString()));
                        runTo.AppendChild(new Break());
                        runTo.AppendChild(new Text(dt.Rows[0][13].ToString()));
                        runTo.AppendChild(new Break());
                        runTo.AppendChild(new Text(dt.Rows[0][14].ToString()));
                        runTo.AppendChild(new Break());
                        runTo.AppendChild(new Text(dt.Rows[0][15].ToString()));
                        runTo.AppendChild(new Break());
                        runTo.AppendChild(new Text(dt.Rows[0][16].ToString()));
                    }
                    runTo.AppendChild(new Break());

                    Paragraph           paraTitle   = body.AppendChild(new Paragraph());
                    ParagraphProperties heading_pPr = new ParagraphProperties();
                    heading_pPr.ParagraphStyleId = new ParagraphStyleId()
                    {
                        Val = "myHeading1"
                    };
                    paraTitle.Append(heading_pPr);
                    Run           runTitle = paraTitle.AppendChild(new Run());
                    RunProperties rpTitle  = new RunProperties(new Underline()
                    {
                        Val = UnderlineValues.Single
                    });
                    runTitle.Append(rpTitle);
                    if ((dt.Rows[0][17].ToString() == "Upfront Payment" || dt.Rows[0][17].ToString() == "Annual") && dt.Rows[0][8].ToString() != "&nbsp;")
                    {
                        runTitle.AppendChild(new Text("Sub : Raising of Invoice"));
                    }
                    else if (dt.Rows[0][17].ToString() == "Royalty" && dt.Rows[0][8].ToString() == "&nbsp;")
                    {
                        runTitle.AppendChild(new Text("Sub : Royalty Dues : Declaration"));
                        Paragraph subdetail    = body.AppendChild(new Paragraph());
                        Run       runsubdetail = subdetail.AppendChild(new Run());
                        runsubdetail.AppendChild(new Text("Dear Sir / Madam,"));
                        runsubdetail.AppendChild(new Text("Reference Agreement as per details below a royalty payment is due."));
                    }
                    else if (dt.Rows[0][17].ToString() == "Royalty" && dt.Rows[0][8].ToString() != "&nbsp;")
                    {
                        runTitle.AppendChild(new Text("Sub : Raising of Invoice [Royalty Payments]"));
                    }
                    else if (dt.Rows[0][17].ToString() == "Reimbursement" && dt.Rows[0][8].ToString() != "&nbsp;")
                    {
                        runTitle.AppendChild(new Text("Sub:Raising of Invoice [Reimbursement of costs]"));
                    }
                    else if (dt.Rows[0][17].ToString() == "Reimbursement" && dt.Rows[0][8].ToString() == "&nbsp;")
                    {
                        runTitle.AppendChild(new Text("Sub : Reimbursements of costs"));
                        Paragraph subdetail    = body.AppendChild(new Paragraph());
                        Run       runsubdetail = subdetail.AppendChild(new Run());
                        runsubdetail.AppendChild(new Text("Dear Sir / Madam,"));
                        runsubdetail.AppendChild(new Text("Reference Agreement as per details below,reimbursement of costs are due."));
                    }

                    // Create an empty table.
                    Table table = new Table();

                    // Create a TableProperties object and specify its border information.
                    TableProperties tblProp = new TableProperties(
                        new TableBorders(
                            new TopBorder()
                    {
                        Val  = new EnumValue <BorderValues>(BorderValues.Single),
                        Size = 10
                    },
                            new BottomBorder()
                    {
                        Val  = new EnumValue <BorderValues>(BorderValues.Single),
                        Size = 10
                    },
                            new LeftBorder()
                    {
                        Val  = new EnumValue <BorderValues>(BorderValues.Single),
                        Size = 10
                    },
                            new RightBorder()
                    {
                        Val  = new EnumValue <BorderValues>(BorderValues.Single),
                        Size = 10
                    },
                            new InsideHorizontalBorder()
                    {
                        Val  = new EnumValue <BorderValues>(BorderValues.Single),
                        Size = 10
                    },
                            new InsideVerticalBorder()
                    {
                        Val  = new EnumValue <BorderValues>(BorderValues.Single),
                        Size = 10
                    }
                            )
                        );

                    // Append the TableProperties object to the empty table.
                    table.AppendChild <TableProperties>(tblProp);
                    table.Append(new TableProperties(new TableWidth()
                    {
                        Type = TableWidthUnitValues.Pct, Width = "100%"
                    }));

                    TableRow tr = new TableRow();
                    //tr.Append(new TableRowProperties(new TableWidth() { Type = TableWidthUnitValues.Pct, Width = "100%" }));
                    TableCell tc1 = new TableCell();
                    // Specify the width property of the table cell.
                    //tc1.Append(new TableCellProperties(
                    //    new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
                    // Specify the table cell content.
                    tc1.Append(new Paragraph(new Run(new Text(dt.Rows[0][0].ToString()))));
                    // Append the table cell to the table row.
                    tr.Append(tc1);
                    TableCell tc2 = new TableCell();
                    tc2.Append(new Paragraph(new Run(new Text("Agreement No: " + dt.Rows[0][1]))));
                    tr.Append(tc2);
                    TableCell tc3 = new TableCell();
                    tc3.Append(new Paragraph(new Run(new Text("TT A/c: " + dt.Rows[0][2]))));
                    tr.Append(tc3);

                    TableCellProperties tcp    = new TableCellProperties();
                    HorizontalMerge     vMerge = new HorizontalMerge()
                    {
                        Val = MergedCellValues.Restart
                    };
                    tcp.Append(vMerge);

                    TableCellProperties tcp1    = new TableCellProperties();
                    HorizontalMerge     vMerge1 = new HorizontalMerge()
                    {
                        Val = MergedCellValues.Continue
                    };
                    tcp1.Append(vMerge1);

                    TableRow  tr1  = new TableRow();
                    TableCell tcr1 = new TableCell();
                    tcr1.Append(new Paragraph(new Run(new Text("Title:" + dt.Rows[0][3]))));
                    tcr1.Append(tcp);
                    tr1.Append(tcr1);

                    TableCell tc2r1 = new TableCell();
                    tc2r1.Append(new Paragraph());
                    tc2r1.Append(tcp1);
                    tr1.Append(tc2r1);
                    TableCell tc3r1 = new TableCell();
                    tc3r1.Append(new Paragraph());
                    TableProperties mergeend = new TableProperties();
                    HorizontalMerge hm1      = new HorizontalMerge()
                    {
                        Val = MergedCellValues.Continue
                    };
                    mergeend.Append(hm1);
                    tc3r1.Append(mergeend);
                    tr1.Append(tc3r1);

                    TableCellProperties tcp2   = new TableCellProperties();
                    HorizontalMerge     hMerge = new HorizontalMerge()
                    {
                        Val = MergedCellValues.Restart
                    };
                    tcp2.Append(hMerge);
                    TableCellProperties tcp3    = new TableCellProperties();
                    HorizontalMerge     hMerge1 = new HorizontalMerge()
                    {
                        Val = MergedCellValues.Continue
                    };
                    tcp3.Append(hMerge1);

                    TableRow  tr2  = new TableRow();
                    TableCell tcr2 = new TableCell();
                    tcr2.Append(new Paragraph(new Run(new Text("Scope: " + dt.Rows[0][4]))));
                    tcr2.Append(tcp2);
                    tr2.Append(tcr2);
                    TableCell tc2r2 = new TableCell();
                    tc2r2.Append(new Paragraph());
                    tc2r2.Append(tcp3);
                    tr2.Append(tc2r2);
                    TableCell tc3r2 = new TableCell();
                    tc3r2.Append(new Paragraph());
                    TableProperties mergeend1 = new TableProperties();
                    HorizontalMerge hm3       = new HorizontalMerge()
                    {
                        Val = MergedCellValues.Continue
                    };
                    mergeend1.Append(hm3);
                    tc3r2.Append(mergeend1);
                    tr2.Append(tc3r2);

                    TableCellProperties tcp4    = new TableCellProperties();
                    HorizontalMerge     hMerge2 = new HorizontalMerge()
                    {
                        Val = MergedCellValues.Restart
                    };
                    tcp4.Append(hMerge2);
                    TableCellProperties tcp5    = new TableCellProperties();
                    HorizontalMerge     hMerge3 = new HorizontalMerge()
                    {
                        Val = MergedCellValues.Continue
                    };
                    tcp5.Append(hMerge3);

                    TableRow  tr3  = new TableRow();
                    TableCell tcr3 = new TableCell();
                    tcr3.Append(new Paragraph(new Run(new Text("Coordinating Person: " + dt.Rows[0][5]))));
                    tcr3.Append(tcp4);
                    tr3.Append(tcr3);
                    TableCell tc2r3 = new TableCell();
                    tc2r3.Append(new Paragraph());
                    tc2r3.Append(tcp5);
                    tr3.Append(tc2r3);
                    TableCell tc3r3 = new TableCell();
                    tc3r3.Append(new Paragraph());
                    TableProperties mergeend2 = new TableProperties();
                    HorizontalMerge hm5       = new HorizontalMerge()
                    {
                        Val = MergedCellValues.Continue
                    };
                    mergeend2.Append(hm5);
                    tc3r3.Append(mergeend2);
                    tr3.Append(tc3r3);

                    TableCellProperties tcp6    = new TableCellProperties();
                    HorizontalMerge     hMerge4 = new HorizontalMerge()
                    {
                        Val = MergedCellValues.Restart
                    };
                    tcp6.Append(hMerge4);
                    TableCellProperties tcp7    = new TableCellProperties();
                    HorizontalMerge     hMerge5 = new HorizontalMerge()
                    {
                        Val = MergedCellValues.Continue
                    };
                    tcp7.Append(hMerge5);

                    TableRow  tr4   = new TableRow();
                    TableCell tc1r4 = new TableCell();
                    tc1r4.Append(new Paragraph(new Run(new Text("Type: " + dt.Rows[0][6]))));
                    tc1r4.Append(tcp6);
                    tr4.Append(tc1r4);
                    TableCell tc2r4 = new TableCell();
                    tc2r4.Append(new Paragraph());
                    tc2r4.Append(tcp7);
                    tr4.Append(tc2r4);
                    TableCell tc3r4 = new TableCell();
                    tc3r4.Append(new Paragraph(new Run(new Text("Dept: " + dt.Rows[0][6]))));
                    tr4.Append(tc3r4);

                    TableCellProperties tcp8    = new TableCellProperties();
                    HorizontalMerge     hMerge6 = new HorizontalMerge()
                    {
                        Val = MergedCellValues.Restart
                    };
                    tcp8.Append(hMerge6);
                    TableCellProperties tcp9    = new TableCellProperties();
                    HorizontalMerge     hMerge7 = new HorizontalMerge()
                    {
                        Val = MergedCellValues.Continue
                    };
                    tcp9.Append(hMerge7);

                    TableRow  tr5   = new TableRow();
                    TableCell tc1r5 = new TableCell();
                    tc1r5.Append(new Paragraph(new Run(new Text("Due Date: " + dt.Rows[0][9]))));
                    tc1r5.Append(tcp8);
                    tr5.Append(tc1r5);
                    TableCell tc2r5 = new TableCell();
                    tc2r5.Append(new Paragraph());
                    tc2r5.Append(tcp9);
                    tr5.Append(tc2r5);
                    TableCell tc3r5 = new TableCell();
                    tc3r5.Append(new Paragraph(new Run(new Text("Amount: " + dt.Rows[0][8]))));
                    tr5.Append(tc3r5);

                    // Append the table row to the table.
                    table.Append(tr);
                    table.Append(tr1);
                    table.Append(tr2);
                    table.Append(tr3);
                    table.Append(tr4);
                    table.Append(tr5);
                    // Append the table to the document.
                    doc.MainDocumentPart.Document.Body.Append(table);

                    if (dt.Rows[0][8].ToString() != "&nbsp;")
                    {
                        Paragraph     customer    = body.AppendChild(new Paragraph());
                        Run           runcustomer = customer.AppendChild(new Run());
                        RunProperties cusprp      = new RunProperties(new Bold(), new Underline()
                        {
                            Val = UnderlineValues.Single
                        });
                        //cusprp.Bold = new Bold();
                        //cusprp.Underline = new Underline();
                        runcustomer.Append(new Break());
                        runcustomer.Append(cusprp);
                        runcustomer.AppendChild(new Text("Customer"));

                        Paragraph     custdet    = body.AppendChild(new Paragraph());
                        Run           rundetails = custdet.AppendChild(new Run());
                        Justification center     = new Justification()
                        {
                            Val = JustificationValues.Center
                        };
                        rundetails.AppendChild(center);
                        rundetails.AppendChild(new Text(dt.Rows[0][10].ToString()));
                        rundetails.AppendChild(new Break());
                        rundetails.AppendChild(new Text(dt.Rows[0][11].ToString()));
                        rundetails.AppendChild(new Break());
                        rundetails.AppendChild(new Text(dt.Rows[0][12].ToString()));
                        rundetails.AppendChild(new Break());
                        rundetails.AppendChild(new Text(dt.Rows[0][13].ToString()));
                        rundetails.AppendChild(new Break());
                        rundetails.AppendChild(new Text(dt.Rows[0][14].ToString()));
                        rundetails.AppendChild(new Break());
                        rundetails.AppendChild(new Text(dt.Rows[0][15].ToString()));
                        rundetails.AppendChild(new Break());
                        rundetails.AppendChild(new Text(dt.Rows[0][16].ToString()));
                    }
                    Paragraph extra    = body.AppendChild(new Paragraph());
                    Run       runextra = extra.AppendChild(new Run());
                    runextra.AppendChild(new Break());
                    if ((dt.Rows[0][17].ToString() == "Upfront Payment" || dt.Rows[0][17].ToString() == "Annual") && dt.Rows[0][8] != null)
                    {
                        runextra.AppendChild(new Text("Other available details are attached. The invoice may be raised for the above."));
                    }
                    else if (dt.Rows[0][17].ToString() == "Royalty" && dt.Rows[0][8].ToString() != "&nbsp;")
                    {
                        runextra.AppendChild(new Text("The declaration of dues and workings has been verified by us. Same is enclosed."));
                        runextra.AppendChild(new Break());
                        runextra.AppendChild(new Text("The invoice may be raised for the above"));
                    }
                    else if (dt.Rows[0][17].ToString() == "Royalty" && dt.Rows[0][8].ToString() == "&nbsp;")
                    {
                        runextra.AppendChild(new Text("Request you to send a declaration along with workings. After verification and confirmation we will raise the invoice"));
                        //runextra.AppendChild(new Text("Working sheets of the dues is enclosed. Request you to verify and confirm"));
                        //runextra.AppendChild(new Break());
                        //runextra.AppendChild(new Text("Invoice will be sent on receipt of confirmation"));
                    }
                    else if (dt.Rows[0][17].ToString() == "Reimbursement" && dt.Rows[0][8].ToString() == "&nbsp;")
                    {
                        runextra.AppendChild(new Text("Working sheet of the dues is enclosed. Request you to verify and confirm."));
                        runextra.AppendChild(new Break());
                        runextra.AppendChild(new Text("Invoice will be sent on receipt of confimation"));
                    }
                    else if (dt.Rows[0][17].ToString() == "Reimbursement" && dt.Rows[0][8].ToString() != "&nbsp;")
                    {
                        runextra.AppendChild(new Text("Working sheet along with customer's confirmation is enclosed"));
                        runextra.AppendChild(new Break());
                        runextra.AppendChild(new Text("The invoice may be raised for the above"));
                    }
                    runextra.AppendChild(new Break());
                    runextra.AppendChild(new Break());
                    runextra.AppendChild(new Text("Thanking You"));
                    runextra.AppendChild(new Break());

                    Paragraph support = body.AppendChild(new Paragraph());
                    Run       runsup  = support.AppendChild(new Run());

                    if (dt.Rows[0][17].ToString() == "Upfront Payment" && dt.Rows[0][8].ToString() != "&nbsp;")
                    {
                        runsup.AppendChild(new Text("Supporting Documents:"));
                        runsup.AppendChild(new Break());
                        runsup.AppendChild(new Text("1. PDF of Agreement -" + dt.Rows[0][0]));
                        runsup.AppendChild(new Break());
                        runsup.AppendChild(new Text("2. Customer Tax & Bank details"));
                    }
                    else if (dt.Rows[0][17].ToString() == "Annual" && dt.Rows[0][8].ToString() != "&nbsp;")
                    {
                        runsup.AppendChild(new Text("Supporting Documents:"));
                        runsup.AppendChild(new Break());
                        runsup.AppendChild(new Text(" 1. Agreement " + dt.Rows[0][0] + " already forwarded"));
                        runsup.AppendChild(new Break());
                        runsup.AppendChild(new Text(" 2. Customer Tax & Bank details are same /change as per enclosure"));
                    }
                    else if (dt.Rows[0][17].ToString() == "Royalty" && dt.Rows[0][8].ToString() != "&nbsp;")
                    {
                        runsup.AppendChild(new Text("Supporting Documents:"));
                        runsup.AppendChild(new Break());
                        runsup.AppendChild(new Text("1. Verified declaration of dues"));
                        runsup.AppendChild(new Break());
                        runsup.AppendChild(new Text("2. Working sheets of the customer"));
                    }
                    else if (dt.Rows[0][17].ToString() == "Reimbursement" && dt.Rows[0][8].ToString() != "&nbsp;")
                    {
                        runsup.AppendChild(new Text("Supporting Documents:"));
                        runsup.AppendChild(new Break());
                        runsup.AppendChild(new Text("1. Confirmation from the customer"));
                        runsup.AppendChild(new Break());
                        runsup.AppendChild(new Text("2. Detailed workings"));
                    }
                    else if (dt.Rows[0][17].ToString() == "Reimbursement" && dt.Rows[0][8].ToString() == "&nbsp;")
                    {
                        runsup.AppendChild(new Text("Enclosure:"));
                        runsup.AppendChild(new Break());
                        runsup.AppendChild(new Text("1. Working document on dues"));
                        runsup.AppendChild(new Break());
                        runsup.AppendChild(new Text("2. Copies of payment invoices"));
                    }
                    runsup.AppendChild(new Break());
                    doc.MainDocumentPart.Document.Save();
                }
                System.Web.HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
                System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + docFileName);
                mem.Seek(0, SeekOrigin.Begin);
                mem.WriteTo(System.Web.HttpContext.Current.Response.OutputStream);
                System.Web.HttpContext.Current.Response.Flush();
                System.Web.HttpContext.Current.Response.End();
            }
        }
    }
Example #26
0
        public static Run CreateRun(string text, bool bold = false, bool italic = false, int?size = null, string style = null, string font = null)
        {
            Run           newRun           = new Run();
            RunProperties newRunProperties = new RunProperties();

            if (bold)
            {
                newRunProperties.Append(new Bold());
            }

            if (italic)
            {
                newRunProperties.Append(new Italic());
            }

            if (!string.IsNullOrEmpty(font))
            {
                newRunProperties.Append(
                    new RunProperties()
                {
                    RunFonts = new RunFonts()
                    {
                        Ascii    = font,
                        HighAnsi = new StringValue(font)
                    }
                });
            }

            if (size != null && size != -1)
            {
                newRunProperties.Append(
                    new FontSize()
                {
                    Val = new StringValue((2 * size).ToString())
                });
            }

            if (!string.IsNullOrEmpty(style))
            {
                newRunProperties.Append(
                    new RunStyle()
                {
                    Val = style
                });
            }

            newRun.Append(newRunProperties);

            if (text != null)
            {
                string[] textSplit = text.Split('\n');

                for (int i = 0; i < textSplit.Length; i++)
                {
                    newRun.Append(
                        new Text(textSplit[i])
                    {
                        Space = SpaceProcessingModeValues.Preserve
                    });

                    if (i < textSplit.Length - 1)
                    {
                        newRun.Append(
                            new Break());
                    }
                }
            }

            return(newRun);
        }
Example #27
0
        public static void GentText(Dictionary <string, string> dict, List <List <string> > List1, string path2, string path3)
        {
            List <string> Tables  = new List <string>();
            int           flazhok = 0;
            int           fcount  = 0;
            int           k       = 0;

            byte[]        byteArray = File.ReadAllBytes(path3);
            List <string> M         = new List <string>();
            int           u         = 0;
            int           m         = 0;

            using (MemoryStream mem = new MemoryStream())
            {
                mem.Write(byteArray, 0, (int)byteArray.Length);



                using (WordprocessingDocument outDoc = WordprocessingDocument.Open(mem, true))
                {
                    var doc = outDoc.MainDocumentPart.Document;

                    MainDocumentPart mainPart = outDoc.MainDocumentPart;


                    DocDefaults defaults = doc.MainDocumentPart.StyleDefinitionsPart.Styles.Descendants <DocDefaults>().FirstOrDefault();

                    RunFonts runFont = defaults.RunPropertiesDefault.RunPropertiesBaseStyle.RunFonts;
                    runFont.Ascii = "Calibri";
                    //runFont.AsciiTheme = "Times New Roman";
                    string   font = runFont.Ascii;
                    FontSize fs   = new FontSize();
                    fs.Val = "16";
                    string[] tblTag = new string[0];//Табличные теги
                    bool     flag   = true;
                    for (int f1 = 0; f1 < List1.Count; f1++)
                    {
                        flazhok = 0;
                        Array.Resize(ref tblTag, tblTag.Length + 1);

                        fcount = 0;
                        int i = 0;



                        tblTag[i] = List1[k][fcount].ToString();
                        m         = k;
                        fcount++;
                        i++;



                        var ccWithTable1 = mainPart.Document.Body.Descendants <SdtElement>();



                        SdtBlock ccWithTable = mainPart.Document.Body.Descendants <SdtBlock>().FirstOrDefault();

                        int index = 0;



                        foreach (var tt in ccWithTable1)
                        {
                            if (flag != false)
                            {
                                if (tt.SdtProperties.GetFirstChild <Tag>().Val == tblTag[index])
                                {
                                    ccWithTable = mainPart.Document.Body.Descendants <SdtBlock>().Where
                                                      (r => r.SdtProperties.GetFirstChild <Tag>().Val == tblTag[index]).Single();

                                    Tables.Add(tblTag[index]);
                                    flazhok = 1;
                                    flag    = false;
                                }
                            }
                        }
                        int count = 0;
                        int row = 0;
                        int r2 = 3; int n = 0;
                        int u2 = 1;

                        if (flazhok == 1)
                        {
                            Table theTable = ccWithTable.Descendants <Table>().FirstOrDefault();


                            for (row = 4; row < theTable.Elements <TableRow>().Count(); row++)
                            {
                                count = 0; bool p = true;
                                int             countp = 0;
                                TableRow        row8   = theTable.Elements <TableRow>().ElementAt(row);


                                for (int yacheika2 = 0; yacheika2 < theTable.Elements <TableRow>().ElementAt(row).Elements <TableCell>().Count(); yacheika2++)
                                {
                                    if (row == 4)
                                    {
                                        TableCell cell1     = row8.Elements <TableCell>().ElementAt(yacheika2);
                                        int       b3        = 0;
                                        int[]     gridSpan1 = null;
                                        gridSpan1 = new int[] { 1, 7 };
                                        TableCellProperties tcp3 = new TableCellProperties(new GridSpan()
                                        {
                                            Val = gridSpan1[b3]
                                        }); b3++;

                                        TableCell cell23 = new TableCell(tcp3, new Paragraph(new Run(new Text(List1[m][u2]))));

                                        TableCell cell2 = row8.Elements <TableCell>().ElementAt(yacheika2);
                                        cell2 = cell23;

                                        var sdts12 = mainPart.Document.Descendants <SdtElement>();

                                        //TableRow rowCopy = (TableRow)theRow.CloneNode(true);

                                        row8.Descendants <TableCell>().ElementAt(yacheika2).Append(new Paragraph
                                                                                                       (new Run(new Text(List1[m][u2]))));

                                        //row8.Elements<TableCell>().ElementAt(yacheika).InnerText = List1[m][u2];
                                        Paragraph p3 = row8.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>().First();
                                        Run       t2 = p3.Elements <Run>().First();


                                        RunProperties rPr2 = new RunProperties(
                                            new RunFonts()
                                        {
                                            Ascii    = font,
                                            HighAnsi = font
                                        },

                                            new FontSize()
                                        {
                                            Val = fs.Val
                                        });
                                        t2.PrependChild <RunProperties>(rPr2);

                                        if (t2.Count() > 1)
                                        {
                                            t2.LastChild.Remove();
                                        }


                                        if (row8.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>().Count() > 1)
                                        {
                                            foreach (var t3 in row8.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>())
                                            {
                                                if (countp == 0)
                                                {
                                                    t3.Remove();
                                                    break;
                                                }
                                            }
                                        }
                                        foreach (var t3 in row8.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>())
                                        {
                                            if (t3.Elements <ParagraphProperties>().Count() > 1)
                                            {
                                                for (int i7 = 0; i7 < t3.Elements <ParagraphProperties>().Count(); i7++)
                                                {
                                                    t3.Elements <ParagraphProperties>().ElementAt(i7).Remove();
                                                }
                                            }

                                            u2++;



                                            TableCellProperties tcp5 = new TableCellProperties(

                                                new TableCellVerticalAlignment()
                                            {
                                                Val = TableVerticalAlignmentValues.Center
                                            });



                                            ParagraphProperties pp = new ParagraphProperties(new Justification()
                                            {
                                                Val = JustificationValues.Center
                                            });

                                            t3.PrependChild <ParagraphProperties>(pp);

                                            t3.PrependChild <TableCellProperties>(tcp5);
                                        }
                                    }

                                    if (row != 4)
                                    {
                                        countp = 0;

                                        if (theTable.Elements <TableRow>().Count() <= row)
                                        {
                                            break;
                                        }


                                        TableRow row9 = theTable.Elements <TableRow>().ElementAt(row);
                                        row8 = theTable.Elements <TableRow>().ElementAt(row - 1);


                                        // row9 = theTable.Elements<TableRow>().ElementAt(row);
                                        if (yacheika2 == 15)
                                        {
                                            break;
                                        }
                                        if (count == 0)
                                        {
                                            if (u2 <= List1[m].Count() - 1)
                                            {
                                                if (List1[m][u2 - 15] != List1[m][u2])
                                                {
                                                    p = false;
                                                }
                                            }

                                            else
                                            {
                                                break;
                                            }
                                        }
                                        if (p == false)
                                        {
                                            TableCell cell1     = row8.Elements <TableCell>().ElementAt(yacheika2);
                                            int       b3        = 0;
                                            int[]     gridSpan1 = null;
                                            gridSpan1 = new int[] { 1, 7 };
                                            TableCellProperties tcp3 = new TableCellProperties(new GridSpan()
                                            {
                                                Val = gridSpan1[b3]
                                            }); b3++;

                                            // TableCell cell23 = new TableCell(tcp3, new Paragraph(new Run(new Text(List1[m][u2]))));

                                            // TableCell cell2 = row9.Elements<TableCell>().ElementAt(yacheika2);
                                            // cell2 = cell23;

                                            //  var sdts12 = mainPart.Document.Descendants<SdtElement>();

                                            //TableRow rowCopy = (TableRow)theRow.CloneNode(true);

                                            row9.Descendants <TableCell>().ElementAt(yacheika2).Append(new Paragraph
                                                                                                           (new Run(new Text(List1[m][u2]))));

                                            //row8.Elements<TableCell>().ElementAt(yacheika).InnerText = List1[m][u2];
                                            Paragraph p3 = row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>().First();
                                            Run       t2 = p3.Elements <Run>().First();

                                            if (row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>().Count() > 1)
                                            {
                                                foreach (var t3 in row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>())
                                                {
                                                    if (countp == 0)
                                                    {
                                                        t3.Remove();
                                                        break;
                                                    }
                                                }
                                            }
                                            RunProperties rPr2 = new RunProperties(
                                                new RunFonts()
                                            {
                                                Ascii    = font,
                                                HighAnsi = font
                                            },

                                                new FontSize()
                                            {
                                                Val = fs.Val
                                            });
                                            t2.PrependChild <RunProperties>(rPr2);
                                            if (t2.Count() > 1)
                                            {
                                                t2.LastChild.Remove();
                                            }


                                            foreach (var t3 in row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>())
                                            {
                                                if (t3.Elements <ParagraphProperties>().Count() > 1)
                                                {
                                                    for (int i7 = 0; i7 < t3.Elements <ParagraphProperties>().Count(); i7++)
                                                    {
                                                        t3.Elements <ParagraphProperties>().ElementAt(i7).Remove();
                                                    }
                                                }



                                                TableCellProperties tcp5 = new TableCellProperties(

                                                    new TableCellVerticalAlignment()
                                                {
                                                    Val = TableVerticalAlignmentValues.Center
                                                });



                                                ParagraphProperties pp = new ParagraphProperties(new Justification()
                                                {
                                                    Val = JustificationValues.Center
                                                });

                                                t3.PrependChild <ParagraphProperties>(pp);

                                                t3.PrependChild <TableCellProperties>(tcp5);
                                            }
                                        }

                                        else
                                        {
                                            countp = 0;
                                            if (List1[m][u2 - 15] != List1[m][u2])
                                            {
                                                // row9 = theTable.Elements<TableRow>().ElementAt(row - 1);



                                                TableCell cell1     = row8.Elements <TableCell>().ElementAt(yacheika2);
                                                int       b3        = 0;
                                                int[]     gridSpan1 = null;
                                                gridSpan1 = new int[] { 1, 7 };
                                                TableCellProperties tcp3 = new TableCellProperties(new GridSpan()
                                                {
                                                    Val = gridSpan1[b3]
                                                }); b3++;

                                                TableCell cell23 = new TableCell(tcp3, new Paragraph(new Run(new Text(List1[m][u2]))));

                                                TableCell cell2 = row8.Elements <TableCell>().ElementAt(yacheika2);
                                                cell2 = cell23;

                                                var sdts12 = mainPart.Document.Descendants <SdtElement>();

                                                //TableRow rowCopy = (TableRow)theRow.CloneNode(true);

                                                row9.Descendants <TableCell>().ElementAt(yacheika2).Append(new Paragraph
                                                                                                               (new Run(new Text(List1[m][u2]))));

                                                //row8.Elements<TableCell>().ElementAt(yacheika).InnerText = List1[m][u2];
                                                Paragraph p3 = row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>().First();
                                                Run       t2 = p3.Elements <Run>().First();

                                                if (row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>().Count() > 1)
                                                {
                                                    foreach (var t3 in row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>())
                                                    {
                                                        if (countp == 0)
                                                        {
                                                            t3.Remove();
                                                            break;
                                                        }
                                                    }
                                                }

                                                RunProperties rPr2 = new RunProperties(
                                                    new RunFonts()
                                                {
                                                    Ascii    = font,
                                                    HighAnsi = font
                                                },

                                                    new FontSize()
                                                {
                                                    Val = fs.Val
                                                });
                                                t2.PrependChild <RunProperties>(rPr2);
                                                if (t2.Count() > 1)
                                                {
                                                    t2.LastChild.Remove();
                                                }



                                                foreach (var t3 in row9.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>())
                                                {
                                                    if (t3.Elements <ParagraphProperties>().Count() > 1)
                                                    {
                                                        for (int i7 = 0; i7 < t3.Elements <ParagraphProperties>().Count(); i7++)
                                                        {
                                                            t3.Elements <ParagraphProperties>().ElementAt(i7).Remove();
                                                        }
                                                    }



                                                    TableCellProperties tcp5 = new TableCellProperties(

                                                        new TableCellVerticalAlignment()
                                                    {
                                                        Val = TableVerticalAlignmentValues.Center
                                                    });



                                                    ParagraphProperties pp = new ParagraphProperties(new Justification()
                                                    {
                                                        Val = JustificationValues.Center
                                                    });

                                                    t3.PrependChild <ParagraphProperties>(pp);

                                                    t3.PrependChild <TableCellProperties>(tcp5);
                                                }
                                            }
                                        }


                                        //string row11 = theTable.Elements<TableRow>().ElementAt(row1).Elements<TableCell>().ElementAt(yacheika1).InnerText;

                                        count++;
                                        u2++;
                                    }
                                }
                            }

//
                            int y = theTable.Elements <TableRow>().Count();

                            for (row = 4; row < theTable.Elements <TableRow>().Count(); row++)
                            {
                                TableRow row8 = theTable.Elements <TableRow>().ElementAt(row);

                                for (int yacheika2 = 0; yacheika2 < theTable.Elements <TableRow>().ElementAt(row).Elements <TableCell>().Count(); yacheika2++)
                                {
                                    foreach (var t3 in row8.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>())
                                    {
                                        Paragraph p3 = row8.Descendants <TableCell>().ElementAt(yacheika2).Elements <Paragraph>().First();
                                        Run       t2 = p3.Elements <Run>().First();


                                        RunProperties rPr2 = new RunProperties(
                                            new RunFonts()
                                        {
                                            Ascii    = font,
                                            HighAnsi = font
                                        },

                                            new FontSize()
                                        {
                                            Val = fs.Val
                                        });
                                        t2.PrependChild <RunProperties>(rPr2);
                                    }
                                }
                            }
                        }

                        var sdts123 = mainPart.Document.Descendants <SdtElement>();


                        foreach (var sdt3 in sdts123)
                        {
                            Tag    ff       = sdt3.SdtProperties.GetFirstChild <Tag>();
                            string old_text = sdt3.SdtProperties.InnerText;


                            if (ff != null)
                            {
                                if (dict.ContainsKey((ff.Val)))
                                {
                                    string value = dict[ff.Val];;
                                    sdt3.Descendants <DocumentFormat.OpenXml.Wordprocessing.Text>().FirstOrDefault().Text = value;
                                }
                            }
                        }
                    }
                }


                try
                {
                    File.Delete(path2);


                    using (FileStream fileStream = new FileStream(path2,
                                                                  System.IO.FileMode.CreateNew))
                    {
                        mem.WriteTo(fileStream);
                    }
                }


                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        public TableRow GenerateTableFooterRow(CellProps[] cellProps, UInt32Value height)
        {
            // Add table row properties
            TableRow tableRow1 = new TableRow();
            TableRowProperties tableRowProperties1 = generateTableRowProperties(height);
            tableRow1.Append(tableRowProperties1);

            foreach (CellProps cp in cellProps) {
                if (cp.span == 0) continue;
                TableCell tableCell1 = new TableCell();
                TableCellProperties tableCellProperties1 = new TableCellProperties();
                TableCellBorders tableCellBorders1;

                if (cp.boxed) {
                    tableCellBorders1 = generateTableCellBordersBox();
                } else {
                    tableCellBorders1 = generateTableCellBordersPlain();
                }

                Shading shading1 = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" };
                NoWrap noWrap1 = new NoWrap();
                TableCellVerticalAlignment tableCellVerticalAlignment1 = new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center };
                HideMark hideMark1 = new HideMark();

                tableCellProperties1.Append(tableCellBorders1);
                tableCellProperties1.Append(shading1);
                tableCellProperties1.Append(noWrap1);
                tableCellProperties1.Append(tableCellVerticalAlignment1);
                tableCellProperties1.Append(hideMark1);

                Paragraph paragraph1 = new Paragraph();

                ParagraphProperties paragraphProperties1 = new ParagraphProperties();
                Justification justification1 = new Justification() { Val = JustificationValues.Right };

                ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties();
                Bold bold1 = new Bold();
                BoldComplexScript boldComplexScript1 = new BoldComplexScript();
                Color color1 = new Color() { Val = "333399" };
                FontSize fontSize1 = new FontSize() { Val = "18" };
                FontSizeComplexScript fontSizeComplexScript1 = new FontSizeComplexScript() { Val = "18" };

                paragraphMarkRunProperties1.Append(bold1);
                paragraphMarkRunProperties1.Append(boldComplexScript1);
                paragraphMarkRunProperties1.Append(color1);
                paragraphMarkRunProperties1.Append(fontSize1);
                paragraphMarkRunProperties1.Append(fontSizeComplexScript1);

                paragraphProperties1.Append(justification1);
                paragraphProperties1.Append(paragraphMarkRunProperties1);

                Run run1 = new Run();

                RunProperties runProperties1 = new RunProperties();
                Bold bold2 = new Bold();
                BoldComplexScript boldComplexScript2 = new BoldComplexScript();
                Color color2 = new Color() { Val = "333399" };
                FontSize fontSize2 = new FontSize() { Val = "18" };
                FontSizeComplexScript fontSizeComplexScript2 = new FontSizeComplexScript() { Val = "18" };

                runProperties1.Append(bold2);
                runProperties1.Append(boldComplexScript2);
                runProperties1.Append(color2);
                runProperties1.Append(fontSize2);
                runProperties1.Append(fontSizeComplexScript2);
                run1.Append(runProperties1);

                if (cp.text != null) {
                    Text text1 = new Text();
                    text1.Text = cp.text;
                    run1.Append(text1);
                }

                paragraph1.Append(paragraphProperties1);
                paragraph1.Append(run1);

                tableCell1.Append(tableCellProperties1);
                tableCell1.Append(paragraph1);
                tableRow1.Append(tableCell1);
            }
            return tableRow1;
        }
Example #29
0
        public IActionResult CreateComplexDocument()
        {
            using (var stream = new MemoryStream())
            {
                using (var wordDocument = WordprocessingDocument.Create(stream,
                                                                        WordprocessingDocumentType.Document, true))
                {
                    wordDocument.AddMainDocumentPart();

                    var document = new Document();
                    var body     = new Body();

                    var paragraph1           = new Paragraph();
                    var paragraphProperties1 = new ParagraphProperties();
                    var paragraphStyleId1    = new ParagraphStyleId()
                    {
                        Val = "Normal"
                    };
                    var justifyJustification1 = new Justification()
                    {
                        Val = JustificationValues.Both
                    };

                    paragraphProperties1.Append(paragraphStyleId1);
                    paragraphProperties1.Append(justifyJustification1);

                    var run1  = new Run();
                    var text1 = new Text("A normal text, ")
                    {
                        Space = SpaceProcessingModeValues.Preserve
                    };
                    run1.Append(text1);

                    ///////////////////////////

                    var run2           = new Run();
                    var runProperties2 = new RunProperties();
                    runProperties2.Bold = new Bold();

                    var text2 = new Text("now a bold text, ")
                    {
                        Space = SpaceProcessingModeValues.Preserve
                    };
                    run2.Append(runProperties2); // Properties must go first... always!
                    run2.Append(text2);

                    ///////////////////////////

                    var run3           = new Run();
                    var runProperties3 = new RunProperties();
                    runProperties3.Italic = new Italic();

                    var text3 = new Text("now an italic text. ")
                    {
                        Space = SpaceProcessingModeValues.Preserve
                    };
                    run3.Append(runProperties3);
                    run3.Append(text3);

                    ///////////////////////////

                    var run4           = new Run();
                    var runProperties4 = new RunProperties();
                    runProperties4.Italic    = new Italic();
                    runProperties4.Underline = new Underline();
                    runProperties4.Bold      = new Bold();

                    var text4 = new Text("Yes, you can combine styles, ")
                    {
                        Space = SpaceProcessingModeValues.Preserve
                    };
                    run4.Append(runProperties4);
                    run4.Append(text4);

                    ///////////////////////////

                    var run5           = new Run();
                    var runProperties5 = new RunProperties();
                    runProperties5.Color = new Color()
                    {
                        Val = "FFFF00"
                    };

                    var text5 = new Text("and add some color for your text.")
                    {
                        Space = SpaceProcessingModeValues.Preserve
                    };
                    run5.Append(runProperties5);
                    run5.Append(text5);

                    paragraph1.Append(paragraphProperties1);
                    paragraph1.Append(run1);
                    paragraph1.Append(run2);
                    paragraph1.Append(run3);
                    paragraph1.Append(run4);
                    paragraph1.Append(run5);

                    ///////////////////////////
                    ///////////////////////////

                    var runProperties6 = new RunProperties();
                    runProperties6.RunStyle = new RunStyle()
                    {
                        Val = "Hyperlink"
                    };
                    runProperties6.Color = new Color()
                    {
                        ThemeColor = ThemeColorValues.Hyperlink
                    };

                    var text6 = new Text("Visit my website!")
                    {
                        Space = SpaceProcessingModeValues.Preserve
                    };
                    var run6 = new Run(runProperties6, text6);

                    var url = "https://luisbeltran.mx";
                    var uri = new Uri(url);

                    var hyperlinkRelationship = wordDocument.MainDocumentPart.AddHyperlinkRelationship(uri, true);
                    var id = hyperlinkRelationship.Id;

                    var proofError = new ProofError()
                    {
                        Type = ProofingErrorValues.GrammarStart
                    };

                    var hyperLink = new Hyperlink(proofError, run6)
                    {
                        History = OnOffValue.FromBoolean(true),
                        Id      = id
                    };

                    var paragraph2 = new Paragraph();
                    paragraph2.Append(hyperLink);

                    ///////////////////////////

                    body.Append(paragraph1);
                    body.Append(paragraph2);

                    document.Append(body);
                    wordDocument.MainDocumentPart.Document = document;
                    wordDocument.Close();
                }

                return(File(stream.ToArray(), docxMIMEType,
                            "Word Document Complex Example.docx"));
            }
        }
Example #30
0
        private Paragraph createParagraphWithStyles(bool isBold, bool isItalic, bool isUnderlined, string colore, string testo)
        {
            ParagraphProperties pp = new ParagraphProperties();

            pp.Justification = new Justification()
            {
                Val = JustificationValues.Center
            };

            //*******PARAGRAFO 2******
            Paragraph p = new Paragraph();

            p.Append(pp);

            Run           r  = new Run();
            RunProperties rp = new RunProperties();

            if (isBold)
            {
                rp.Bold = new Bold();
            }
            if (isItalic)
            {
                rp.Italic = new Italic();
            }
            if (isUnderlined)
            {
                rp.Underline = new Underline()
                {
                    Val = DocumentFormat.OpenXml.Wordprocessing.UnderlineValues.Single
                };
            }
            rp.Color = new Color()
            {
                Val = colore
            };
            r.Append(rp);
            Text t = new Text(testo)
            {
                Space = SpaceProcessingModeValues.Preserve
            };

            r.Append(t);
            p.Append(r);

            ////BOLD
            //Run r2 = new Run();
            //RunProperties rp2 = new RunProperties();
            //rp2.Bold = new Bold();
            ////Always add properties first
            //r2.Append(rp2);
            //Text t2 = new Text("grassetto - ") { Space = SpaceProcessingModeValues.Preserve };
            //r2.Append(t2);
            //p.Append(r2);

            ////ITALIC
            //Run r4 = new Run();
            //RunProperties rp4 = new RunProperties();
            //rp4.Italic = new Italic();
            ////Always add properties first
            //r4.Append(rp4);
            //Text t4 = new Text("italico - ") { Space = SpaceProcessingModeValues.Preserve };
            //r4.Append(t4);
            //p.Append(r4);

            ////ITALIC, BOLD AND UNDERLINE
            //Run r6 = new Run();
            //RunProperties rp6 = new RunProperties();
            //rp6.Italic = new Italic();
            //rp6.Bold = new Bold();
            //rp6.Underline = new Underline() { Val = DocumentFormat.OpenXml.Wordprocessing.UnderlineValues.Single };
            ////Always add properties first
            //r6.Append(rp6);
            //Text t6 = new Text("italico grassetto e sottolineato - ") { Space = SpaceProcessingModeValues.Preserve };
            //r6.Append(t6);
            //p.Append(r6);

            ////COLORE ROSSO
            //Run r8 = new Run();
            //RunProperties rp8 = new RunProperties();
            //rp8.Color = new Color() { Val = "FF0000" };
            ////Always add properties first
            //r8.Append(rp8);
            //Text t8 = new Text("rosso ") { Space = SpaceProcessingModeValues.Preserve };
            //r8.Append(t8);
            //p.Append(r8);

            return(p);
        }
Example #31
0
        public  void HelloWorld(string documentFileName) 
        { 
            // Create a Wordprocessing document. 
            using (WordprocessingDocument myDoc = 
                   WordprocessingDocument.Create(_TemplatePath, 
                                 WordprocessingDocumentType.Document)) 
            { 
                // Add a new main document part. 
                MainDocumentPart mainPart = myDoc.AddMainDocumentPart(); 
                //Create Document tree for simple document. 
                mainPart.Document = new Document();
                
                
                StyleDefinitionsPart stylePart = mainPart.AddNewPart<StyleDefinitionsPart>();
                // we have to set the properties
                RunProperties rPr = new RunProperties();
                Color color = new Color() { Val = "FF0000" }; // the color is red
                RunFonts rFont = new RunFonts();
                rFont.Ascii = "Arial"; // the font is Arial
                rPr.Append(color);
                rPr.Append(rFont);
                rPr.Append(new Bold()); // it is Bold
                rPr.Append(new FontSize() { Val = "28" }); //font size (in 1/72 of an inch)
                //creation of a style
                Style style = new Style();
                style.StyleId = "MyHeading1"; //this is the ID of the style
                style.Append(new Name() { Val = "My Heading 1" }); //this is name
                // our style based on Normal style
                style.Append(new BasedOn() { Val = "Heading1" });
                // the next paragraph is Normal type
                style.Append(new NextParagraphStyle() { Val = "Normal" });
                style.Append(rPr);//we are adding properties previously defined
                // we have to add style that we have created to the StylePart
                stylePart.Styles = new Styles();
                stylePart.Styles.Append(style);
                stylePart.Styles.Save(); // we save the style part

                Paragraph heading = new Paragraph();
                Run heading_run = new Run();
                Text heading_text = new Text("This is Heading");
                ParagraphProperties heading_pPr = new ParagraphProperties();
                // we set the style
                heading_pPr.ParagraphStyleId = new ParagraphStyleId() { Val = "MyHeading1" };
                heading.Append(heading_pPr);
                heading_run.Append(heading_text);
                heading.Append(heading_run);


                //Create Body (this element contains
                //other elements that we want to include 
                Body body = new Body(); 
                //Create paragraph 
                Paragraph paragraph = new Paragraph(); 
                Run run_paragraph = new Run(); 
                // we want to put that text into the output document 
                Text text_paragraph = new Text("Hello World!"); 
                //Append elements appropriately. 
                run_paragraph.Append(text_paragraph); 
                paragraph.Append(run_paragraph); 
                body.Append(paragraph);
                body.Append(heading); 
                mainPart.Document.Append(body); 
                // Save changes to the main document part. 
                mainPart.Document.Save(); 
            } 
        
        }
Example #32
0
    /// <summary>
    /// 取代書籤
    /// </summary>
    /// <param name="bookmarkName">書籤名稱</param>
    /// <param name="text">取代的值</param>
    /// <param name="delFlag">若取代值為空,是否刪除整個段落</param>
    /// <param name="color">套用此顏色</param>
    public void ReplaceBookmark(string bookmarkName, string text, bool delFlag, System.Drawing.Color color)
    {
        try {
            MainDocumentPart mainPart = outDoc.MainDocumentPart;
            //IEnumerable<BookmarkEnd> bookMarkEnds = mainPart.RootElement.Descendants<BookmarkEnd>();
            foreach (BookmarkStart bookmarkStart in mainPart.RootElement.Descendants <BookmarkStart>())
            {
                if (bookmarkStart.Name.Value.ToLower() == bookmarkName.ToLower())
                {
                    string id = bookmarkStart.Id.Value;

                    //如果是空值,且要刪除整個段落
                    if (text == "" && delFlag)
                    {
                        bookmarkStart.Parent.Remove();
                    }
                    else
                    {
                        BookmarkEnd bookmarkEnd = bookmarkStart.Parent.Descendants <BookmarkEnd>().Where(i => i.Id.Value == id).FirstOrDefault();

                        //留第一個run其他run刪除,從BookmarkStart刪到BookmarkEnd為止
                        OpenXmlElement[] bookmarkItems = bookmarkStart.Parent.ChildElements.ToArray();
                        //HttpContext.Current.Response.Write(bookmarkItems.Count());
                        //HttpContext.Current.Response.End();

                        bool canRemove = false;
                        int  bIndex    = 0;
                        foreach (OpenXmlElement item in bookmarkItems)
                        {
                            if (item.GetType() == typeof(BookmarkEnd) && bookmarkEnd != null && bookmarkEnd.Id == id)
                            {
                                break;
                            }
                            if (canRemove && item.GetType() == typeof(Run))
                            {
                                if (bIndex == 0)
                                {
                                    string[] txtArr = text.Split('\n');
                                    for (int i = 0; i < txtArr.Length; i++)
                                    {
                                        if (i == 0)
                                        {
                                            if (color != System.Drawing.Color.Empty)
                                            {
                                                RunProperties FirstRunProp = item.Descendants <RunProperties>().FirstOrDefault();
                                                if (FirstRunProp == null)
                                                {
                                                    FirstRunProp = new RunProperties();
                                                }
                                                Color RunColor = new Color()
                                                {
                                                    Val = toHtmlHexColor(color)
                                                };
                                                FirstRunProp.Append(RunColor);
                                            }
                                            item.GetFirstChild <Text>().Text = txtArr[i];
                                        }
                                        else
                                        {
                                            item.Append(new Break());
                                            item.Append(new Text(txtArr[i]));
                                        }
                                    }
                                }
                                else
                                {
                                    item.Remove();
                                }
                                bIndex++;
                            }
                            //if (item.GetType() == typeof(BookmarkStart)) {
                            if (item.Equals(bookmarkStart))
                            {
                                canRemove = true;
                            }
                        }

                        bookmarkStart.Remove();
                        if (bookmarkEnd != null)
                        {
                            bookmarkEnd.Remove();
                        }
                    }
                }
            }
        }
        catch (Exception ex) {
            throw new Exception("取代書籤錯誤!!(" + bookmarkName + ")", ex);
        }
    }
        //
        // Word
        //

        private void ExportWord_AppendTableCell(TableRow tr, CellRecord cr)
        {
            TableCell tc   = tr.AppendChild(new TableCell());
            Paragraph para = tc.AppendChild(new Paragraph());

            // see: https://stackoverflow.com/questions/17675526/
            // how-can-i-modify-the-foreground-and-background-color-of-an-openxml-tablecell/17677892

            if (cr.HorizAlign != null)
            {
                ParagraphProperties pp = new ParagraphProperties();

                if (cr.HorizAlign == "left")
                {
                    pp.Justification = new Justification()
                    {
                        Val = JustificationValues.Left
                    }
                }
                ;
                if (cr.HorizAlign == "center")
                {
                    pp.Justification = new Justification()
                    {
                        Val = JustificationValues.Center
                    }
                }
                ;
                if (cr.HorizAlign == "right")
                {
                    pp.Justification = new Justification()
                    {
                        Val = JustificationValues.Right
                    }
                }
                ;

                para.Append(pp);
            }

            if (cr.VertAlign != null || cr.Bg != null)
            {
                var tcp = tc.AppendChild(new TableCellProperties());

                if (cr.VertAlign == "top")
                {
                    tcp.Append(new TableCellVerticalAlignment()
                    {
                        Val = TableVerticalAlignmentValues.Top
                    });
                }
                if (cr.VertAlign == "center")
                {
                    tcp.Append(new TableCellVerticalAlignment()
                    {
                        Val = TableVerticalAlignmentValues.Center
                    });
                }
                if (cr.VertAlign == "bottom")
                {
                    tcp.Append(new TableCellVerticalAlignment()
                    {
                        Val = TableVerticalAlignmentValues.Bottom
                    });
                }

                if (cr.Bg != null)
                {
                    // ReSharper disable PossibleNullReferenceException
                    try
                    {
                        var bgc = (System.Windows.Media.Color)ColorConverter.ConvertFromString(cr.Bg);
                        var bgs = (new ColorConverter()).ConvertToString(bgc).Substring(3);

                        tcp.Append(new DocumentFormat.OpenXml.Wordprocessing.Shading()
                        {
                            Color = "auto",
                            Fill  = bgs,
                            Val   = ShadingPatternValues.Clear
                        });
                    }
                    catch (Exception ex)
                    {
                        AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex);
                    }
                    // ReSharper enable PossibleNullReferenceException
                }
            }

            // var run = new Run(new Text(cr.Text));
            // make a run with multiple breaks
            var run   = new Run();
            var lines = cr.Text.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var l in lines)
            {
                if (run.ChildElements != null && run.ChildElements.Count > 0)
                {
                    run.AppendChild(new Break());
                }
                run.AppendChild(new Text(l));
            }

            if (cr.Fg != null || cr.Font != null)
            {
                try
                {
                    var rp = new RunProperties();

                    if (cr.Fg != null)
                    {
                        var fgc = (System.Windows.Media.Color)ColorConverter.ConvertFromString(cr.Fg);
                        var fgs = (new ColorConverter()).ConvertToString(fgc).Substring(3);

                        rp.Append(new DocumentFormat.OpenXml.Wordprocessing.Color()
                        {
                            Val = fgs
                        });
                    }

                    if (cr.Font != null && cr.Font.Contains("bold"))
                    {
                        rp.Bold = new Bold();
                    }

                    if (cr.Font != null && cr.Font.Contains("italic"))
                    {
                        rp.Italic = new Italic();
                    }

                    if (cr.Font != null && cr.Font.Contains("underline"))
                    {
                        rp.Underline = new Underline();
                    }

                    run.RunProperties = rp;
                }
                catch (Exception ex)
                {
                    AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex);
                }
            }

            para.Append(run);
        }
        public void UlWithH1()
        {
            using MemoryStream mem = new MemoryStream();
            WordDocument doc = new WordDocument(mem);

            doc.Process(new HtmlParser("<ul><li><h1>test</h1></li></ul>"));

            Assert.IsNotNull(doc.Document.Body);
            Assert.AreEqual(1, doc.Document.Body.ChildElements.Count);

            Paragraph para = doc.Document.Body.ChildElements[0] as Paragraph;

            Assert.IsNotNull(para);
            Assert.AreEqual(2, para.ChildElements.Count);

            ParagraphProperties properties = para.ChildElements[0] as ParagraphProperties;

            Assert.IsNotNull(properties);
            Assert.AreEqual(2, properties.ChildElements.Count);
            ParagraphStyleId paragraphStyleId = properties.ChildElements[0] as ParagraphStyleId;

            Assert.IsNotNull(paragraphStyleId);
            Assert.AreEqual("ListParagraph", paragraphStyleId.Val.Value);

            NumberingProperties numberingProperties = properties.ChildElements[1] as NumberingProperties;

            Assert.IsNotNull(numberingProperties);
            Assert.AreEqual(2, numberingProperties.ChildElements.Count);

            NumberingLevelReference numberingLevelReference = numberingProperties.ChildElements[0] as NumberingLevelReference;

            Assert.IsNotNull(numberingLevelReference);
            Assert.AreEqual(0, numberingLevelReference.Val.Value);

            NumberingId numberingId = numberingProperties.ChildElements[1] as NumberingId;

            Assert.IsNotNull(numberingId);
            Assert.AreEqual(2, numberingId.Val.Value);

            Run run = para.ChildElements[1] as Run;

            Assert.IsNotNull(run);
            Assert.AreEqual(2, run.ChildElements.Count);

            RunProperties runProperties = run.ChildElements[0] as RunProperties;

            Assert.IsNotNull(runProperties);
            Bold bold = runProperties.ChildElements[0] as Bold;

            Assert.IsNotNull(bold);
            FontSize fontSize = runProperties.ChildElements[1] as FontSize;

            Assert.IsNotNull(fontSize);
            Assert.AreEqual("48", fontSize.Val.Value);

            Word.Text text = run.ChildElements[1] as Word.Text;
            Assert.IsNotNull(text);
            Assert.AreEqual("test", text.InnerText);

            OpenXmlValidator validator = new OpenXmlValidator();
            var errors = validator.Validate(doc.WordprocessingDocument);

            Assert.AreEqual(0, errors.Count());
        }
Example #35
0
        //.....................................................................
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private TableCell MakeElem6( )
        {
            TableCell tableCell6 = new TableCell( );

            //---------------------------------------------
            TableCellProperties tableCellProperties6 = new TableCellProperties( );

            TableCellWidth tableCellWidth6 = new TableCellWidth( )
            {
                Width = "2841", Type = TableWidthUnitValues.Dxa
            };
            TableCellVerticalAlignment tableCellVerticalAlignment6 = new TableCellVerticalAlignment( )
            {
                Val = TableVerticalAlignmentValues.Center
            };

            tableCellProperties6.Append(tableCellWidth6);
            tableCellProperties6.Append(tableCellVerticalAlignment6);

            //---------------------------------------------
            Paragraph paragraph6 = new Paragraph( )
            {
                RsidParagraphMarkRevision = "00422B84", RsidParagraphAddition = "00B721D5", RsidRunAdditionDefault = "00B721D5"
            };

            ParagraphProperties paragraphProperties6 = new ParagraphProperties( );

            ParagraphMarkRunProperties paragraphMarkRunProperties5 = new ParagraphMarkRunProperties( );
            Bold      bold10     = new Bold( );
            Italic    italic1    = new Italic( );
            Underline underline1 = new Underline( )
            {
                Val = UnderlineValues.Wave
            };

            paragraphMarkRunProperties5.Append(bold10);
            paragraphMarkRunProperties5.Append(italic1);
            paragraphMarkRunProperties5.Append(underline1);

            paragraphProperties6.Append(paragraphMarkRunProperties5);


            //---------------------------------------------
            Run run7 = new Run( )
            {
                RsidRunProperties = "00422B84"
            };

            RunProperties runProperties7 = new RunProperties( );

            Bold      bold11     = new Bold( );
            Italic    italic2    = new Italic( );
            Underline underline2 = new Underline( )
            {
                Val = UnderlineValues.Wave
            };

            runProperties7.Append(bold11);
            runProperties7.Append(italic2);
            runProperties7.Append(underline2);

            Text text7 = new Text( );

            text7.Text = "P";

            run7.Append(runProperties7);
            run7.Append(text7);

            //---------------------------------------------
            Run run8 = new Run( )
            {
                RsidRunProperties = "00422B84"
            };

            RunProperties runProperties8 = new RunProperties( );
            RunFonts      runFonts4      = new RunFonts( )
            {
                Hint = FontTypeHintValues.EastAsia
            };

            Bold      bold12     = new Bold( );
            Italic    italic3    = new Italic( );
            Underline underline3 = new Underline( )
            {
                Val = UnderlineValues.Wave
            };

            runProperties8.Append(runFonts4);
            runProperties8.Append(bold12);
            runProperties8.Append(italic3);
            runProperties8.Append(underline3);

            Text text8 = new Text( );

            text8.Text = "122231";

            run8.Append(runProperties8);
            run8.Append(text8);

            //---------------------------------------------
            paragraph6.Append(paragraphProperties6);
            paragraph6.Append(run7);
            paragraph6.Append(run8);

            tableCell6.Append(tableCellProperties6);
            tableCell6.Append(paragraph6);
            return(tableCell6);
        }
Example #36
0
        public static Paragraph createParagraphWithStyles()
        {
            Paragraph p = new Paragraph();
            // Set the paragraph properties
            ParagraphProperties pp = new ParagraphProperties(new ParagraphStyleId()
            {
                Val = "Titolo1"
            });

            pp.Justification = new Justification()
            {
                Val = JustificationValues.Center
            };
            // Add paragraph properties to your paragraph
            p.Append(pp);

            // Run 1
            Run  r1 = new Run();
            Text t1 = new Text("Pellentesque ")
            {
                Space = SpaceProcessingModeValues.Preserve
            };

            // The Space attribute preserve white space before and after your text
            r1.Append(t1);
            p.Append(r1);

            // Run 2 - Bold
            Run           r2  = new Run();
            RunProperties rp2 = new RunProperties();

            rp2.Bold = new Bold();
            // Always add properties first
            r2.Append(rp2);
            Text t2 = new Text("commodo ")
            {
                Space = SpaceProcessingModeValues.Preserve
            };

            r2.Append(t2);
            p.Append(r2);

            // Run 3
            Run  r3 = new Run();
            Text t3 = new Text("rhoncus ")
            {
                Space = SpaceProcessingModeValues.Preserve
            };

            r3.Append(t3);
            p.Append(r3);

            // Run 4 – Italic
            Run           r4  = new Run();
            RunProperties rp4 = new RunProperties();

            rp4.Italic = new Italic();
            // Always add properties first
            r4.Append(rp4);
            Text t4 = new Text("mauris")
            {
                Space = SpaceProcessingModeValues.Preserve
            };

            r4.Append(t4);
            p.Append(r4);

            // Run 5
            Run  r5 = new Run();
            Text t5 = new Text(", sit ")
            {
                Space = SpaceProcessingModeValues.Preserve
            };

            r5.Append(t5);
            p.Append(r5);

            // Run 6 – Italic , bold and underlined
            Run           r6  = new Run();
            RunProperties rp6 = new RunProperties();

            rp6.Italic    = new Italic();
            rp6.Bold      = new Bold();
            rp6.Underline = new Underline()
            {
                Val = UnderlineValues.WavyDouble
            };
            // Always add properties first
            r6.Append(rp6);
            Text t6 = new Text("amet ")
            {
                Space = SpaceProcessingModeValues.Preserve
            };

            r6.Append(t6);
            p.Append(r6);

            // Run 7
            Run  r7 = new Run();
            Text t7 = new Text("faucibus arcu ")
            {
                Space = SpaceProcessingModeValues.Preserve
            };

            r7.Append(t7);
            p.Append(r7);

            // Run 8 – Red color
            Run           r8  = new Run();
            RunProperties rp8 = new RunProperties();

            rp8.Color = new Color()
            {
                Val = "FF0000"
            };
            // Always add properties first
            r8.Append(rp8);
            Text t8 = new Text("porttitor ")
            {
                Space = SpaceProcessingModeValues.Preserve
            };

            r8.Append(t8);
            p.Append(r8);

            // Run 9
            Run  r9 = new Run();
            Text t9 = new Text("pharetra. Maecenas quis erat quis eros iaculis placerat ut at mauris.")
            {
                Space = SpaceProcessingModeValues.Preserve
            };

            r9.Append(t9);
            p.Append(r9);

            // return the new paragraph
            return(p);
        }
Example #37
0
        /// <summary>
        /// Формула простановки формулы на последнюю страницу
        /// </summary>
        /// <param name="footerstext"></param>
        /// <returns></returns>
        private Run FormulandFooters(string footerstext)
        {
            Run       run   = new Run();
            FieldChar field = new FieldChar()
            {
                FieldCharType = FieldCharValues.Begin
            };
            FieldCode code = new FieldCode()
            {
                Text = "IF"
            };
            FieldChar field1 = new FieldChar()
            {
                FieldCharType = FieldCharValues.Begin
            };
            FieldCode code1 = new FieldCode()
            {
                Text = "PAGE"
            };
            FieldChar field2 = new FieldChar()
            {
                FieldCharType = FieldCharValues.Separate
            };
            FieldChar field6 = new FieldChar()
            {
                FieldCharType = FieldCharValues.End
            };
            FieldCode code2 = new FieldCode()
            {
                Text = "="
            };
            FieldChar field3 = new FieldChar()
            {
                FieldCharType = FieldCharValues.Begin
            };
            FieldCode code3 = new FieldCode()
            {
                Text = "NUMPAGES"
            };
            FieldChar field4 = new FieldChar()
            {
                FieldCharType = FieldCharValues.Separate
            };
            FieldChar field5 = new FieldChar()
            {
                FieldCharType = FieldCharValues.End
            };
            FieldCode code5 = new FieldCode()
            {
                Text = "\""
            };
            FieldCode code6 = new FieldCode()
            {
                Text = footerstext
            };
            FieldCode code7 = new FieldCode()
            {
                Text = "\""
            };
            FieldCode code8 = new FieldCode()
            {
                Text = "\"\""
            };
            FieldChar field7 = new FieldChar()
            {
                FieldCharType = FieldCharValues.Separate
            };
            FieldChar field8 = new FieldChar()
            {
                FieldCharType = FieldCharValues.End
            };
            RunProperties runProperties = new RunProperties();
            NoProof       noProof       = new NoProof();

            runProperties.Append(noProof);
            run.Append(field);
            run.Append(code);
            run.Append(field1);
            run.Append(code1);
            run.Append(field2);
            run.Append(field6);
            run.Append(code2);
            run.Append(field3);
            run.Append(code3);
            run.Append(field4);
            run.Append(field5);
            run.Append(code5);
            run.Append(code6);
            run.Append(code7);
            run.Append(code8);
            run.Append(field7);
            run.Append(field8);
            run.Append(runProperties);
            return(run);
        }
Example #38
0
        public static void AddStyle(MainDocumentPart mainPart, bool isBold = false, bool isItalic = false, bool isUnderline = false, string styleId = "00", string styleName = "Default", string fontName = "Calibri", int fontSize = 12, string rgbColor = "000000")
        {
            // we have to set the properties
            RunProperties rPr   = new RunProperties();
            Color         color = new Color()
            {
                Val = rgbColor
            };
            RunFonts rFont = new RunFonts();

            rFont.Ascii = fontName;
            rPr.Append(color);
            rPr.Append(rFont);
            if (isBold)
            {
                rPr.Append(new Bold());
            }
            if (isItalic)
            {
                rPr.Append(new Italic());
            }
            if (isUnderline)
            {
                rPr.Append(new Underline()
                {
                    Val = UnderlineValues.Single
                });
            }
            rPr.Append(new FontSize()
            {
                Val = (fontSize * 2).ToString()
            });

            Style style = new Style();

            style.StyleId = styleId;
            if (styleName == null || styleName.Length == 0)
            {
                styleName = styleId;
            }
            style.Append(new Name()
            {
                Val = styleName
            });
            style.Append(rPr); //we are adding properties previously defined

            // we have to add style that we have created to the StylePart
            StyleDefinitionsPart stylePart;

            if (mainPart.StyleDefinitionsPart == null)
            {
                stylePart        = mainPart.AddNewPart <StyleDefinitionsPart>();
                stylePart.Styles = new Styles();
            }
            else
            {
                stylePart = mainPart.StyleDefinitionsPart;
            }

            stylePart.Styles.Append(style);
            stylePart.Styles.Save(); // we save the style part
        }
        private TableCell BuildCell(string text, int gridSpan = 1, VerticalMerge vm = null, bool bold = false)
        {
            TableCell cell = new TableCell();
            Paragraph p = new Paragraph();
            ParagraphProperties paragraphProperties = new ParagraphProperties();

            Justification justification = new Justification() { Val = JustificationValues.Center };
            paragraphProperties.Append(justification);

            if (bold)
            {
                ParagraphMarkRunProperties paragraphMarkRunProperties = new ParagraphMarkRunProperties();
                Bold boldStyle = new Bold();

                paragraphMarkRunProperties.Append(boldStyle);
                paragraphProperties.Append(paragraphMarkRunProperties);
            }
            p.Append(paragraphProperties);

            if (!string.IsNullOrEmpty(text))
            {
                Run r = new Run();
                RunProperties runProperties = new RunProperties();

                if (bold)
                {
                    Bold boldStyle = new Bold();

                    runProperties.Append(boldStyle);
                }

                r.Append(runProperties);

                Text t = new Text { Text = text };
                r.AppendChild<Text>(t);

                p.AppendChild<Run>(r);
            }

            TableCellProperties cellProperty = new TableCellProperties();
            TableCellVerticalAlignment tableCellVerticalAlignment1 = new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center };

            cellProperty.Append(tableCellVerticalAlignment1);

            if (gridSpan > 1)
            {
                GridSpan gs = new GridSpan { Val = gridSpan };
                cellProperty.Append(gs);
            }

            if (vm != null)
            {
                cellProperty.Append(vm);
            }

            cell.Append(cellProperty);
            cell.Append(p);

            return cell;
        }
Example #40
0
 public RunClassParam(RunProperties rPr)
 {
     InlineProperties = rPr;
     RunStyleId       = rPr?.RunStyle?.Val;
 }
        private Paragraph GeneratePageCountparagraph(int pageCount)
        {
            Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "004E307B", RsidParagraphProperties = "00E073E3", RsidRunAdditionDefault = "00E073E3" };

            ParagraphProperties paragraphProperties1 = new ParagraphProperties();
            Justification justification1 = new Justification() { Val = JustificationValues.Center };

            ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties();
            RunFonts runFonts1 = new RunFonts() { Hint = FontTypeHintValues.EastAsia };

            paragraphMarkRunProperties1.Append(runFonts1);

            paragraphProperties1.Append(justification1);
            paragraphProperties1.Append(paragraphMarkRunProperties1);

            Run run1 = new Run();

            RunProperties runProperties1 = new RunProperties();
            RunFonts runFonts2 = new RunFonts() { Hint = FontTypeHintValues.EastAsia };

            runProperties1.Append(runFonts2);
            Text text1 = new Text();
            text1.Text = "第";

            run1.Append(runProperties1);
            run1.Append(text1);

            Run run2 = new Run();

            RunProperties runProperties2 = new RunProperties();
            RunFonts runFonts3 = new RunFonts() { Hint = FontTypeHintValues.EastAsia };

            runProperties2.Append(runFonts3);
            Text text2 = new Text();
            text2.Text = pageCount.ToString();

            run2.Append(runProperties2);
            run2.Append(text2);

            Run run3 = new Run();

            RunProperties runProperties3 = new RunProperties();
            RunFonts runFonts4 = new RunFonts() { Hint = FontTypeHintValues.EastAsia };

            runProperties3.Append(runFonts4);
            Text text3 = new Text();
            text3.Text = "页";

            run3.Append(runProperties3);
            run3.Append(text3);

            paragraph1.Append(paragraphProperties1);
            paragraph1.Append(run1);
            paragraph1.Append(run2);
            paragraph1.Append(run3);
            return paragraph1;
        }
        private Paragraph CreateTextParagraph(string str)
        {
            Paragraph paragraph = new Paragraph() {};

            Run run = new Run();
            RunProperties runProperties = new RunProperties();
            RunFonts runFonts = new RunFonts() { Hint = FontTypeHintValues.EastAsia };

            runProperties.Append(runFonts);
            Text text = new Text() { Space = SpaceProcessingModeValues.Preserve };
            text.Text = str;

            run.Append(runProperties);
            run.Append(text);

            paragraph.Append(run);
            return paragraph;
        }
        public TableRow GenerateTableRow(CellProps[] cellProps, UInt32Value height)
        {
            TableRow tableRow1 = new TableRow();
            TableRowProperties tableRowProperties1 = generateTableRowProperties(height);
            tableRow1.Append(tableRowProperties1);

            foreach (CellProps cp in cellProps) {
                if (cp.span == 0) continue;
                TableCell tableCell1 = new TableCell();
                TableCellProperties tableCellProperties1 = new TableCellProperties();

                TableCellBorders tableCellBorders1 = generateTableCellBordersPlain();
                Shading shading1 = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" };
                NoWrap noWrap1 = new NoWrap();
                TableCellVerticalAlignment tableCellVerticalAlignment1 = new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center };
                HideMark hideMark1 = new HideMark();

                if (cp.span > 1) {
                    GridSpan span = new GridSpan() { Val = (Int32Value)cp.span };
                    tableCellProperties1.Append(span);
                }

                tableCellProperties1.Append(tableCellBorders1);
                tableCellProperties1.Append(shading1);
                tableCellProperties1.Append(noWrap1);
                tableCellProperties1.Append(tableCellVerticalAlignment1);
                tableCellProperties1.Append(hideMark1);

                Paragraph paragraph1 = new Paragraph();

                ParagraphProperties paragraphProperties1 = new ParagraphProperties();
                Justification justification1 = new Justification() { Val = cp.align };

                ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties();
                FontSize fontSize1 = new FontSize() { Val = "18" };
                FontSizeComplexScript fontSizeComplexScript1 = new FontSizeComplexScript() { Val = "18" };

                paragraphMarkRunProperties1.Append(fontSize1);
                paragraphMarkRunProperties1.Append(fontSizeComplexScript1);

                paragraphProperties1.Append(justification1);
                paragraphProperties1.Append(paragraphMarkRunProperties1);

                Run run1 = new Run();

                RunProperties runProperties1 = new RunProperties();
                FontSize fontSize2 = new FontSize() { Val = "18" };
                FontSizeComplexScript fontSizeComplexScript2 = new FontSizeComplexScript() { Val = "18" };

                runProperties1.Append(fontSize2);
                runProperties1.Append(fontSizeComplexScript2);

                run1.Append(runProperties1);
                if (cp.text != null) {
                    Text text1 = new Text();
                    text1.Text = cp.text;
                    run1.Append(text1);
                }

                paragraph1.Append(paragraphProperties1);
                paragraph1.Append(run1);

                tableCell1.Append(tableCellProperties1);
                tableCell1.Append(paragraph1);
                tableRow1.Append(tableCell1);

            }

            return tableRow1;
        }
Example #44
0
        // Generates content of glossaryDocumentPart1.
        private void GenerateGlossaryDocumentPart1Content(GlossaryDocumentPart glossaryDocumentPart1)
        {
            GlossaryDocument glossaryDocument1 = new GlossaryDocument(){ MCAttributes = new MarkupCompatibilityAttributes(){ Ignorable = "w14 w15 wp14" }  };
            glossaryDocument1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
            glossaryDocument1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            glossaryDocument1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
            glossaryDocument1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            glossaryDocument1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
            glossaryDocument1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
            glossaryDocument1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
            glossaryDocument1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
            glossaryDocument1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
            glossaryDocument1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
            glossaryDocument1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml");
            glossaryDocument1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2010/11/wordml");
            glossaryDocument1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
            glossaryDocument1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
            glossaryDocument1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
            glossaryDocument1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");

            DocParts docParts1 = new DocParts();

            DocPart docPart1 = new DocPart();

            DocPartProperties docPartProperties1 = new DocPartProperties();
            DocPartName docPartName1 = new DocPartName(){ Val = "DefaultPlaceholder_1081868558" };

            Category category1 = new Category();
            Name name1 = new Name(){ Val = "General" };
            Gallery gallery1 = new Gallery(){ Val = DocPartGalleryValues.Placeholder };

            category1.Append(name1);
            category1.Append(gallery1);

            DocPartTypes docPartTypes1 = new DocPartTypes();
            DocPartType docPartType1 = new DocPartType(){ Val = DocPartValues.SdtPlaceholder };

            docPartTypes1.Append(docPartType1);

            Behaviors behaviors1 = new Behaviors();
            Behavior behavior1 = new Behavior(){ Val = DocPartBehaviorValues.Content };

            behaviors1.Append(behavior1);
            DocPartId docPartId1 = new DocPartId(){ Val = "{F039DA22-FC7F-4FBD-92C2-651CCBF1B274}" };

            docPartProperties1.Append(docPartName1);
            docPartProperties1.Append(category1);
            docPartProperties1.Append(docPartTypes1);
            docPartProperties1.Append(behaviors1);
            docPartProperties1.Append(docPartId1);

            DocPartBody docPartBody1 = new DocPartBody();

            Paragraph paragraph19 = new Paragraph(){ RsidParagraphAddition = "00930812", RsidRunAdditionDefault = "00B75576" };

            Run run25 = new Run(){ RsidRunProperties = "003E0DED" };

            RunProperties runProperties43 = new RunProperties();
            RunStyle runStyle3 = new RunStyle(){ Val = "PlaceholderText" };

            runProperties43.Append(runStyle3);
            Text text25 = new Text();
            text25.Text = "Click here to enter text.";

            run25.Append(runProperties43);
            run25.Append(text25);

            paragraph19.Append(run25);

            docPartBody1.Append(paragraph19);

            docPart1.Append(docPartProperties1);
            docPart1.Append(docPartBody1);

            DocPart docPart2 = new DocPart();

            DocPartProperties docPartProperties2 = new DocPartProperties();
            DocPartName docPartName2 = new DocPartName(){ Val = "DefaultPlaceholder_1081868562" };

            Category category2 = new Category();
            Name name2 = new Name(){ Val = "General" };
            Gallery gallery2 = new Gallery(){ Val = DocPartGalleryValues.Placeholder };

            category2.Append(name2);
            category2.Append(gallery2);

            DocPartTypes docPartTypes2 = new DocPartTypes();
            DocPartType docPartType2 = new DocPartType(){ Val = DocPartValues.SdtPlaceholder };

            docPartTypes2.Append(docPartType2);

            Behaviors behaviors2 = new Behaviors();
            Behavior behavior2 = new Behavior(){ Val = DocPartBehaviorValues.Content };

            behaviors2.Append(behavior2);
            DocPartId docPartId2 = new DocPartId(){ Val = "{00F3F2EC-0290-443B-9815-66648EE1ADF9}" };

            docPartProperties2.Append(docPartName2);
            docPartProperties2.Append(category2);
            docPartProperties2.Append(docPartTypes2);
            docPartProperties2.Append(behaviors2);
            docPartProperties2.Append(docPartId2);

            DocPartBody docPartBody2 = new DocPartBody();

            Paragraph paragraph20 = new Paragraph(){ RsidParagraphAddition = "00930812", RsidRunAdditionDefault = "00B75576" };

            Run run26 = new Run(){ RsidRunProperties = "003E0DED" };

            RunProperties runProperties44 = new RunProperties();
            RunStyle runStyle4 = new RunStyle(){ Val = "PlaceholderText" };

            runProperties44.Append(runStyle4);
            Text text26 = new Text();
            text26.Text = "Enter any content that you want to repeat, including other content controls. You can also insert this control around table rows in order to repeat parts of a table.";

            run26.Append(runProperties44);
            run26.Append(text26);

            paragraph20.Append(run26);

            docPartBody2.Append(paragraph20);

            docPart2.Append(docPartProperties2);
            docPart2.Append(docPartBody2);

            DocPart docPart3 = new DocPart();

            DocPartProperties docPartProperties3 = new DocPartProperties();
            DocPartName docPartName3 = new DocPartName(){ Val = "B207B2DF6D0E4E13956E6616811860CA" };

            Category category3 = new Category();
            Name name3 = new Name(){ Val = "General" };
            Gallery gallery3 = new Gallery(){ Val = DocPartGalleryValues.Placeholder };

            category3.Append(name3);
            category3.Append(gallery3);

            DocPartTypes docPartTypes3 = new DocPartTypes();
            DocPartType docPartType3 = new DocPartType(){ Val = DocPartValues.SdtPlaceholder };

            docPartTypes3.Append(docPartType3);

            Behaviors behaviors3 = new Behaviors();
            Behavior behavior3 = new Behavior(){ Val = DocPartBehaviorValues.Content };

            behaviors3.Append(behavior3);
            DocPartId docPartId3 = new DocPartId(){ Val = "{1631777A-52D9-4CE4-A42F-C87B6FA35F21}" };

            docPartProperties3.Append(docPartName3);
            docPartProperties3.Append(category3);
            docPartProperties3.Append(docPartTypes3);
            docPartProperties3.Append(behaviors3);
            docPartProperties3.Append(docPartId3);

            DocPartBody docPartBody3 = new DocPartBody();

            Paragraph paragraph21 = new Paragraph(){ RsidParagraphAddition = "00EF189C", RsidParagraphProperties = "00930812", RsidRunAdditionDefault = "00930812" };

            ParagraphProperties paragraphProperties1 = new ParagraphProperties();
            ParagraphStyleId paragraphStyleId1 = new ParagraphStyleId(){ Val = "B207B2DF6D0E4E13956E6616811860CA" };

            paragraphProperties1.Append(paragraphStyleId1);

            Run run27 = new Run(){ RsidRunProperties = "00D27A45" };

            RunProperties runProperties45 = new RunProperties();
            RunStyle runStyle5 = new RunStyle(){ Val = "PlaceholderText" };

            runProperties45.Append(runStyle5);
            Text text27 = new Text();
            text27.Text = "Click here to enter text.";

            run27.Append(runProperties45);
            run27.Append(text27);

            paragraph21.Append(paragraphProperties1);
            paragraph21.Append(run27);

            docPartBody3.Append(paragraph21);

            docPart3.Append(docPartProperties3);
            docPart3.Append(docPartBody3);

            DocPart docPart4 = new DocPart();

            DocPartProperties docPartProperties4 = new DocPartProperties();
            DocPartName docPartName4 = new DocPartName(){ Val = "4B632797D8B1461898B8F461443A20E0" };

            Category category4 = new Category();
            Name name4 = new Name(){ Val = "General" };
            Gallery gallery4 = new Gallery(){ Val = DocPartGalleryValues.Placeholder };

            category4.Append(name4);
            category4.Append(gallery4);

            DocPartTypes docPartTypes4 = new DocPartTypes();
            DocPartType docPartType4 = new DocPartType(){ Val = DocPartValues.SdtPlaceholder };

            docPartTypes4.Append(docPartType4);

            Behaviors behaviors4 = new Behaviors();
            Behavior behavior4 = new Behavior(){ Val = DocPartBehaviorValues.Content };

            behaviors4.Append(behavior4);
            DocPartId docPartId4 = new DocPartId(){ Val = "{4829C634-4047-4182-9E1A-7F28677ACBC2}" };

            docPartProperties4.Append(docPartName4);
            docPartProperties4.Append(category4);
            docPartProperties4.Append(docPartTypes4);
            docPartProperties4.Append(behaviors4);
            docPartProperties4.Append(docPartId4);

            DocPartBody docPartBody4 = new DocPartBody();

            Paragraph paragraph22 = new Paragraph(){ RsidParagraphAddition = "00EF189C", RsidParagraphProperties = "00930812", RsidRunAdditionDefault = "00930812" };

            ParagraphProperties paragraphProperties2 = new ParagraphProperties();
            ParagraphStyleId paragraphStyleId2 = new ParagraphStyleId(){ Val = "4B632797D8B1461898B8F461443A20E0" };

            paragraphProperties2.Append(paragraphStyleId2);

            Run run28 = new Run(){ RsidRunProperties = "00D27A45" };

            RunProperties runProperties46 = new RunProperties();
            RunStyle runStyle6 = new RunStyle(){ Val = "PlaceholderText" };

            runProperties46.Append(runStyle6);
            Text text28 = new Text();
            text28.Text = "Click here to enter text.";

            run28.Append(runProperties46);
            run28.Append(text28);

            paragraph22.Append(paragraphProperties2);
            paragraph22.Append(run28);

            docPartBody4.Append(paragraph22);

            docPart4.Append(docPartProperties4);
            docPart4.Append(docPartBody4);

            docParts1.Append(docPart1);
            docParts1.Append(docPart2);
            docParts1.Append(docPart3);
            docParts1.Append(docPart4);

            glossaryDocument1.Append(docParts1);

            glossaryDocumentPart1.GlossaryDocument = glossaryDocument1;
        }
        public void Format(Body body, ScenarioOutline scenarioOutline)
        {
            if (this.configuration.HasTestResults)
            {
                TestResult testResult = this.testResults.GetScenarioOutlineResult(scenarioOutline);
                if (testResult == TestResult.Passed)
                {
                    body.GenerateParagraph("Passed", "Passed");
                }
                else if (testResult == TestResult.Failed)
                {
                    body.GenerateParagraph("Failed", "Failed");
                }
            }

            body.GenerateParagraph(scenarioOutline.Name, "Heading2");
            if (scenarioOutline.Tags.Count != 0)
            {
                var paragraph = new Paragraph(new ParagraphProperties(new ParagraphStyleId {
                    Val = "Normal"
                }));
                var tagrunProp = new RunProperties(new Italic(), new Color {
                    ThemeColor = ThemeColorValues.Text2
                })
                {
                    Bold = new Bold()
                    {
                        Val = false
                    }
                };
                paragraph.Append(new Run(tagrunProp, new Text("(Tags: " + string.Join(", ", scenarioOutline.Tags) + ")")));
                body.Append(paragraph);
            }
            if (!string.IsNullOrEmpty(scenarioOutline.Description))
            {
                body.GenerateParagraph(scenarioOutline.Description, "Normal");
            }

            foreach (Step step in scenarioOutline.Steps)
            {
                this.wordStepFormatter.Format(body, step);
            }

            var languageServices = this.languageServicesRegistry.GetLanguageServicesForLanguage(scenarioOutline.Feature?.Language);
            var examplesKeyword  = languageServices.ExamplesKeywords[0];

            foreach (var example in scenarioOutline.Examples)
            {
                body.Append(new Paragraph(new ParagraphProperties(new ParagraphStyleId {
                    Val = "Heading3"
                }), new Run(new RunProperties(), new Text(examplesKeyword + ":"))));

                if (example.Tags.Count != 0)
                {
                    var tagrunProp = new RunProperties(new Italic(), new Color {
                        ThemeColor = ThemeColorValues.Text2
                    })
                    {
                        Bold = new Bold()
                        {
                            Val = false
                        }
                    };
                    body.Append(new Paragraph(new ParagraphProperties(new ParagraphStyleId {
                        Val = "Normal"
                    }),
                                              new Run(tagrunProp, new Text("(Tags: " + string.Join(", ", example.Tags) + ")"))));
                }

                if (!string.IsNullOrWhiteSpace(example.Description))
                {
                    body.Append(new Paragraph(new ParagraphProperties(new ParagraphStyleId {
                        Val = "Normal"
                    }),
                                              new Run(new Text(example.Description))));
                }

                this.wordTableFormatter.Format(body, example.TableArgument);
            }
        }
Example #46
0
        public void CreateWordFile(string FileName, List <string> Tabs)
        {
            using (WordprocessingDocument doc = WordprocessingDocument.Create(FileName, WordprocessingDocumentType.Document))
            {
                //文档主对象
                MainDocumentPart mdp = doc.AddMainDocumentPart();
                mdp.Document = new Document();
                Body body = mdp.Document.AppendChild(new Body());
                //获取表数据
                DataTable TabDT = DBStructure.GetTables(Tabs);
                if (TabDT != null && TabDT.Rows.Count > 0)
                {
                    //Console.WriteLine("共计: " + TabDT.Rows.Count.ToString() + " 个表");
                    //Console.WriteLine("序号\t表名\t\t\t\t表描述");
                    int j = 0;
                    foreach (DataRow dr in TabDT.Rows)
                    {
                        j++;
                        //逐个创建表
                        string    TabName        = dr["name"].ToString().Trim();
                        string    TabDescription = (dr["desctxt"] == DBNull.Value ? "" : dr["desctxt"].ToString().Trim());
                        DataTable ColsDT         = DBStructure.GetTableInfo(TabName);

                        if (ColsDT != null && ColsDT.Rows.Count > 0)
                        {
                            #region 插入空段落
                            Paragraph p = mdp.Document.Body.AppendChild(new Paragraph()
                            {
                                RsidParagraphAddition = "007557D9", RsidRunAdditionDefault = "007557D9"
                            });
                            p.AppendChild(new Run(new Text("")));
                            #endregion

                            #region 添加表和表头
                            Table table1 = new Table();

                            TableProperties tableProperties = new TableProperties();
                            TableWidth      tableWidth      = new TableWidth()
                            {
                                Width = "0", Type = TableWidthUnitValues.Auto
                            };

                            TableBorders tableBorders = new TableBorders();
                            TopBorder    topBorder    = new TopBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };
                            LeftBorder leftBorder = new LeftBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };
                            BottomBorder bottomBorder = new BottomBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };
                            RightBorder rightBorder = new RightBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };

                            tableBorders.Append(topBorder);
                            tableBorders.Append(leftBorder);
                            tableBorders.Append(bottomBorder);
                            tableBorders.Append(rightBorder);

                            TableLayout tableLayout = new TableLayout()
                            {
                                Type = TableLayoutValues.Fixed
                            };
                            TableLook tableLook = new TableLook()
                            {
                                Val = "0000"
                            };

                            tableProperties.Append(tableWidth);
                            tableProperties.Append(tableBorders);
                            tableProperties.Append(tableLayout);
                            tableProperties.Append(tableLook);

                            TableGrid tableGrid = new TableGrid();
                            int[]     ColWidths = new[] { 1800, 1000, 700, 700, 700, 700, 3100 };
                            for (int i = 0; i < 7; i++)
                            {
                                GridColumn gCol = new GridColumn()
                                {
                                    Width = ColWidths[i].ToString()
                                };
                                tableGrid.Append(gCol);
                            }

                            TableRow nameRow = new TableRow()
                            {
                                RsidTableRowAddition = "007557D9", RsidTableRowProperties = "00096DED"
                            };

                            TablePropertyExceptions tablePropertyExceptions_name = new TablePropertyExceptions();
                            TableCellMarginDefault  tableCellMarginDefault_name  = new TableCellMarginDefault();
                            TopMargin topMargin_name = new TopMargin()
                            {
                                Width = "0", Type = TableWidthUnitValues.Dxa
                            };
                            BottomMargin bottomMargin_name = new BottomMargin()
                            {
                                Width = "0", Type = TableWidthUnitValues.Dxa
                            };

                            tableCellMarginDefault_name.Append(topMargin_name);
                            tableCellMarginDefault_name.Append(bottomMargin_name);

                            tablePropertyExceptions_name.Append(tableCellMarginDefault_name);

                            TableRowProperties tableRowProperties_name = new TableRowProperties();
                            CantSplit          cantSplit_name          = new CantSplit();
                            TableHeader        tableHeader_name        = new TableHeader();

                            tableRowProperties_name.Append(cantSplit_name);
                            tableRowProperties_name.Append(tableHeader_name);

                            TableCell tableCell_name = new TableCell();

                            TableCellProperties tableCellProperties_name = new TableCellProperties();
                            TableCellWidth      tableCellWidth_name      = new TableCellWidth()
                            {
                                Width = "8500", Type = TableWidthUnitValues.Dxa
                            };
                            GridSpan gridSpan_name = new GridSpan()
                            {
                                Val = 7
                            };

                            TableCellBorders tableCellBorders_name = new TableCellBorders();
                            TopBorder        topBorder_name        = new TopBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };
                            BottomBorder bottomBorder_name = new BottomBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };
                            RightBorder rightBorder_name = new RightBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };
                            LeftBorder leftBorder_name = new LeftBorder()
                            {
                                Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                            };

                            tableCellBorders_name.Append(topBorder_name);
                            tableCellBorders_name.Append(rightBorder_name);
                            tableCellBorders_name.Append(bottomBorder_name);
                            tableCellBorders_name.Append(leftBorder_name);
                            Shading shading_name = new Shading()
                            {
                                Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto"
                            };
                            TableCellVerticalAlignment tableCellVerticalAlignment_name = new TableCellVerticalAlignment()
                            {
                                Val = TableVerticalAlignmentValues.Center
                            };

                            tableCellProperties_name.Append(tableCellWidth_name);
                            tableCellProperties_name.Append(gridSpan_name);
                            tableCellProperties_name.Append(tableCellBorders_name);
                            tableCellProperties_name.Append(shading_name);
                            tableCellProperties_name.Append(tableCellVerticalAlignment_name);

                            Paragraph paragraph_name = new Paragraph()
                            {
                                RsidParagraphAddition = "007557D9", RsidRunAdditionDefault = "007557D9"
                            };

                            Run run_name = new Run();

                            RunProperties runProperties_name = new RunProperties();
                            RunFonts      runFonts_name      = new RunFonts()
                            {
                                Hint = FontTypeHintValues.EastAsia
                            };

                            runProperties_name.Append(runFonts_name);
                            Text text_name = new Text();
                            text_name.Text = TabName + ":" + TabDescription;

                            run_name.Append(runProperties_name);
                            run_name.Append(text_name);

                            paragraph_name.Append(run_name);

                            tableCell_name.Append(tableCellProperties_name);
                            tableCell_name.Append(paragraph_name);

                            nameRow.Append(tablePropertyExceptions_name);
                            nameRow.Append(tableRowProperties_name);
                            nameRow.Append(tableCell_name);
                            table1.AppendChild(nameRow);
                            #endregion

                            //表头定义
                            TableRow headerRow = new TableRow()
                            {
                                RsidTableRowAddition = "007557D9", RsidTableRowProperties = "007557D9"
                            };
                            TablePropertyExceptions tablePropertyExceptions_header = new TablePropertyExceptions();
                            TableCellMarginDefault  tableCellMarginDefault_header  = new TableCellMarginDefault();
                            TopMargin topMargin_header = new TopMargin()
                            {
                                Width = "0", Type = TableWidthUnitValues.Dxa
                            };
                            BottomMargin bottomMargin_header = new BottomMargin()
                            {
                                Width = "0", Type = TableWidthUnitValues.Dxa
                            };
                            tableCellMarginDefault_header.Append(topMargin_header);
                            tableCellMarginDefault_header.Append(bottomMargin_header);
                            tablePropertyExceptions_header.Append(tableCellMarginDefault_header);
                            TableRowProperties tableRowProperties_header = new TableRowProperties();
                            CantSplit          cantSplit_header          = new CantSplit();
                            tableRowProperties_header.Append(cantSplit_header);

                            string[] HeaderArray = new string[] { "列名", "类型", "长度", "可空", "自增", "主键", "描述" };
                            int      HeadIndex   = 0;
                            foreach (string headstr in HeaderArray)
                            {
                                TableCell titleCell = new TableCell();

                                TableCellProperties tableCellProperties_header = new TableCellProperties();
                                TableCellWidth      tableCellWidth_header      = new TableCellWidth()
                                {
                                    Width = ColWidths[HeadIndex].ToString(), Type = TableWidthUnitValues.Dxa
                                };

                                TableCellBorders tableCellBorders_header = new TableCellBorders();
                                TopBorder        topBorder_header        = new TopBorder()
                                {
                                    Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                };
                                BottomBorder bottomBorder_header = new BottomBorder()
                                {
                                    Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                };
                                RightBorder rightBorder_header = new RightBorder()
                                {
                                    Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                };
                                LeftBorder leftBorder_header = new LeftBorder()
                                {
                                    Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                };

                                tableCellBorders_header.Append(topBorder_header);
                                tableCellBorders_header.Append(bottomBorder_header);
                                tableCellBorders_header.Append(rightBorder_header);
                                tableCellBorders_header.Append(leftBorder_header);
                                Shading shading_header = new Shading()
                                {
                                    Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto"
                                };

                                tableCellProperties_header.Append(tableCellWidth_header);
                                tableCellProperties_header.Append(tableCellBorders_header);
                                tableCellProperties_header.Append(shading_header);

                                Paragraph paragraph_header = new Paragraph()
                                {
                                    RsidParagraphAddition = "007557D9", RsidRunAdditionDefault = "007557D9"
                                };

                                Run run_header = new Run();

                                RunProperties runProperties_header = new RunProperties();
                                RunFonts      runFonts_header      = new RunFonts()
                                {
                                    Hint = FontTypeHintValues.EastAsia
                                };

                                runProperties_header.Append(runFonts_header);
                                Text text_header = new Text();
                                text_header.Text = headstr;

                                run_header.Append(runProperties_header);
                                run_header.Append(text_header);

                                paragraph_header.Append(run_header);

                                titleCell.Append(tableCellProperties_header);
                                titleCell.Append(paragraph_header);


                                headerRow.Append(titleCell);
                                HeadIndex++;
                            }
                            headerRow.Append(tablePropertyExceptions_header);
                            headerRow.Append(tableRowProperties_header);
                            table1.AppendChild(headerRow);

                            foreach (DataRow subdr in ColsDT.Rows)
                            {
                                TableRow dataRow = new TableRow();
                                TablePropertyExceptions tablePropertyExceptions_data = new TablePropertyExceptions();
                                TableCellMarginDefault  tableCellMarginDefault_data  = new TableCellMarginDefault();
                                TopMargin topMargin_data = new TopMargin()
                                {
                                    Width = "0", Type = TableWidthUnitValues.Dxa
                                };
                                BottomMargin bottomMargin_data = new BottomMargin()
                                {
                                    Width = "0", Type = TableWidthUnitValues.Dxa
                                };
                                tableCellMarginDefault_data.Append(topMargin_data);
                                tableCellMarginDefault_data.Append(bottomMargin_data);
                                tablePropertyExceptions_data.Append(tableCellMarginDefault_data);
                                TableRowProperties tableRowProperties_data = new TableRowProperties();
                                CantSplit          cantSplit_data          = new CantSplit();
                                tableRowProperties_data.Append(cantSplit_data);

                                int DataIndex = 0;
                                foreach (string header in HeaderArray)
                                {
                                    TableCell dataCell = new TableCell();

                                    TableCellProperties tableCellProperties_data = new TableCellProperties();
                                    TableCellWidth      tableCellWidth_data      = new TableCellWidth()
                                    {
                                        Width = ColWidths[DataIndex].ToString(), Type = TableWidthUnitValues.Dxa
                                    };

                                    TableCellBorders tableCellBorders_data = new TableCellBorders();
                                    TopBorder        topBorder_data        = new TopBorder()
                                    {
                                        Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                    };
                                    BottomBorder bottomBorder_data = new BottomBorder()
                                    {
                                        Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                    };
                                    RightBorder rightBorder_data = new RightBorder()
                                    {
                                        Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                    };
                                    LeftBorder leftBorder_data = new LeftBorder()
                                    {
                                        Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)2U, Space = (UInt32Value)0U
                                    };

                                    tableCellBorders_data.Append(topBorder_data);
                                    tableCellBorders_data.Append(bottomBorder_data);
                                    tableCellBorders_data.Append(rightBorder_data);
                                    tableCellBorders_data.Append(leftBorder_data);
                                    Shading shading_data = new Shading()
                                    {
                                        Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto"
                                    };

                                    tableCellProperties_data.Append(tableCellWidth_data);
                                    tableCellProperties_data.Append(tableCellBorders_data);
                                    tableCellProperties_data.Append(shading_data);

                                    Paragraph paragraph_data = new Paragraph()
                                    {
                                        RsidParagraphAddition = "007557D9", RsidRunAdditionDefault = "007557D9"
                                    };

                                    Run run_data = new Run();

                                    RunProperties runProperties_data = new RunProperties();
                                    RunFonts      runFonts_data      = new RunFonts()
                                    {
                                        Hint = FontTypeHintValues.EastAsia
                                    };

                                    runProperties_data.Append(runFonts_data);
                                    Text text_data = new Text();
                                    text_data.Text = subdr[header].ToString();

                                    run_data.Append(runProperties_data);
                                    run_data.Append(text_data);

                                    paragraph_data.Append(run_data);

                                    dataCell.Append(tableCellProperties_data);
                                    dataCell.Append(paragraph_data);

                                    dataRow.Append(dataCell);
                                    DataIndex++;
                                }
                                dataRow.Append(tablePropertyExceptions_data);
                                dataRow.Append(tableRowProperties_data);

                                table1.AppendChild(dataRow);
                            }
                            //Console.WriteLine(string.Format("{0}\t{1}\t\t\t\t{2}", j, TabName, TabDescription));
                            CurrCount++;
                            ShowProgress(CurrCount, TabCount);
                            body.Append(table1);
                            Paragraph p1 = new Paragraph(new Run(new Text("")));
                            body.Append(p1);
                        }
                    }
                }
            }
        }
Example #47
0
 protected RunProperties SetBoldRunProperties(RunProperties runProperties)
 {
     runProperties.Bold = new Bold();
     return runProperties;
 }
Example #48
0
        public static Table GetParagraph(ReportTable reportTable, Int32Value width)
        {
            Table           table   = new Table();
            TableProperties tblProp = new TableProperties(
                new TableBorders(
                    new TopBorder()
            {
                Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 4
            },
                    new BottomBorder()
            {
                Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 4
            },
                    new LeftBorder()
            {
                Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 4
            },
                    new RightBorder()
            {
                Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 4
            },
                    new InsideHorizontalBorder()
            {
                Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 4
            },
                    new InsideVerticalBorder()
            {
                Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 4
            }
                    )
                );

            tblProp.TableWidth = new TableWidth()
            {
                Width = "0", Type = TableWidthUnitValues.Auto
            };
            TableGrid  tableGrid1  = new TableGrid();
            GridColumn gridColumn1 = new GridColumn()
            {
                Width = width.ToString()
            };
            GridColumn gridColumn2 = new GridColumn()
            {
                Width = width.ToString()
            };
            GridColumn gridColumn3 = new GridColumn()
            {
                Width = width.ToString()
            };

            tableGrid1.Append(gridColumn1);
            tableGrid1.Append(gridColumn2);
            tableGrid1.Append(gridColumn3);

            table.Append(tblProp);
            table.Append(tableGrid1);

            int count = reportTable.Value.Count;
            int cols  = reportTable.Column;
            int j     = 0;

            foreach (List <string> strs in reportTable.Value)
            {
                TableRow row = new TableRow();
                for (int i = 0; i < cols; i++)
                {
                    TableCell           cell = new TableCell();
                    TableCellProperties tableCellProperties = new TableCellProperties();
                    TableCellMargin     margin = new TableCellMargin();
                    margin.LeftMargin = new LeftMargin()
                    {
                        Width = "100", Type = TableWidthUnitValues.Dxa
                    };
                    margin.RightMargin = new RightMargin()
                    {
                        Width = "100", Type = TableWidthUnitValues.Dxa
                    };
                    tableCellProperties.Append(margin);
                    Paragraph par = new Paragraph();
                    Run       run = new Run();
                    if (j == 0 && reportTable.IsHaveColumn)
                    {
                        Shading shading1 = new Shading()
                        {
                            Val = ShadingPatternValues.Clear, Color = "auto", Fill = "AEAAAA", ThemeFill = ThemeColorValues.Background2, ThemeFillShade = "BF"
                        };
                        RunProperties rPr = new RunProperties();
                        tableCellProperties.Append(shading1);
                        rPr.Append(new Bold());
                        run.Append(rPr);
                    }
                    if (strs.Count != cols && i >= strs.Count - 1)
                    {
                        HorizontalMerge verticalMerge = new HorizontalMerge();
                        if (i == strs.Count - 1)
                        {
                            RunProperties rPr = new RunProperties();
                            rPr.Append(new Bold());
                            run.Append(rPr);
                            verticalMerge.Val = MergedCellValues.Restart;
                            run.Append(CreateText(strs[i]));
                        }
                        else
                        {
                            verticalMerge.Val = MergedCellValues.Continue;
                        }
                        tableCellProperties.Append(verticalMerge);
                    }
                    else
                    {
                        run.Append(CreateText(strs[i]));
                    }
                    par.Append(run);
                    cell.Append(tableCellProperties);
                    cell.Append(par);
                    row.Append(cell);
                }
                j++;
                table.Append(row);
            }

            return(table);
        }
Example #49
0
        public static void Print(Ticket SelectedTicket, string path)
        {
            string fileName = SelectedTicket.TicketHolder.Trim() + SelectedTicket.TicketType.Name.Trim() + ".docx";
            string finalPath = path + "\\" + fileName;

            string code = SelectedTicket.TicketHolder + SelectedTicket.ID;

            try
            {
                File.Copy("template.docx", finalPath, true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            WordprocessingDocument doc = WordprocessingDocument.Open(finalPath, true);
            IDictionary<string, BookmarkStart> bookmarks = new Dictionary<string, BookmarkStart>();

            foreach (BookmarkStart bms in doc.MainDocumentPart.RootElement.Descendants<BookmarkStart>())
            {
                bookmarks[bms.Name] = bms;
            }
            string TicketCode = SelectedTicket.ID + SelectedTicket.TicketHolder[0] + SelectedTicket.TicketHolder[1] + SelectedTicket.TicketHolder[2];
            bookmarks["TicketName"].Parent.InsertAfter<Run>(new Run(new Text("Electronic Rampage")), bookmarks["TicketName"]);
            bookmarks["Name"].Parent.InsertAfter<Run>(new Run(new Text(SelectedTicket.TicketHolder)), bookmarks["Name"]);
            bookmarks["Code"].Parent.InsertAfter<Run>(new Run(new Text(TicketCode)), bookmarks["Code"]);
            bookmarks["TicketType"].Parent.InsertAfter<Run>(new Run(new Text(SelectedTicket.TicketType.Name)), bookmarks["TicketType"]);

            Run run = new Run(new Text(code));
            RunProperties prop = new RunProperties();
            RunFonts font = new RunFonts() { Ascii = "Free 3 of 9 Extended", HighAnsi = "Free 3 of 9 Extended" };
            FontSize size = new FontSize() { Val = SelectedTicket.ID.ToString() };

            prop.Append(font);
            prop.Append(size);
            run.PrependChild<RunProperties>(prop);

            bookmarks["Barcode"].Parent.InsertAfter<Run>(run, bookmarks["Barcode"]);

            doc.Close();
            System.Windows.MessageBox.Show("Ticket is aangemaakt");
        }
Example #50
0
        public static WmlDocument AppendParagraphToDocument(
            WmlDocument wmlDoc,
            string strParagraph,
            bool isBold,
            bool isItalic,
            bool isUnderline,
            string foreColor,
            string backColor,
            string styleName)
        {
            using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(wmlDoc))
            {
                using (WordprocessingDocument wDoc = streamDoc.GetWordprocessingDocument())
                {
                    StyleDefinitionsPart part = wDoc.MainDocumentPart.StyleDefinitionsPart;

                    Body body = wDoc.MainDocumentPart.Document.Body;

                    SectionProperties sectionProperties = body.Elements <SectionProperties>().FirstOrDefault();

                    Paragraph     paragraph     = new Paragraph();
                    Run           run           = paragraph.AppendChild(new Run());
                    RunProperties runProperties = new RunProperties();

                    if (isBold)
                    {
                        runProperties.AppendChild(new Bold());
                    }

                    if (isItalic)
                    {
                        runProperties.AppendChild(new Italic());
                    }


                    if (!string.IsNullOrEmpty(foreColor))
                    {
                        int colorValue = System.Drawing.Color.FromName(foreColor).ToArgb();
                        if (colorValue == 0)
                        {
                            throw new OpenXmlPowerToolsException(String.Format("Add-DocxText: The specified color {0} is unsupported, Please specify the valid color. Ex, Red, Green", foreColor));
                        }

                        string ColorHex = string.Format("{0:x6}", colorValue);
                        runProperties.AppendChild(new DocumentFormat.OpenXml.Wordprocessing.Color()
                        {
                            Val = ColorHex.Substring(2)
                        });
                    }

                    if (isUnderline)
                    {
                        runProperties.AppendChild(new Underline()
                        {
                            Val = UnderlineValues.Single
                        });
                    }

                    if (!string.IsNullOrEmpty(backColor))
                    {
                        int colorShade = System.Drawing.Color.FromName(backColor).ToArgb();
                        if (colorShade == 0)
                        {
                            throw new OpenXmlPowerToolsException(String.Format("Add-DocxText: The specified color {0} is unsupported, Please specify the valid color. Ex, Red, Green", foreColor));
                        }

                        string ColorShadeHex = string.Format("{0:x6}", colorShade);
                        runProperties.AppendChild(new Shading()
                        {
                            Fill = ColorShadeHex.Substring(2), Val = ShadingPatternValues.Clear
                        });
                    }

                    if (!string.IsNullOrEmpty(styleName))
                    {
                        Style style = part.Styles.Elements <Style>().Where(s => s.StyleId == styleName).FirstOrDefault();
                        //if the specified style is not present in word document add it
                        if (style == null)
                        {
                            using (MemoryStream memoryStream = new MemoryStream())
                            {
                                #region Default.dotx Template has been used to get all the paragraph styles
                                string base64 =
                                    @"UEsDBBQABgAIAAAAIQDTMB8uXgEAACAFAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbLSUy27CMBBF
95X6D5G3VWLooqoqAos+li1S6QcYewJW/ZI9vP6+EwKoqiCRCmwiJTP33jNWxoPR2ppsCTFp70rW
L3osAye90m5Wsq/JW/7IsoTCKWG8g5JtILHR8PZmMNkESBmpXSrZHDE8cZ7kHKxIhQ/gqFL5aAXS
a5zxIOS3mAG/7/UeuPQOwWGOtQcbDl6gEguD2euaPjckEUxi2XPTWGeVTIRgtBRIdb506k9Kvkso
SLntSXMd0h01MH40oa6cDtjpPuhoolaQjUXEd2Gpi698VFx5ubCkLNptjnD6qtISDvraLUQvISU6
c2sKBBtoAiis0G7Pf5Ij4cZAujxF49sdD4gkuAbAzrkTYQXTz6tR/DLvBKkodyKmBi6PcbDuhEDa
QGie/bM5tjZtkdQ5jj4k2uj4j7H3K1urcxo4QETd/tcdEsn67Pmgvg0UqCPZfHu/DX8AAAD//wMA
UEsDBBQABgAIAAAAIQAekRq37wAAAE4CAAALAAAAX3JlbHMvLnJlbHOsksFqwzAMQO+D/YPRvVHa
wRijTi9j0NsY2QcIW0lME9vYatf+/TzY2AJd6WFHy9LTk9B6c5xGdeCUXfAallUNir0J1vlew1v7
vHgAlYW8pTF41nDiDJvm9mb9yiNJKcqDi1kVis8aBpH4iJjNwBPlKkT25acLaSIpz9RjJLOjnnFV
1/eYfjOgmTHV1mpIW3sHqj1FvoYdus4ZfgpmP7GXMy2Qj8Lesl3EVOqTuDKNain1LBpsMC8lnJFi
rAoa8LzR6nqjv6fFiYUsCaEJiS/7fGZcElr+54rmGT827yFZtF/hbxucXUHzAQAA//8DAFBLAwQU
AAYACADRagZB/Fz9fNYBAAALAwAAEAAAAGRvY1Byb3BzL2FwcC54bWztvQdgHEmWJSYvbcp7f0r1
StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee++997o7nU4n
99//P1xmZAFs9s5K2smeIYCqyB8/fnwfPyL+x7/3H3z8e7xblOllXjdFtfzso93xzkdpvpxWs2J5
8dlH6/Z8++CjtGmz5Swrq2X+2UfXefPR73H0OFs9ellXq7xui7xJCcayeXTZfvbRvG1Xj+7ebabz
fJE1Y2qxpC/Pq3qRtfRnfXG3Oj8vpvnTarpe5Mv27t7Ozqd3Z9UU0JqffHO9IvgKL1t9XXj5uzZf
zvLZ9sri+BHj/CZfrMqszY8e3w3+wh9Vm5VvikV+tCNf2r95sNlF3hzt8jfyOz79blXPGm0vv+PT
k3lWZ9OWaKpfeR/g++PVqiymWUsUP/qimNZVU5236Zc8jhRg+CW/Fd6iEb7Op+u6aK8VrP8JWjwv
lrnpUn4XzOvsos5Wc/OV9wG+fz3NyvyE6HR0npVNzk3cZwr3bfPV6k31FLRyrcLPw5F/t2jnr1fZ
1CIU/Yr7py/yGY3F799+hhbfJqaoS3RGQJYX+cxr2f9OKfyTwtJHu/fHO/QYkpqPhRKWO47+H1BL
AwQUAAYACADRagZBUsP9QroBAABvAgAAEQAAAGRvY1Byb3BzL2NvcmUueG1s7b0HYBxJliUmL23K
e39K9UrX4HShCIBgEyTYkEAQ7MGIzeaS7B1pRyMpqyqBymVWZV1mFkDM7Z28995777333nvvvfe6
O51OJ/ff/z9cZmQBbPbOStrJniGAqsgfP358Hz8iHv8e7xZlepnXTVEtP/tod7zzUZovp9WsWF58
9tFXb55tH3yUNm22nGVltcw/++g6bz76PY6Sx9PVo2lV5y/rapXXbZE3KQFaNo+mq88+mrft6tHd
u810ni+yZkwtlvTleVUvspb+rC/urrLp2+wiv7u3s/Pp3UXeZrOsze4C4PbKQvxIQc6mFuRqXZcM
YDa9m5f5Il+2zd3d8e5d17bN60UTfYG/8VouivZ6lUebmi9t63dNYRteXV2Nr+5xU8J/9+7v/cXz
1zzU7WIJUk3zj44ez6aPpnWetVV9dJIVbVks0+NmXubX26+qslxky8d3vSYgZ5k17RdE+PMinz25
vsuf1fllgZk52n181//zsY5TAOSzlPB7JKMx33z33snTN88+Otrb2d3b3nmwvXf/ze6DR3v3H+3s
/BT6Dt53ABeKwW0g3nuzt/tovwPRADhijEMeOfp/AFBLAwQUAAYACAAAACEA1mSzUfQAAAAxAwAA
HAAAAHdvcmQvX3JlbHMvZG9jdW1lbnQueG1sLnJlbHOskstqwzAQRfeF/oOYfS07fVBC5GxKIdvW
/QBFHj+oLAnN9OG/r0hJ69BguvByrphzz4A228/BineM1HunoMhyEOiMr3vXKnipHq/uQRBrV2vr
HSoYkWBbXl5sntBqTkvU9YFEojhS0DGHtZRkOhw0ZT6gSy+Nj4PmNMZWBm1edYtyled3Mk4ZUJ4w
xa5WEHf1NYhqDPgftm+a3uCDN28DOj5TIT9w/4zM6ThKWB1bZAWTMEtEkOdFVkuK0B+LYzKnUCyq
wKPFqcBhnqu/XbKe0y7+th/G77CYc7hZ0qHxjiu9txOPn+goIU8+evkFAAD//wMAUEsDBBQABgAI
ANFqBkF65TN3MwIAAJAFAAARAAAAd29yZC9kb2N1bWVudC54bWztvQdgHEmWJSYvbcp7f0r1Stfg
dKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee++997o7nU4n99//
P1xmZAFs9s5K2smeIYCqyB8/fnwfPyL+x7/3H3z8e7xblOllXjdFtfzso93xzkdpvpxWs2J58dlH
6/Z8++CjtGmz5Swrq2X+2UfXefPR73H0+OrRrJquF/myTQnAsnl0tZp+9tG8bVeP7t5tpvN8kTXj
RTGtq6Y6b8fTanG3Oj8vpvndq6qe3d3b2d3h31Z1Nc2bhno7yZaXWfORglv0oVWrfElfnlf1Imvp
z/ri7iKr365X2wR9lbXFpCiL9ppg73xqwFQ0hnr5SEFsW4TwyiNBSH+YN+rb9CuvPFUKcI9367wk
HKplMy9WbhhfFxp9OTdALjcN4nJRmnZXq939D5uDp3V2RT8cwNugP5OXFqVgvhni7s4tZgQg7Bu3
QSHs02CyyIql6/hrkcYj7u799wOw1wWwung/AN3J+byu1isHrfgwaGfLtxYW5Po9YOkk+0Nr3gtA
D5nX82xFEriYPjq7WFZ1NikJI5qylKiegq0/gsaZVLNr/Fyld/Gjyafty5o/uHj9g/QKrLK7t7dP
Guzq0Zx+v3+A3+9Kiy+ymj5uK2Lp3X1pUxcX89b9Oanatlq4v8v83Pt2nmeznJTDgz3+87yqWu/P
i3XLf5r+plXZ0MfNKpvm2og+v+uQvmuGc9dp0qP/B1BLAwQUAAYACADRagZB3iZxVZoCAAAzBwAA
EgAAAHdvcmQvZm9udFRhYmxlLnhtbO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3m
kuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrI
Hz9+fB8/Iv7Hv/cffPx7vFuU6WVeN0W1/Oyj3fHOR2m+nFazYnnx2Ufr9nz74KO0abPlLCurZf7Z
R9d589HvcfT46tF5tWyblN5eNo8W088+mrft6tHdu810ni+yZlyt8iV9eV7Vi6ylP+uLu4usfrte
bU+rxSpri0lRFu313b2dnU8/UjD1baBU5+fFNH9aTdeLfNny+3frvCSI1bKZF6vGQLu6DbSrqp6t
6mqaNw2NeFEKvEVWLC2Y3f0eoEUxraumOm/HNBjFiEHR67s7/NuidADuvx+APQtgMX10drGs6mxS
EukJk5SAfWSon149WmYL+uIkK4tJXfAXq2xZNfkufXeZlZ99tLO382znPv2L//Z37uHfj9K7aDmd
Z3WTt7bljn5+ni2K8tp83FwVTaPfrIp2OjdfXGZ1Abz0u6a4oG/WzWTns49Od+jZe/bsI/lk97OP
9umD4xP7yR6642dXP7lnP9nBJ1OGIy0ePtNPdv021OldIUOPHK+Lxev1kqmRle0L+szg/J//DX/s
f/b3/6lmND1K7e58SrDv0U/9L06pg0+jlMrWbfWehNLR3HOE2js4eGaI4BNq99MbCAUK774noY4J
sXKAa54QLfaVb/Z+aFyzd+xzzQl98uBg35DHcc3Dm7nm2ftyjQpR+ry4mLeDonTPkOOHJErHwHvv
tCNKezsPnvSIYnhmmCg77y1Kb4pF3qQv8qv0VbXIlgNk2SNeuUdaZp81zb33JEvNkN+PLD9sXtFf
mqP/B1BLAwQUAAQACADRagZBhoJdSR0EAAB5CQAAEQAAAHdvcmQvc2V0dGluZ3MueG1s7b0HYBxJ
liUmL23Ke39K9UrX4HShCIBgEyTYkEAQ7MGIzeaS7B1pRyMpqyqBymVWZV1mFkDM7Z2899577733
3nvvvfe6O51OJ/ff/z9cZmQBbPbOStrJniGAqsgfP358Hz8i/se/9x98/Hu8W5TpZV43RbX87KPd
8c5Hab6cVrNiefHZR+v2fPvgo7Rps+UsK6tl/tlH13nz0e9x9PjqUZO3LTVqUgKwbB4tpp99NG/b
1aO7d5vpPF9kzbha5Uv68ryqF1lLf9YXdxdZ/Xa92p5Wi1XWFpOiLNrru3s7O59+pGAq6rRePlIQ
24tiWldNdd7ilUfV+XkxzfWHeaO+Tb/yytNqul7ky5Z7vFvnJeFQLZt5sWoMtMXXhUZfzg2Qy02D
uFyUpt3V7s4thntV1TP7xm3QwwuruprmTUMTtCgNgsXSdbzfA2T7HlPfOkQGRa/v7vBvPub33w/A
XgdAU95mJPLV82JSZ/W1P4zF9NHZxbKqs0lJPEnDSQmjj8CWNPDq/HWbtXlKPLrKy5I5eVrmGb13
9eiizhbEhfaTu3hplp9n67J9k01et9WKWl1mhN+DnQP9fn69mudL5pafIikwDfb37muD6Tyrs2mb
169X2ZQ6PKmWbV2VpuGselG1J8T0Nc2JeYVlAL9lq1V5/aTOs7f05qt1mTfSYt3kz06fZ9fVuvVf
eS2CR7CX2YJGHwjTF9UsxzDXdXH7CfrI4LlrxxPtqSI9URez/A3I/rq9LvNnNM7XxQ/y4+XsO+um
LQgkU+kDUNiIAU0Cdf0lccqb61X+LM/aNZH0Z6s3nrZnZbH6oqjrqj5bzkjcf/Z6K87P85p6KIh5
vyB2LOrqikn97TybkYb+0I7vOqZbPIK+elmb3zCP6UIan2SLSV1k6Res0e6iyaR++6RYmgaTnGQ0
D756vZ6Yb7e39ZtmkZXlMxIL882OfjErmtXT/Fz+KL/I6gsH27Sp4x+ToH7HwpsSrfL687par/Tr
qzpbySyZNrv7++bdYtk+Lxbmi2Y9eW3fW5J68b5bL2dfXtZCM0epq0ct0ZtZ/nnG88aNV+32k1eg
dJ417XFTZJ999IP59skLfDQpZjRdWb39+thMfVm/xrTlX5DUy+xPLnY/+6gsLubtLt5p6a8ZmUn+
Y3Kxp9/t8Xd78h3/kU1BAGqtv7jP9sxnXrt75rN77rN989m+++y++ey+++xT89mn+IyUYV6TVn1L
jGh+xefnVVlWV/ns2+773kdKhWaerfKnonSbo8eVfKBauEkvH+XvWhL2WdGS87EqZovsHU3lzt6n
/L42L0Uz+o3xHVqvQhCzrM2sEARvs1B0sIE5mBbEvK+vFxOnw8eKe1k0JLor0vdtVZsvR/Ll7n22
BO0b4npW5vn5k6zJZyp9xmU6+n8AUEsDBBQABAAIANFqBkEr9+zhUxIAABWtAAAPAAAAd29yZC9z
dHlsZXMueG1s7b0HYBxJliUmL23Ke39K9UrX4HShCIBgEyTYkEAQ7MGIzeaS7B1pRyMpqyqBymVW
ZV1mFkDM7Z28995777333nvvvfe6O51OJ/ff/z9cZmQBbPbOStrJniGAqsgfP358Hz8i/se/9x98
/Hu8W5TpZV43RbX87KPd8c5Hab6cVrNiefHZR+v2fPvgo7Rps+UsK6tl/tlH13nz0e9x9PjqUdNe
l3mT0uvL5tFi+tlH87ZdPbp7t5nO80XWjKtVvqQvz6t6kbX0Z31xd5HVb9er7Wm1WGVtMSnKor2+
u7ez8+lHCqa+DZTq/LyY5k+r6XqRL1t+/26dlwSxWjbzYtUYaFe3gXZV1bNVXU3zpqEhL0qBt8iK
pQWzu98DtCimddVU5+2YBqMYMSh6fXeHf1uUDsD99wOwZwEspo/OLpZVnU1Koj1hkhKwj0D+WTV9
mp9n67Jt8Gf9stY/9S/+8axatk169ShrpkXxhnomIIuC4H37eNkUH9E3c/wS/SbPmva4KTL/y1P9
DN9Pm9b75kkxo7fuMmP8gL69zMrPPtrbsx+dNL0Py2x5YT7Ml9tfvfZ7/eyjn862v/MSH00I9Gcf
ZfX262N+866O72531KvuX9z1KpsW3FF23ubEYDS/gFoW4Oa9B5+aP16tQeJs3Vaml5X24sO926M8
MR6x4WuRBvo2P39eTd/ms9ctffHZR9wZffjV2cu6qGri+M8+evhQP3ydL4pvF7NZvvQaLufFLP/u
PF9+1eQz9/lPPGOu1Q+m1XpJv997sMvcUDaz03fTfAUZoG+XGSbmBV4o0XpduM759V9kgO2ayYgB
mOcZ9EC624Xx8P1h7EVhNB4BpJfO6Hffv6d7P7Se9n9oPd3/ofX06Q+tpwc/tJ4Ofmg9PfxZ76lY
zvJ3IpG3AXsToL1vCtC9bwrQ/jcF6P43BejTbwrQg28K0ME3BejW7DkMqK2mfQNx7xsC3LMa3xTg
npH4pgD3bMI3BbhnAr4pwD2N/00B7in4bwpwT59/U4Af/mwAFjcsPSOBW7YfDu68qtpl1eZpm7/7
BsBlSwLGsdM3BBCmMK8/HA7G+U3AEUWnBvrDwU0z/rvHKLe2Nrc19C1ivrQ6T8+Li3VNUfct4Q9D
zJeXeUkhcJrNZgSw+eibg1jn7bpefjiKlrnr/DyvKRGRfzhMj8O/QagIGdPlejH5Jnh0lV18c8Dy
5eybJqEB+c1oCMvZFGzPIT/FN8Hdi4wyKh8Opq2yb05ZPC+ab4BegJI+WZdl/k0Be/ENsRoD+wZC
CIbzDUQQDOcbCCAYzq01+q1m7hsjk4L7pqil4L4poim4b4p2wqjfGO0U3DdFOwX3TdFOwX0DtHtT
tCWrfd9F2X2PzN9JWTXfiAZ8XVwsM/INvgEjpEnX9GVWZxd1tpqnSG/3RvnhHT2pZtfpm2/E1FlQ
35j7z5xyQgMvlutvgKgBuG9MzizAb0rSLMBvStYswG9A2r4gXxoO3Le/ocjn9XrSRgWYQd1OgF9n
5Vqc3g/H5yktZHw4FCcKz4q6+eYEIg73m2DlF3B5v/1N+YIOz28ANQfsG5CwrpL6ZhFUmN8EniUt
rH1Divnb16u8phju7YeDelaVZXWVz75BkK/buhKe8+V/j+fldvJ/uljNs6ZoejB8J+Amudcl9vSL
bPXhY3pZ0pr6NzR7p9u0QF+m36Bz8e03XzxP31QrhKUg8DcE8UnVttXimwOqucSt7+aTOx8OjVE8
prB5ef0N4CbQvqnUEkM7Kb4JyyOgqtk3BYoc0WJZfDO2lQH+Xvn1pMrq2TcE7iVlflhHtPk3BfJ1
tliV3xT93pCivCJ19E34SgzwJ7O6QE7pw8GpfL35ZqB5mcdmPfnpfPoNqL4XVfr8G8kqfbluOYcJ
aN/EenIA7xvwIAJ434D3wHNKJgOM/E2MN4D3DYw3gPeNjfekzJqm0BXabxLgNzZiA/AbH/I3ECoq
wKqs6vN1+Q0S0UD85qhoIH5zZKzK9WLZfKODZoDf5JgZ4Dc+5G+ScxjgN5BkEICf18Xsm5sRhvaN
TQdD+8bmgqF9YxPB0L7ZWfj0G4X24BuFdvBNQfumnAMP2jfGb9+sY8DQvjF+Y2jfGL8xtG+M3xga
89s3Bu0b47d7T9P8/Jwc5W/Q7ngwvzHe82B+YxyIlHS+WFV1Vl9/UzBPy/wi+yayrALuZV2dU3RP
X2TlNwUT2e7ym/TIBd43NtXfzSffHHIA9o1i9g1w35OM8pfVN5Wac1aIX/VSj/ce3vzem3m++AYC
b8o1TvN5VdJyzNCwhl+mCPv1Kptq0r+3tni7/Ovz4mLepq/nmVk88OF8unPzq9Crvfdu0WWM8p/u
bXrvi3xWrBcGV+H14O177/H2Xu/t/Vu8zUak3/H9277a7/XTW7zqnOng1Qe3fbXf68FtX73Xe3Wj
cDzN6rdRjniwkZNsUDjAhw828pN9O9rxRpayr8a48cFGfgoEh5LTUyxA9CfplhI0DOCWojQM4L1k
ahjMewnXMJjbS9kwjI3i9iq/LGD430uVco8vszq7qLPVvGcQ2N2+nT79iTUtxnYB7D28PYAzcq6W
TZ5GAd17j1WxQO8ME/P2CmgYxu010TCM26ukYRi3002D77+fkhoGc3ttNQzj9mprGMb766++pXhP
/dUH8J76qw/ga+mvPpivpb8+xEsYhnF7d2EYxvuLbR/G+4vth3gSwzBuFNvNLPb1xLYP5v3Ftg/j
/cW2D+P9xbbvpb2n2PYBvKfY9gF8LbHtg/laYtsH8/5i24fx/mLbh/H+YtuH8f5i24fx/mL7dSOB
wfe/ntj2wby/2PZhvL/Y9mG8v9ju90j6nmLbB/CeYtsH8LXEtg/ma4ltH8z7i20fxvuLbR/G+4tt
H8b7i20fxvuLbR/G+4lt7/2vJ7Z9MO8vtn0Y7y+2fRjvL7b3eyR9T7HtA3hPse0D+Fpi2wfztcS2
D+b9xbYP4/3Ftg/j/cW2D+P9xbYP4/3Ftg/j/cS29/7XE9s+mPcX2z6M9xfbPoz3F9tPeyR9T7Ht
A3hPse0D+Fpi2wfztcS2D+b9xbYP4/3Ftg/j/cW2D+P9xbYP4/3Ftg/j/cS29/7XE9s+mPcX2z6M
9xfbPoyNnKoroqeL1Txrisa9LC/vPsQnt0t+mizqEKy93dvDUrRe5ed5nS+n/aTse8AyeA0D27s9
sCdV9TZ9UxByPSj33gNKMSmLihPf1z04D/DJh61xvvnyJP12zvzZA//wtuBvOxhaUC1ohZjXaHe7
3e3f+tVeUmZ/I/P7r/YCw/2NPO+/2nNO9zdqZP/VnoHc36iIWUjlTTZTvbc3qh3v7d2B9zeqcO/9
PqE3Km7vzT6dN6pr780+mTcqae/N+yk0dvf1+7cl1qep0ZI9EBs50wPxYBjERg7tT5nR0X0pufXc
DYO49SQOg7j1bA6DeL9pHYTzNeZ3GNb7T/QwrK85432Ze+8Z/wCxHQbx3jPeB/H1ZrwH5wNmvA/r
6894H9bXnPG+rnzvGe+DeO8Z/wCNPQzi6814D84HzHgf1tef8T6srznjfRv33jPeB/HeM94H8d4z
/qHGehDOB8x4H9bXn/E+rK85430P8L1nvA/ivWe8D+K9Z7wP4uvNeA/OB8x4H9bXn/E+rK85473o
+v1nvA/ivWe8D+K9Z7wPojPjt5zxHpwPmPE+rK8/431YG2f8ObIwwYy/30R777+nn+a9+Z7G2nvz
PTW29+bXCa+8179ueOWB+LrhVX/KzNy/Z3jlz90wiFtP4jCIW8/mMIj3m9ZBOF9jfodhvf9ED8P6
mjP+nuFVbMY/QGyHQbz3jL9neDU44+8ZXm2c8fcMrzbO+HuGV8Mz/p7hVWzG3zO8is34B2jsYRBf
b8bfM7zaOOPvGV5tnPH3DK+GZ/w9w6vYjL9neBWb8fcMr2Iz/qHGehDOB8z4e4ZXG2f8PcOr4Rl/
z/AqNuPvGV7FZvw9w6vYjL9neDU44+8ZXm2c8fcMrzbO+HuGV8Mz/p7hVWzG3zO8is34e4ZXsRl/
z/BqcMbfM7zaOOPvGV5tnPGh8OouActoubV93V6XeQPgDX6j1u31iqCusjrjdU8A4K/OaLXxBdYZ
2f+f5efZuuQlR7wMVOjTy6x0jRhlXZrUPhnQbTvThdF+B3P5IjVkmWS0FPrlMtr/Mn/XRr8oi+Vb
84Xp6WSe1fq1o5lpZBjDG9HVo9XLGj/e5vnqBXq6a/56XizzRv5sVtkU6BKi+XlV5+DTHYw0O2/z
+rOPDKdU65aQyp9flqbLHTNX2k2tP55Vy7YBgGZaFG/mOdhgkf10VX/7eNkUAD3HL9Fv8qxpj5si
87881c/w/bRpvW+eFLPCUFl/nOiwpmA1g+ne6YP9J6xe+G1mw88+ypgJd+3Hr+fZjCA/eaYgmx/Y
943kNj84wcj8D+/qwL8m/+wN8o9Rft8U/+zdin/ckr62DFb0vzEe29u5HY/tGhr/v57H7j95+OTp
MI91OcpYpICjPjWj/RCOujfIUfe+YY669/9FjrIW5v8HHPWBnLI/yCn73zCn7P9/kVPuGRr/v5FT
Cv3xc8M59wc55/43zDn3/7/IOfuGxv9v4JyAM3af7T99cHBLT+jBMzOOD+GVTwd5xdjAb4pXPv3/
Iq/cNzT+fwOvbNQqPwe882CQd0w4/k3xzoP/L/KO9Rf/X887+zv4r8s7LZHEcc6bYtna8OsDGedg
kHFMKPdNMc7B/xcZ54Gh8c8249yGcd7TdbnywygzxCCMsomJD+Ggh4McZOb0m+Kgh/9f5CCb/Ph/
Awd9s6rnm2OwKU1sNiVKBgz2VJKTLw33gWRosCFpqa+k9p1UXhrgGSsoN/LMMO4tcrYB3pzFNcx8
ixyrpH2HGft9OLudlMJg9MvZckYwrpg7Dbazd5lCowYneVl+kUnzarWhbZmft/L17s5BrMGkattq
sQFCzesOwyDuhgjJn5uZZrleTPKapDIg/osKmfQb6Z5Kqw8n+ftqzTdFS3PdRUg+VVp+qLpkYBt1
5a6R1pgiXD2Z8U87p/xKQ4QWPp+KYrjBAEETsPYT5Zn7wZ524JSqatF7olOhQUl57Ns/Xq1L+iBb
t5W1hEvopXVWvlYY/+/RsYFOvbd373T/WUyn7tkPe+l0SxYx9D1da5f7fF3rVoS+lq71eIaGsG5o
5l/ju5j0cNvUY7AOx8b1dpxNb2bRH03me+uY1+tJG1Uz9otvSNMYeJuVjbGyMWVDSlx+KcrIYoZ+
+/8Syf7AVGKPGXb73LBnEsqBG2U159cS7XCSbpRu0/zDBbzDbRs440fT+v7TqkGRrnbfOK3aPN39
8Hk1PQ/Oq/Gefk6ndaI//l+40B2ZUDehuvx86wnd+8Ym1Fii/y9O6K3k1E3fB60qb5w+Xeu99fTd
+8amz6xa//9z+j5wWnRh9dbTsv+NTYtR/f8fmZYPtIYfOE26innrabr/jU2TMdr/L52mH8IC08aJ
0SXDW0/Mp9/YxBhV/f/Sifk5WAncOFG6PnfriXrwjU2UWWn8/+JEvXfu+wNnSRfDbj1LB9/YLBnH
9f+ls/Se5iZw6n4WliCUaLrydOvpeviNTZeZlP+XTtc3K1Q/27OJhESZny5W86wpmmjmg2DY7993
+iIJDjNJQepLZ2wj7Q528N9taPeBZmOQGt8gGexc3kyGrzuMM1oQWDbDc6vff5OTu2dUUGxUE4V/
W7f6Z8mtft3WFS2Q9ThdPv4GaLB3axrcPIRVNJn9E+uqzXsjkE+jA3j/NDYD8zR2ZJxfW5B3+BkQ
5FuRJT6zHs43miVu++Emyaf5BhL9cKgSZxYV8zjPGB3wjfKO3+NGFrr3w1pz3edfblxzneTnVZ1D
OfM86BLs3oFBs1jOUln5J1/j3qdow4v4+peCVefj/1VKrz8lN0pIwBofLikBG97IEP/vop54Qa/y
87zOl9O+FKmX5Bq8L6EilNhkSRuSu/IkW8WocPr0wdN7zPh9KhjLtO5K0wfQRud1mDiGj75R6tze
xn44tQbWq79JIj6pqrdvosvT+CZ9M7xA/X5kM/nwr0G2KBVuHm/cJhHYtqiWvdFO9fPoUG9niCKj
touP+aL4djGb5UttupwXs/y783z5FXUUoYyqcjd0UmgwDxLB4Y9XayjPbN1Wt1P/76mwrrzobze2
vqYfft15ePPliQbVvamgr1LzXXQ69EuD6PtMiHGLvu6EVOsWxH9+WRqQDw0ZVl+HDC+q1zLFPSq8
qFLz1dBoooq6xznqS1jGuQ0XuWGY35qj/wdQSwMEFAAGAAgA0WoGQQnbwwXdBgAAUBsAABUAAAB3
b3JkL3RoZW1lL3RoZW1lMS54bWztvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLs
HWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee++997o7nU4n99//P1xmZAFs9s5K2smeIYCqyB8/
fnwfPyL+x7/3H3z8e7xblOllXjdFtfzso93xzkdpvpxWs2J58dlH6/Z8++CjtGmz5Swrq2X+2UfX
efPR73H0OHvUzvNFntLby4Z+X+ze/+yjeduuHt2920zpq6wZL4ppXTXVeTueVou71fl5Mc3v8muL
8u7ezu7e3UVWLD9SGFnv/WqVL+m786peZC39WV/cndXZFWHG7+98qu8vswUh9iXDT98A/kcWwdOS
/lm2DT6YlvXrKWPtv8FtZ2938aO5bk7KOr3Mys8+on5m1dWb/F37UVpmTUtffPbRDj8fpXePHt+1
b5XtwMvei8/4MS/qG7O3e/xifTGxb+7v39//9Nj1sCc99BuePjj99PRTB5FbZNMpjXa31/j+k4dP
nt43jb1W8msE+tMHT+/thi94PdzrvXB8H/+FL9xzL+z3Xnj27MQjpddKfr0focyDvZP98IX77oVP
ey882Dl+uv8gfIFbzcti+bbXfOf+p/dO7JBtm/Oq/Ha0/cP7+88e7Jn2rtldj9MEwLId4rtF9tNV
/Ywa8CxnbbFM2+tVfp5Nqd1JVhaTukifFxdzYsJVtqwa+nhnb+fZzj36F//t829ClexRnnmv62fT
pv8ZUEqbaV2s2s8++g4B/shr8z/+fX/9//j3/a3pf/qH/G3/6R/yd/6nf+gf+p/+IX9j7LVvZ8sL
/7X/9q/8k/+7P/8PSv+bv/Uv+m//tD994IXGf+E//xv+2P/s7/9TB1q2fsv/4s/4m/7Lv+1v+i/+
rD/hv/5r/7RY++M6m/jt3xSLvElf5Ffpq2qBwUW6yCf1e77yZp4V/ivHy4smW2Z4Kdb8tJ0HzV9c
Z2UWa/gkDwn5kzUpj2jLz9c/HSD9el6v2yLW8veaL4KWX1RV+aSq4wP7vbg7jxbr5cVA//Xab/gq
yy6j3Z90pvp0vSL+L6JAT+Z5gOrLkmY/u8iXeZviu+ptnsfe+32KIqDvF8bapL9PkT7Jijhh3hST
gLXcW98uFjRB11EcaeoDCn3xk+mTqox28DS/DJuSmGRlFGheBtT8PFu32SKOdbYo/abPs3YeRfT1
dT0NCN+0NOkXeVmlp7O8aaIvfVlfByj/XqR3Bjjgi/J6ETat2+JttOnzrKr8pk+rtyfzbLGK410s
537js+YtcWyWvqzaOB5VKDP4myYkWw7P/E8WeTDzt5D4r0jxxpkF36zrqIzkVSij1+V5lgv4ux2F
vyiWN2r/jt6//7Ou90nN/hd/3p8/oJb/36rxj+siLmRdPT/YsKvdT6p6Vvx/Q7k/zdbLlzkEKNL2
R7r9/Ee63VfYPx90+6CU/2xodKfE78qbnuu/GPT8z4uyfN1el/nzhtV/Q0OcPaMP+Q9+yUYaqzn9
avoLGl7UGf+e1lX73aKdv55nK+pnl7u4aBT2RZOuqoYsyEchcA84vijXiy+qmXS5u2sDXeoya90X
ZILsF2SxWvn40wdeMGfR578uGh+H+wz39nj43YV43Ivh8cB+egMePL5vBpGHMUQOdjcictebHpLI
NEO65f6+pheaaVbmM0yYAjDz/I3P+SBJw7HvxYb4cH/jEN9rzgM8fN4L8fCZcp7N8t7n3/CsP/Tm
NkBxz/YYYPLg4Gdn1u/2FUa5DP9Kr0gK792nl6fZ6rOPzsmfpF8XKwLYQKFm5QUl+Kat0vtrqZtV
3bRPs2Yu7fgrpcGiaPM6LYsFcX4wG+XSobe79wBf/L8Xv4c7/6+k393ubOfn5/m0HfjE/UnfKZTo
1x/aGn9Ua8L79Xx2lU7Kdf0qI2rdf7ALKs6KprUknRW1x+iOlB0dppIZZOWcxGblap6puQnUvLTn
3y0+3kAY1e6wwr91NJOLZx0p+3rzfPNb+MLTpEO25YEQLKZPfvb8AA8vzyAEeN23eAXq76FVf4MG
5MNNhYee112A3j2G0kfP+zhE75v0GrwOHZt2EHTm4xu3E10evuu5ofxXb12kmvw0ycFTcm/XZdsI
trTsUWcnJo2tqoE/NgrnXZuu6+Kzj37xzv3j/ZO9+yfbOwf3T7f37+3vbB/cP763fXz//r3d0/u7
O0+f7P0SogwvEknvzygWKq+/kcWjyOJPWhBxfvGne88e3nv45NPth/eOn23vP31ysP3w5NMn208/
PXnw9NnTk/sHD5/9ko/SS268f3zvZP/T04PtT3dPTrb3P90B+gcPtx/s7+0d7z84PjjdP/4lhtw0
dPPTUJgRO/p/AFBLAwQUAAYACADRagZBjoxzCXABAAD0AQAAFAAAAHdvcmQvd2ViU2V0dGluZ3Mu
eG1s7b0HYBxJliUmL23Ke39K9UrX4HShCIBgEyTYkEAQ7MGIzeaS7B1pRyMpqyqBymVWZV1mFkDM
7Z28995777333nvvvfe6O51OJ/ff/z9cZmQBbPbOStrJniGAqsgfP358Hz8i/se/9x98/Hu8W5Tp
ZV43RbX87KPd8c5Hab6cVrNiefHZR+v2fPvgo7Rps+UsK6tl/tlH13nz0e9x9Pjq0VU+eZ23LbVr
UoKxbB4tpp99NG/b1aO7d5vpPF9kzbha5Uv68ryqF1lLf9YXdxdZ/Xa92p5Wi1XWFpOiLNrru3s7
O59+pGDq20Cpzs+Laf60mq4X+bLl9+/WeUkQq2UzL1aNgXZ1G2hXVT1b1dU0bxoaz6IUeIusWFow
u/s9QItiWldNdd6OaTCKEYOi13d3+LdF6QDcfz8AexbAYvro7GJZ1dmkpAkgTFIC9hHmoFq1xaL4
Qf6sqp/U1VWT1+ldfJ6VZXX18sXn+OtuMFVH/w9QSwECLQAUAAYACAAAACEA0zAfLl4BAAAgBQAA
EwAAAAAAAAAAAAAAAAAAAAAAW0NvbnRlbnRfVHlwZXNdLnhtbFBLAQItABQABgAIAAAAIQAekRq3
7wAAAE4CAAALAAAAAAAAAAAAAAAAAI8BAABfcmVscy8ucmVsc1BLAQItABQABgAIANFqBkH8XP18
1gEAAAsDAAAQAAAAAAAAAAAAAAAAAKcCAABkb2NQcm9wcy9hcHAueG1sUEsBAi0AFAAGAAgA0WoG
QVLD/UK6AQAAbwIAABEAAAAAAAAAAAAAAAAAqwQAAGRvY1Byb3BzL2NvcmUueG1sUEsBAi0AFAAG
AAgAAAAhANZks1H0AAAAMQMAABwAAAAAAAAAAAAAAAAAlAYAAHdvcmQvX3JlbHMvZG9jdW1lbnQu
eG1sLnJlbHNQSwECLQAUAAYACADRagZBeuUzdzMCAACQBQAAEQAAAAAAAAAAAAAAAADCBwAAd29y
ZC9kb2N1bWVudC54bWxQSwECLQAUAAYACADRagZB3iZxVZoCAAAzBwAAEgAAAAAAAAAAAAAAAAAk
CgAAd29yZC9mb250VGFibGUueG1sUEsBAi0AFAAEAAgA0WoGQYaCXUkdBAAAeQkAABEAAAAAAAAA
AAAAAAAA7gwAAHdvcmQvc2V0dGluZ3MueG1sUEsBAi0AFAAEAAgA0WoGQSv37OFTEgAAFa0AAA8A
AAAAAAAAAAAAAAAAOhEAAHdvcmQvc3R5bGVzLnhtbFBLAQItABQABgAIANFqBkEJ28MF3QYAAFAb
AAAVAAAAAAAAAAAAAAAAALojAAB3b3JkL3RoZW1lL3RoZW1lMS54bWxQSwECLQAUAAYACADRagZB
joxzCXABAAD0AQAAFAAAAAAAAAAAAAAAAADKKgAAd29yZC93ZWJTZXR0aW5ncy54bWxQSwUGAAAA
AAsACwDBAgAAbCwAAAAA";
                                #endregion

                                char[] base64CharArray = base64.Where(c => c != '\r' && c != '\n').ToArray();
                                byte[] byteArray       = System.Convert.FromBase64CharArray(base64CharArray, 0, base64CharArray.Length);
                                memoryStream.Write(byteArray, 0, byteArray.Length);

                                using (WordprocessingDocument defaultDotx = WordprocessingDocument.Open(memoryStream, true))
                                {
                                    //Get the specified style from Default.dotx template for paragraph
                                    Style templateStyle = defaultDotx.MainDocumentPart.StyleDefinitionsPart.Styles.Elements <Style>().Where(s => s.StyleId == styleName && s.Type == StyleValues.Paragraph).FirstOrDefault();

                                    //Check if the style is proper style. Ex, Heading1, Heading2
                                    if (templateStyle == null)
                                    {
                                        throw new OpenXmlPowerToolsException(String.Format("Add-DocxText: The specified style name {0} is unsupported, Please specify the valid style. Ex, Heading1, Heading2, Title", styleName));
                                    }
                                    else
                                    {
                                        part.Styles.Append((templateStyle.CloneNode(true)));
                                    }
                                }
                            }
                        }

                        paragraph.ParagraphProperties = new ParagraphProperties(new ParagraphStyleId()
                        {
                            Val = styleName
                        });
                    }

                    run.AppendChild(runProperties);
                    run.AppendChild(new Text(strParagraph));

                    if (sectionProperties != null)
                    {
                        body.InsertBefore(paragraph, sectionProperties);
                    }
                    else
                    {
                        body.AppendChild(paragraph);
                    }
                }
                return(streamDoc.GetModifiedWmlDocument());
            }
        }
Example #51
0
        // Creates an Table instance and adds its children.
        public static Table GenerateTable(Document doc, System.Data.DataTable datetable)
        {
            Table table = new Table();
            //
            PageSize pagesize = doc.Body.Descendants<PageSize>().First();
            PageMargin pagemargin = doc.Body.Descendants<PageMargin>().First();
            //
            var AvailableSumWidth = (int)(pagesize.Width - pagemargin.Right - pagemargin.Left);

            TableBorders tborder = new Func<TableBorders>(delegate()
            {
                TableBorders tableBorders1 = new TableBorders();
                TopBorder topBorder1 = new TopBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
                LeftBorder leftBorder1 = new LeftBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
                BottomBorder bottomBorder1 = new BottomBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
                RightBorder rightBorder1 = new RightBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
                InsideHorizontalBorder insideHorizontalBorder1 = new InsideHorizontalBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
                InsideVerticalBorder insideVerticalBorder1 = new InsideVerticalBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };

                tableBorders1.Append(topBorder1);
                tableBorders1.Append(leftBorder1);
                tableBorders1.Append(bottomBorder1);
                tableBorders1.Append(rightBorder1);
                tableBorders1.Append(insideHorizontalBorder1);
                tableBorders1.Append(insideVerticalBorder1);
                return tableBorders1;
            })();

            table.AppendChild<TableProperties>(new TableProperties(
               new TableStyle() { Val = "a7" },
               tborder,
               new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto },
               new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true }
            ));

            int sumColumn = datetable.Columns.Count;

            int averwidth = AvailableSumWidth / sumColumn;

            Double set_colSumW = 0;
            int remainSumW = 0;
            foreach (System.Data.DataColumn item in datetable.Columns)
            {
                Object col_w = item.ExtendedProperties["width"];
                if (col_w != null) { set_colSumW += Convert.ToDouble(col_w); remainSumW += averwidth; }
            }

            foreach (System.Data.DataColumn item in datetable.Columns)
            {
                Object col_w = item.ExtendedProperties["width"];
                if (col_w != null) item.ExtendedProperties.Add("WordWidth", Math.Floor((remainSumW * Convert.ToDouble(col_w) / set_colSumW)));
                else item.ExtendedProperties.Add("WordWidth", averwidth);
            }

            for (int i = 0; i < sumColumn; i++)
            {
                int col_w = Convert.ToInt32(datetable.Columns[i].ExtendedProperties["WordWidth"]);
                table.AppendChild<GridColumn>(new GridColumn() { Width = col_w.ToString() });
            }
            List<System.Data.DataRow> lstCol = new List<System.Data.DataRow>();
            System.Data.DataRow dr = datetable.NewRow();
            List<object> lstObj = new List<object>();

            foreach (System.Data.DataColumn item in datetable.Columns)
            {
                lstObj.Add(item.ColumnName);
            }

            dr.ItemArray = lstObj.ToArray();
            datetable.Rows.InsertAt(dr, 0);

            foreach (System.Data.DataRow item in datetable.Rows)
            {
                TableRow tableRow = new TableRow() { RsidTableRowAddition = "00D24D12", RsidTableRowProperties = "00D24D12" };
                for (int i = 0; i < sumColumn; i++)
                {
                    int col_w = Convert.ToInt32(datetable.Columns[i].ExtendedProperties["WordWidth"]);

                    string cellValue = item[i].ToString();
                    TableCell tableCell1 = new TableCell();

                    TableCellProperties tableCellProperties1 = new TableCellProperties();
                    TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = col_w.ToString(), Type = TableWidthUnitValues.Dxa };

                    tableCellProperties1.Append(tableCellWidth1);

                    Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "00D24D12", RsidParagraphProperties = "003246FB", RsidRunAdditionDefault = "00D24D12" };

                    Run run1 = new Run();

                    RunProperties runProperties1 = new RunProperties();
                    RunFonts runFonts1 = new RunFonts() { Hint = FontTypeHintValues.EastAsia };

                    runProperties1.Append(runFonts1);
                    Text text1 = new Text();
                    text1.Text = cellValue;

                    run1.Append(runProperties1);
                    run1.Append(text1);
                    BookmarkStart bookmarkStart1 = new BookmarkStart();
                    BookmarkEnd bookmarkEnd1 = new BookmarkEnd();

                    paragraph1.Append(run1);
                    paragraph1.Append(bookmarkStart1);
                    paragraph1.Append(bookmarkEnd1);

                    tableCell1.Append(tableCellProperties1);
                    tableCell1.Append(paragraph1);

                    tableRow.Append(tableCell1);
                }
                table.Append(tableRow);
            }
            return table;
        }
        // Creates an Table instance and adds its children.
        public static Table GenerateTable()
        {
            Table table1 = new Table();

            TableProperties tableProperties1 = new TableProperties();
            TableWidth      tableWidth1      = new TableWidth()
            {
                Width = "8789", Type = TableWidthUnitValues.Dxa
            };
            TableIndentation tableIndentation1 = new TableIndentation()
            {
                Width = 10, Type = TableWidthUnitValues.Dxa
            };

            TableBorders tableBorders1 = new TableBorders();
            TopBorder    topBorder1    = new TopBorder()
            {
                Val = BorderValues.Single, Color = "000000", Size = (UInt32Value)10U, Space = (UInt32Value)0U
            };
            LeftBorder leftBorder1 = new LeftBorder()
            {
                Val = BorderValues.Single, Color = "000000", Size = (UInt32Value)10U, Space = (UInt32Value)0U
            };
            BottomBorder bottomBorder1 = new BottomBorder()
            {
                Val = BorderValues.Single, Color = "000000", Size = (UInt32Value)10U, Space = (UInt32Value)0U
            };
            RightBorder rightBorder1 = new RightBorder()
            {
                Val = BorderValues.Single, Color = "000000", Size = (UInt32Value)10U, Space = (UInt32Value)0U
            };
            InsideHorizontalBorder insideHorizontalBorder1 = new InsideHorizontalBorder()
            {
                Val = BorderValues.Single, Color = "000000", Size = (UInt32Value)10U, Space = (UInt32Value)0U
            };
            InsideVerticalBorder insideVerticalBorder1 = new InsideVerticalBorder()
            {
                Val = BorderValues.Single, Color = "000000", Size = (UInt32Value)10U, Space = (UInt32Value)0U
            };

            tableBorders1.Append(topBorder1);
            tableBorders1.Append(leftBorder1);
            tableBorders1.Append(bottomBorder1);
            tableBorders1.Append(rightBorder1);
            tableBorders1.Append(insideHorizontalBorder1);
            tableBorders1.Append(insideVerticalBorder1);

            TableCellMarginDefault tableCellMarginDefault1 = new TableCellMarginDefault();
            TableCellLeftMargin    tableCellLeftMargin1    = new TableCellLeftMargin()
            {
                Width = 10, Type = TableWidthValues.Dxa
            };
            TableCellRightMargin tableCellRightMargin1 = new TableCellRightMargin()
            {
                Width = 10, Type = TableWidthValues.Dxa
            };

            tableCellMarginDefault1.Append(tableCellLeftMargin1);
            tableCellMarginDefault1.Append(tableCellRightMargin1);
            TableLook tableLook1 = new TableLook()
            {
                Val = "0000", FirstRow = false, LastRow = false, FirstColumn = false, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = false
            };

            tableProperties1.Append(tableWidth1);
            tableProperties1.Append(tableIndentation1);
            tableProperties1.Append(tableBorders1);
            tableProperties1.Append(tableCellMarginDefault1);
            tableProperties1.Append(tableLook1);

            TableGrid  tableGrid1  = new TableGrid();
            GridColumn gridColumn1 = new GridColumn()
            {
                Width = "2550"
            };
            GridColumn gridColumn2 = new GridColumn()
            {
                Width = "4860"
            };
            GridColumn gridColumn3 = new GridColumn()
            {
                Width = "1379"
            };

            tableGrid1.Append(gridColumn1);
            tableGrid1.Append(gridColumn2);
            tableGrid1.Append(gridColumn3);

            TableRow tableRow1 = new TableRow()
            {
                RsidTableRowAddition = "009B2C1D", RsidTableRowProperties = "009E39C2", ParagraphId = "0CBEE687", TextId = "77777777"
            };

            TableRowProperties tableRowProperties1 = new TableRowProperties();
            GridAfter          gridAfter1          = new GridAfter()
            {
                Val = 1
            };
            WidthAfterTableRow widthAfterTableRow1 = new WidthAfterTableRow()
            {
                Width = "1379", Type = TableWidthUnitValues.Dxa
            };

            tableRowProperties1.Append(gridAfter1);
            tableRowProperties1.Append(widthAfterTableRow1);

            TableCell tableCell1 = new TableCell();

            TableCellProperties tableCellProperties1 = new TableCellProperties();
            TableCellWidth      tableCellWidth1      = new TableCellWidth()
            {
                Width = "7410", Type = TableWidthUnitValues.Dxa
            };
            GridSpan gridSpan1 = new GridSpan()
            {
                Val = 2
            };

            TableCellBorders tableCellBorders1 = new TableCellBorders();
            TopBorder        topBorder2        = new TopBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            LeftBorder leftBorder2 = new LeftBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            BottomBorder bottomBorder2 = new BottomBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            RightBorder rightBorder2 = new RightBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };

            tableCellBorders1.Append(topBorder2);
            tableCellBorders1.Append(leftBorder2);
            tableCellBorders1.Append(bottomBorder2);
            tableCellBorders1.Append(rightBorder2);

            tableCellProperties1.Append(tableCellWidth1);
            tableCellProperties1.Append(gridSpan1);
            tableCellProperties1.Append(tableCellBorders1);

            Paragraph paragraph1 = new Paragraph()
            {
                RsidParagraphAddition = "009B2C1D", RsidRunAdditionDefault = "009E39C2", ParagraphId = "4C204333", TextId = "77777777"
            };

            Run run1 = new Run();

            RunProperties runProperties1 = new RunProperties();
            Bold          bold1          = new Bold();
            FontSize      fontSize1      = new FontSize()
            {
                Val = "22"
            };
            FontSizeComplexScript fontSizeComplexScript1 = new FontSizeComplexScript()
            {
                Val = "22"
            };

            runProperties1.Append(bold1);
            runProperties1.Append(fontSize1);
            runProperties1.Append(fontSizeComplexScript1);
            Text text1 = new Text();

            text1.Text = "SOCIAL ACTIVITIES / MEMBERSHIPS";

            run1.Append(runProperties1);
            run1.Append(text1);

            Run run2 = new Run();

            RunProperties runProperties2 = new RunProperties();
            FontSize      fontSize2      = new FontSize()
            {
                Val = "22"
            };
            FontSizeComplexScript fontSizeComplexScript2 = new FontSizeComplexScript()
            {
                Val = "22"
            };

            runProperties2.Append(fontSize2);
            runProperties2.Append(fontSizeComplexScript2);
            Text text2 = new Text()
            {
                Space = SpaceProcessingModeValues.Preserve
            };

            text2.Text = "   ";

            run2.Append(runProperties2);
            run2.Append(text2);

            paragraph1.Append(run1);
            paragraph1.Append(run2);

            tableCell1.Append(tableCellProperties1);
            tableCell1.Append(paragraph1);

            tableRow1.Append(tableRowProperties1);
            tableRow1.Append(tableCell1);

            TableRow tableRow2 = new TableRow()
            {
                RsidTableRowAddition = "009B2C1D", RsidTableRowProperties = "009E39C2", ParagraphId = "533821CC", TextId = "77777777"
            };

            TableCell tableCell2 = new TableCell();

            TableCellProperties tableCellProperties2 = new TableCellProperties();
            TableCellWidth      tableCellWidth2      = new TableCellWidth()
            {
                Width = "2550", Type = TableWidthUnitValues.Dxa
            };

            TableCellBorders tableCellBorders2 = new TableCellBorders();
            TopBorder        topBorder3        = new TopBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            LeftBorder leftBorder3 = new LeftBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            BottomBorder bottomBorder3 = new BottomBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            RightBorder rightBorder3 = new RightBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };

            tableCellBorders2.Append(topBorder3);
            tableCellBorders2.Append(leftBorder3);
            tableCellBorders2.Append(bottomBorder3);
            tableCellBorders2.Append(rightBorder3);

            tableCellProperties2.Append(tableCellWidth2);
            tableCellProperties2.Append(tableCellBorders2);

            Paragraph paragraph2 = new Paragraph()
            {
                RsidParagraphAddition = "009B2C1D", RsidRunAdditionDefault = "009E39C2", ParagraphId = "6899F9F0", TextId = "77777777"
            };

            Run run3 = new Run();

            RunProperties runProperties3 = new RunProperties();
            FontSize      fontSize3      = new FontSize()
            {
                Val = "22"
            };
            FontSizeComplexScript fontSizeComplexScript3 = new FontSizeComplexScript()
            {
                Val = "22"
            };

            runProperties3.Append(fontSize3);
            runProperties3.Append(fontSizeComplexScript3);
            Text text3 = new Text()
            {
                Space = SpaceProcessingModeValues.Preserve
            };

            text3.Text = " 2011 - 2016 ";

            run3.Append(runProperties3);
            run3.Append(text3);

            paragraph2.Append(run3);

            tableCell2.Append(tableCellProperties2);
            tableCell2.Append(paragraph2);

            TableCell tableCell3 = new TableCell();

            TableCellProperties tableCellProperties3 = new TableCellProperties();
            TableCellWidth      tableCellWidth3      = new TableCellWidth()
            {
                Width = "6239", Type = TableWidthUnitValues.Dxa
            };
            GridSpan gridSpan2 = new GridSpan()
            {
                Val = 2
            };

            TableCellBorders tableCellBorders3 = new TableCellBorders();
            TopBorder        topBorder4        = new TopBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            LeftBorder leftBorder4 = new LeftBorder()
            {
                Val = BorderValues.Single, Color = "000000", Size = (UInt32Value)1U, Space = (UInt32Value)0U
            };
            BottomBorder bottomBorder4 = new BottomBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };
            RightBorder rightBorder4 = new RightBorder()
            {
                Val = BorderValues.Single, Color = "FFFFFF", Size = (UInt32Value)0U, Space = (UInt32Value)0U
            };

            tableCellBorders3.Append(topBorder4);
            tableCellBorders3.Append(leftBorder4);
            tableCellBorders3.Append(bottomBorder4);
            tableCellBorders3.Append(rightBorder4);

            tableCellProperties3.Append(tableCellWidth3);
            tableCellProperties3.Append(gridSpan2);
            tableCellProperties3.Append(tableCellBorders3);

            Paragraph paragraph3 = new Paragraph()
            {
                RsidParagraphAddition = "009E39C2", RsidParagraphProperties = "009E39C2", RsidRunAdditionDefault = "009E39C2", ParagraphId = "72BA0AEC", TextId = "77777777"
            };

            ParagraphProperties paragraphProperties1 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines1 = new SpacingBetweenLines()
            {
                After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto
            };
            Indentation indentation1 = new Indentation()
            {
                Left = "271", Hanging = "127"
            };

            ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties();
            FontSize fontSize4 = new FontSize()
            {
                Val = "21"
            };
            FontSizeComplexScript fontSizeComplexScript4 = new FontSizeComplexScript()
            {
                Val = "21"
            };

            paragraphMarkRunProperties1.Append(fontSize4);
            paragraphMarkRunProperties1.Append(fontSizeComplexScript4);

            paragraphProperties1.Append(spacingBetweenLines1);
            paragraphProperties1.Append(indentation1);
            paragraphProperties1.Append(paragraphMarkRunProperties1);

            Run run4 = new Run();

            RunProperties runProperties4 = new RunProperties();
            FontSize      fontSize5      = new FontSize()
            {
                Val = "21"
            };
            FontSizeComplexScript fontSizeComplexScript5 = new FontSizeComplexScript()
            {
                Val = "21"
            };

            runProperties4.Append(fontSize5);
            runProperties4.Append(fontSizeComplexScript5);
            Text text4 = new Text();

            text4.Text = "Travel Tour Leader:";

            run4.Append(runProperties4);
            run4.Append(text4);

            paragraph3.Append(paragraphProperties1);
            paragraph3.Append(run4);

            Paragraph paragraph4 = new Paragraph()
            {
                RsidParagraphAddition = "009E39C2", RsidParagraphProperties = "009E39C2", RsidRunAdditionDefault = "009E39C2", ParagraphId = "6641EB68", TextId = "77777777"
            };

            ParagraphProperties paragraphProperties2 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines2 = new SpacingBetweenLines()
            {
                After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto
            };
            Indentation indentation2 = new Indentation()
            {
                Left = "271", Hanging = "127"
            };

            ParagraphMarkRunProperties paragraphMarkRunProperties2 = new ParagraphMarkRunProperties();
            FontSize fontSize6 = new FontSize()
            {
                Val = "21"
            };
            FontSizeComplexScript fontSizeComplexScript6 = new FontSizeComplexScript()
            {
                Val = "21"
            };

            paragraphMarkRunProperties2.Append(fontSize6);
            paragraphMarkRunProperties2.Append(fontSizeComplexScript6);

            paragraphProperties2.Append(spacingBetweenLines2);
            paragraphProperties2.Append(indentation2);
            paragraphProperties2.Append(paragraphMarkRunProperties2);

            Run run5 = new Run();

            RunProperties runProperties5 = new RunProperties();
            FontSize      fontSize7      = new FontSize()
            {
                Val = "21"
            };
            FontSizeComplexScript fontSizeComplexScript7 = new FontSizeComplexScript()
            {
                Val = "21"
            };

            runProperties5.Append(fontSize7);
            runProperties5.Append(fontSizeComplexScript7);
            Text text5 = new Text()
            {
                Space = SpaceProcessingModeValues.Preserve
            };

            text5.Text = "- Organized and led personal growth focused tour groups to India; ";

            run5.Append(runProperties5);
            run5.Append(text5);

            paragraph4.Append(paragraphProperties2);
            paragraph4.Append(run5);

            Paragraph paragraph5 = new Paragraph()
            {
                RsidParagraphAddition = "009B2C1D", RsidParagraphProperties = "009E39C2", RsidRunAdditionDefault = "009E39C2", ParagraphId = "76165E9A", TextId = "09F0CF60"
            };

            ParagraphProperties paragraphProperties3 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines3 = new SpacingBetweenLines()
            {
                After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto
            };
            Indentation indentation3 = new Indentation()
            {
                Left = "271", Hanging = "127"
            };

            paragraphProperties3.Append(spacingBetweenLines3);
            paragraphProperties3.Append(indentation3);

            Run run6 = new Run();

            RunProperties runProperties6 = new RunProperties();
            FontSize      fontSize8      = new FontSize()
            {
                Val = "21"
            };
            FontSizeComplexScript fontSizeComplexScript8 = new FontSizeComplexScript()
            {
                Val = "21"
            };

            runProperties6.Append(fontSize8);
            runProperties6.Append(fontSizeComplexScript8);
            Text text6 = new Text();

            text6.Text = "- Acted as a liaison between European individuals and Asian spiritual guides";

            run6.Append(runProperties6);
            run6.Append(text6);

            paragraph5.Append(paragraphProperties3);
            paragraph5.Append(run6);

            tableCell3.Append(tableCellProperties3);
            tableCell3.Append(paragraph3);
            tableCell3.Append(paragraph4);
            tableCell3.Append(paragraph5);

            tableRow2.Append(tableCell2);
            tableRow2.Append(tableCell3);

            table1.Append(tableProperties1);
            table1.Append(tableGrid1);
            table1.Append(tableRow1);
            table1.Append(tableRow2);
            return(table1);
        }
Example #53
0
        private Paragraph CreateCodeParagraph(CodeVM code)
        {
            Paragraph paragraph1 = new Paragraph();

            ParagraphProperties paragraphProperties1 = new ParagraphProperties();
            Indentation         indentation1         = new Indentation()
            {
                FirstLine = "210", FirstLineChars = 100
            };

            paragraphProperties1.Append(indentation1);

            Run run1 = new Run();

            RunProperties runProperties1 = new RunProperties();
            RunFonts      runFonts1      = new RunFonts()
            {
                Hint = FontTypeHintValues.EastAsia
            };

            runProperties1.Append(runFonts1);
            Text text1 = new Text();

            text1.Text = code.Value;
            run1.Append(runProperties1);
            run1.Append(text1);

            Run run2 = new Run();

            RunProperties runProperties2 = new RunProperties();
            RunFonts      runFonts2      = new RunFonts()
            {
                Hint = FontTypeHintValues.EastAsia
            };

            runProperties2.Append(runFonts2);
            TabChar tabChar1 = new TabChar();

            run2.Append(runProperties2);
            run2.Append(tabChar1);

            Run run3 = new Run();

            RunProperties runProperties3 = new RunProperties();
            RunFonts      runFonts3      = new RunFonts()
            {
                Hint = FontTypeHintValues.EastAsia
            };

            runProperties3.Append(runFonts3);
            Text text2 = new Text();

            text2.Text = code.Label;

            run3.Append(runProperties3);
            run3.Append(text2);

            paragraph1.Append(paragraphProperties1);
            paragraph1.Append(run1);
            paragraph1.Append(run2);
            paragraph1.Append(run3);
            return(paragraph1);
        }
Example #54
0
        public static void SetTableParagraph(ReportTable reportTable, Table table)
        {
            int count = reportTable.Value.Count;
            int cols  = reportTable.Column;
            int j     = 0;

            foreach (List <string> strs in reportTable.Value)
            {
                TableRow row = new TableRow();
                for (int i = 0; i < cols; i++)
                {
                    TableCell           cell = new TableCell();
                    TableCellProperties tableCellProperties = new TableCellProperties();
                    TableCellMargin     margin = new TableCellMargin();
                    margin.LeftMargin = new LeftMargin()
                    {
                        Width = "100", Type = TableWidthUnitValues.Dxa
                    };
                    margin.RightMargin = new RightMargin()
                    {
                        Width = "100", Type = TableWidthUnitValues.Dxa
                    };
                    tableCellProperties.Append(margin);
                    Paragraph par = new Paragraph();
                    Run       run = new Run();
                    if (j == 0 && reportTable.IsHaveColumn)
                    {
                        RunProperties rPr = new RunProperties();
                        rPr.Append(new Bold());
                        run.Append(rPr);
                    }
                    if (strs.Count != cols && i >= strs.Count - 1)
                    {
                        HorizontalMerge verticalMerge = new HorizontalMerge();
                        if (i == strs.Count - 1)
                        {
                            RunProperties rPr = new RunProperties();
                            rPr.Append(new Bold());
                            run.Append(rPr);
                            verticalMerge.Val = MergedCellValues.Restart;
                            run.Append(CreateText(strs[i]));
                        }
                        else
                        {
                            verticalMerge.Val = MergedCellValues.Continue;
                        }
                        tableCellProperties.Append(verticalMerge);
                    }
                    else
                    {
                        run.Append(CreateText(strs[i]));
                    }
                    par.Append(run);
                    cell.Append(tableCellProperties);
                    cell.Append(par);
                    row.Append(cell);
                }
                j++;
                table.Append(row);
            }
        }
 private Paragraph CreateCenterParagraph(string str)
 {
     Paragraph paragraph = new Paragraph();
     ParagraphProperties paragraphProperties = new ParagraphProperties();
     paragraph.Append(paragraphProperties);
     paragraphProperties.Append(new Justification() { Val = JustificationValues.Center });
     Run run = new Run();
     RunProperties runProperties = new RunProperties();
     RunFonts runFonts = new RunFonts() { Hint = FontTypeHintValues.EastAsia };
     runProperties.Append(runFonts);
     Text text = new Text() { Space = SpaceProcessingModeValues.Preserve };
     text.Text = str;
     run.Append(runProperties);
     run.Append(text);
     paragraph.Append(run);
     return paragraph;
 }
 protected static IEnumerable <Run> CreateTextContent(IEnumerable <string> content, RunProperties runProperties = null)
 {
     return(content
            .SelectMany(x => x.Split(new[] { Environment.NewLine }, StringSplitOptions.None))
            .SelectMany((contentLine, index) => index == 0
                                                                 ? new[]
     {
         new Run(new Text(contentLine)
         {
             Space = SpaceProcessingModeValues.Preserve
         })
         {
             RunProperties = CloneRunPropertiesIfNotNull(runProperties)
         }
     }
                                                                 : new[]
     {
         new Run(new Break())
         {
             RunProperties = CloneRunPropertiesIfNotNull(runProperties)
         },
         new Run(new Text(contentLine)
         {
             Space = SpaceProcessingModeValues.Preserve
         })
         {
             RunProperties = CloneRunPropertiesIfNotNull(runProperties)
         }
     })
            .ToList());
 }
Example #57
0
        // Generates content of mainDocumentPart1.
        private void GenerateMainDocumentPart1Content(MainDocumentPart mainDocumentPart1)
        {
            Document document1 = new Document() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 w15 wp14" } };
            document1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
            document1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            document1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
            document1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            document1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
            document1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
            document1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
            document1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
            document1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
            document1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
            document1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml");
            document1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2012/wordml");
            document1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
            document1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
            document1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
            document1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");

            Body body1 = new Body();

            Paragraph paragraph1 = new Paragraph() { RsidParagraphMarkRevision = "00417926", RsidParagraphAddition = "002C2DE6", RsidParagraphProperties = "00417926", RsidRunAdditionDefault = "00417926" };

            ParagraphProperties paragraphProperties1 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines1 = new SpacingBetweenLines() { After = "0" };
            Justification justification1 = new Justification() { Val = JustificationValues.Center };

            ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties();
            RunFonts runFonts1 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            Bold bold1 = new Bold();
            FontSize fontSize1 = new FontSize() { Val = "30" };

            paragraphMarkRunProperties1.Append(runFonts1);
            paragraphMarkRunProperties1.Append(bold1);
            paragraphMarkRunProperties1.Append(fontSize1);

            paragraphProperties1.Append(spacingBetweenLines1);
            paragraphProperties1.Append(justification1);
            paragraphProperties1.Append(paragraphMarkRunProperties1);

            Run run1 = new Run() { RsidRunProperties = "00417926" };

            RunProperties runProperties1 = new RunProperties();
            RunFonts runFonts2 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            Bold bold2 = new Bold();
            FontSize fontSize2 = new FontSize() { Val = "30" };

            runProperties1.Append(runFonts2);
            runProperties1.Append(bold2);
            runProperties1.Append(fontSize2);
            Text text1 = new Text();
            text1.Text = "Hard To Find Books";

            run1.Append(runProperties1);
            run1.Append(text1);

            paragraph1.Append(paragraphProperties1);
            paragraph1.Append(run1);

            Paragraph paragraph2 = new Paragraph() { RsidParagraphMarkRevision = "00417926", RsidParagraphAddition = "00417926", RsidParagraphProperties = "00417926", RsidRunAdditionDefault = "00417926" };

            ParagraphProperties paragraphProperties2 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines2 = new SpacingBetweenLines() { After = "0" };
            Justification justification2 = new Justification() { Val = JustificationValues.Center };

            ParagraphMarkRunProperties paragraphMarkRunProperties2 = new ParagraphMarkRunProperties();
            RunFonts runFonts3 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            Bold bold3 = new Bold();
            FontSize fontSize3 = new FontSize() { Val = "30" };

            paragraphMarkRunProperties2.Append(runFonts3);
            paragraphMarkRunProperties2.Append(bold3);
            paragraphMarkRunProperties2.Append(fontSize3);

            paragraphProperties2.Append(spacingBetweenLines2);
            paragraphProperties2.Append(justification2);
            paragraphProperties2.Append(paragraphMarkRunProperties2);

            Run run2 = new Run() { RsidRunProperties = "00417926" };

            RunProperties runProperties2 = new RunProperties();
            RunFonts runFonts4 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            Bold bold4 = new Bold();
            FontSize fontSize4 = new FontSize() { Val = "30" };

            runProperties2.Append(runFonts4);
            runProperties2.Append(bold4);
            runProperties2.Append(fontSize4);
            Text text2 = new Text();
            text2.Text = "Internet NZ Ltd.";

            run2.Append(runProperties2);
            run2.Append(text2);

            paragraph2.Append(paragraphProperties2);
            paragraph2.Append(run2);

            Paragraph paragraph3 = new Paragraph() { RsidParagraphMarkRevision = "00417926", RsidParagraphAddition = "00417926", RsidParagraphProperties = "00417926", RsidRunAdditionDefault = "00417926" };

            ParagraphProperties paragraphProperties3 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines3 = new SpacingBetweenLines() { After = "0" };
            Justification justification3 = new Justification() { Val = JustificationValues.Center };

            ParagraphMarkRunProperties paragraphMarkRunProperties3 = new ParagraphMarkRunProperties();
            RunFonts runFonts5 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize5 = new FontSize() { Val = "16" };

            paragraphMarkRunProperties3.Append(runFonts5);
            paragraphMarkRunProperties3.Append(fontSize5);

            paragraphProperties3.Append(spacingBetweenLines3);
            paragraphProperties3.Append(justification3);
            paragraphProperties3.Append(paragraphMarkRunProperties3);

            Run run3 = new Run() { RsidRunProperties = "00417926" };

            RunProperties runProperties3 = new RunProperties();
            RunFonts runFonts6 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize6 = new FontSize() { Val = "16" };

            runProperties3.Append(runFonts6);
            runProperties3.Append(fontSize6);
            Text text3 = new Text();
            text3.Text = "PO Box 5645 Moray Pl, Dunedin 9058, New Zealand";

            run3.Append(runProperties3);
            run3.Append(text3);

            paragraph3.Append(paragraphProperties3);
            paragraph3.Append(run3);

            Paragraph paragraph4 = new Paragraph() { RsidParagraphMarkRevision = "00417926", RsidParagraphAddition = "00417926", RsidParagraphProperties = "00417926", RsidRunAdditionDefault = "00417926" };

            ParagraphProperties paragraphProperties4 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines4 = new SpacingBetweenLines() { After = "0" };
            Justification justification4 = new Justification() { Val = JustificationValues.Center };

            ParagraphMarkRunProperties paragraphMarkRunProperties4 = new ParagraphMarkRunProperties();
            RunFonts runFonts7 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize7 = new FontSize() { Val = "16" };

            paragraphMarkRunProperties4.Append(runFonts7);
            paragraphMarkRunProperties4.Append(fontSize7);

            paragraphProperties4.Append(spacingBetweenLines4);
            paragraphProperties4.Append(justification4);
            paragraphProperties4.Append(paragraphMarkRunProperties4);

            Run run4 = new Run() { RsidRunProperties = "00417926" };

            RunProperties runProperties4 = new RunProperties();
            RunFonts runFonts8 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize8 = new FontSize() { Val = "16" };

            runProperties4.Append(runFonts8);
            runProperties4.Append(fontSize8);
            Text text4 = new Text();
            text4.Text = "Phone: +64 3 4745983, Email: [email protected]";

            run4.Append(runProperties4);
            run4.Append(text4);
            BookmarkStart bookmarkStart1 = new BookmarkStart() { Name = "_GoBack", Id = "0" };
            BookmarkEnd bookmarkEnd1 = new BookmarkEnd() { Id = "0" };

            paragraph4.Append(paragraphProperties4);
            paragraph4.Append(run4);
            paragraph4.Append(bookmarkStart1);
            paragraph4.Append(bookmarkEnd1);

            Paragraph paragraph5 = new Paragraph() { RsidParagraphMarkRevision = "00417926", RsidParagraphAddition = "00417926", RsidParagraphProperties = "00417926", RsidRunAdditionDefault = "00417926" };

            ParagraphProperties paragraphProperties5 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines5 = new SpacingBetweenLines() { After = "0" };
            Justification justification5 = new Justification() { Val = JustificationValues.Center };

            ParagraphMarkRunProperties paragraphMarkRunProperties5 = new ParagraphMarkRunProperties();
            RunFonts runFonts9 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize9 = new FontSize() { Val = "16" };

            paragraphMarkRunProperties5.Append(runFonts9);
            paragraphMarkRunProperties5.Append(fontSize9);

            paragraphProperties5.Append(spacingBetweenLines5);
            paragraphProperties5.Append(justification5);
            paragraphProperties5.Append(paragraphMarkRunProperties5);

            Run run5 = new Run() { RsidRunProperties = "00417926" };

            RunProperties runProperties5 = new RunProperties();
            RunFonts runFonts10 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize10 = new FontSize() { Val = "16" };

            runProperties5.Append(runFonts10);
            runProperties5.Append(fontSize10);
            Text text5 = new Text();
            text5.Text = "GST: 70-526-627 Website: www.hardtofind.co.nz";

            run5.Append(runProperties5);
            run5.Append(text5);

            paragraph5.Append(paragraphProperties5);
            paragraph5.Append(run5);

            Paragraph paragraph6 = new Paragraph() { RsidParagraphAddition = "00910498", RsidParagraphProperties = "00417926", RsidRunAdditionDefault = "00910498" };

            ParagraphProperties paragraphProperties6 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines6 = new SpacingBetweenLines() { After = "0" };

            ParagraphMarkRunProperties paragraphMarkRunProperties6 = new ParagraphMarkRunProperties();
            RunFonts runFonts11 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };

            paragraphMarkRunProperties6.Append(runFonts11);

            paragraphProperties6.Append(spacingBetweenLines6);
            paragraphProperties6.Append(paragraphMarkRunProperties6);

            paragraph6.Append(paragraphProperties6);

            Paragraph paragraph7 = new Paragraph() { RsidParagraphAddition = "00910498", RsidParagraphProperties = "00417926", RsidRunAdditionDefault = "00910498" };

            ParagraphProperties paragraphProperties7 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines7 = new SpacingBetweenLines() { After = "0" };

            ParagraphMarkRunProperties paragraphMarkRunProperties7 = new ParagraphMarkRunProperties();
            RunFonts runFonts12 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };

            paragraphMarkRunProperties7.Append(runFonts12);

            SectionProperties sectionProperties1 = new SectionProperties() { RsidR = "00910498" };
            PageSize pageSize1 = new PageSize() { Width = (UInt32Value)11906U, Height = (UInt32Value)16838U };
            PageMargin pageMargin1 = new PageMargin() { Top = 1440, Right = (UInt32Value)1440U, Bottom = 1440, Left = (UInt32Value)1440U, Header = (UInt32Value)708U, Footer = (UInt32Value)708U, Gutter = (UInt32Value)0U };
            Columns columns1 = new Columns() { Space = "708" };
            DocGrid docGrid1 = new DocGrid() { LinePitch = 360 };

            sectionProperties1.Append(pageSize1);
            sectionProperties1.Append(pageMargin1);
            sectionProperties1.Append(columns1);
            sectionProperties1.Append(docGrid1);

            paragraphProperties7.Append(spacingBetweenLines7);
            paragraphProperties7.Append(paragraphMarkRunProperties7);
            paragraphProperties7.Append(sectionProperties1);

            paragraph7.Append(paragraphProperties7);

            Paragraph paragraph8 = new Paragraph() { RsidParagraphAddition = "00417926", RsidParagraphProperties = "00417926", RsidRunAdditionDefault = "00417926" };

            ParagraphProperties paragraphProperties8 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines8 = new SpacingBetweenLines() { After = "0" };

            ParagraphMarkRunProperties paragraphMarkRunProperties8 = new ParagraphMarkRunProperties();
            RunFonts runFonts13 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize11 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties8.Append(runFonts13);
            paragraphMarkRunProperties8.Append(fontSize11);

            paragraphProperties8.Append(spacingBetweenLines8);
            paragraphProperties8.Append(paragraphMarkRunProperties8);

            Run run6 = new Run() { RsidRunProperties = "00417926" };

            RunProperties runProperties6 = new RunProperties();
            RunFonts runFonts14 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize12 = new FontSize() { Val = "24" };

            runProperties6.Append(runFonts14);
            runProperties6.Append(fontSize12);
            LastRenderedPageBreak lastRenderedPageBreak1 = new LastRenderedPageBreak();
            Text text6 = new Text();
            text6.Text = "Invoice:";

            run6.Append(runProperties6);
            run6.Append(lastRenderedPageBreak1);
            run6.Append(text6);

            paragraph8.Append(paragraphProperties8);
            paragraph8.Append(run6);

            Paragraph paragraph9 = new Paragraph() { RsidParagraphAddition = "00417926", RsidParagraphProperties = "00417926", RsidRunAdditionDefault = "00910498" };

            ParagraphProperties paragraphProperties9 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines9 = new SpacingBetweenLines() { After = "0" };

            ParagraphMarkRunProperties paragraphMarkRunProperties9 = new ParagraphMarkRunProperties();
            RunFonts runFonts15 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize13 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties9.Append(runFonts15);
            paragraphMarkRunProperties9.Append(fontSize13);

            paragraphProperties9.Append(spacingBetweenLines9);
            paragraphProperties9.Append(paragraphMarkRunProperties9);

            Run run7 = new Run();

            RunProperties runProperties7 = new RunProperties();
            RunFonts runFonts16 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize14 = new FontSize() { Val = "24" };

            runProperties7.Append(runFonts16);
            runProperties7.Append(fontSize14);
            TabChar tabChar1 = new TabChar();
            Text text7 = new Text();

            //TODO add in customer name
            if(customer != null)
                text7.Text = customer.firstName + " " + customer.lastName;
            else
                text7.Text = order.firstName + " " + order.lastName;

            run7.Append(runProperties7);
            run7.Append(tabChar1);
            run7.Append(text7);

            paragraph9.Append(paragraphProperties9);
            paragraph9.Append(run7);

            Paragraph paragraphInstitute = new Paragraph() { RsidParagraphAddition = "00417926", RsidParagraphProperties = "00417926", RsidRunAdditionDefault = "00910498" };

            ParagraphProperties paragraphInstituteProperties = new ParagraphProperties();
            SpacingBetweenLines institudeSpacingBetweenLines = new SpacingBetweenLines() { After = "0" };

            ParagraphMarkRunProperties paragraphInstituteMarkRunProperties = new ParagraphMarkRunProperties();
            RunFonts paragraphRunFonts = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize paragraphFontSize = new FontSize() { Val = "24" };

            paragraphInstituteMarkRunProperties.Append(paragraphRunFonts);
            paragraphInstituteMarkRunProperties.Append(paragraphFontSize);

            paragraphInstituteProperties.Append(institudeSpacingBetweenLines);
            paragraphInstituteProperties.Append(paragraphInstituteMarkRunProperties);

            Run instituteRun = new Run();

            RunProperties instituteRunProperties = new RunProperties();
            RunFonts instituteRunFonts = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize instituteFontSize = new FontSize() { Val = "24" };

            instituteRunProperties.Append(instituteRunFonts);
            instituteRunProperties.Append(instituteFontSize);
            TabChar instituteTabChar = new TabChar();
            Text instituteText = new Text();

            //TODO add in institute
            instituteText.Text = customer.institution;

            instituteRun.Append(instituteRunProperties);
            instituteRun.Append(instituteTabChar);
            instituteRun.Append(instituteText);

            paragraphInstitute.Append(paragraphInstituteProperties);
            paragraphInstitute.Append(instituteRun);

            Paragraph paragraph10 = new Paragraph() { RsidParagraphAddition = "00910498", RsidParagraphProperties = "00417926", RsidRunAdditionDefault = "00910498" };

            ParagraphProperties paragraphProperties10 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines10 = new SpacingBetweenLines() { After = "0" };

            ParagraphMarkRunProperties paragraphMarkRunProperties10 = new ParagraphMarkRunProperties();
            RunFonts runFonts17 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize15 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties10.Append(runFonts17);
            paragraphMarkRunProperties10.Append(fontSize15);

            paragraphProperties10.Append(spacingBetweenLines10);
            paragraphProperties10.Append(paragraphMarkRunProperties10);

            Run run8 = new Run();

            RunProperties runProperties8 = new RunProperties();
            RunFonts runFonts18 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize16 = new FontSize() { Val = "24" };

            runProperties8.Append(runFonts18);
            runProperties8.Append(fontSize16);
            TabChar tabChar2 = new TabChar();
            Text text8 = new Text();

            //TODO add in address1
            //text8.Text = "62 Seaview Avenue";
            if(customer != null)
                text8.Text = customer.address1;
            else
                text8.Text = "";

            run8.Append(runProperties8);
            run8.Append(tabChar2);
            run8.Append(text8);

            paragraph10.Append(paragraphProperties10);
            paragraph10.Append(run8);

            Paragraph paragraph11 = new Paragraph() { RsidParagraphAddition = "00910498", RsidParagraphProperties = "00417926", RsidRunAdditionDefault = "00910498" };

            ParagraphProperties paragraphProperties11 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines11 = new SpacingBetweenLines() { After = "0" };

            ParagraphMarkRunProperties paragraphMarkRunProperties11 = new ParagraphMarkRunProperties();
            RunFonts runFonts19 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize17 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties11.Append(runFonts19);
            paragraphMarkRunProperties11.Append(fontSize17);

            paragraphProperties11.Append(spacingBetweenLines11);
            paragraphProperties11.Append(paragraphMarkRunProperties11);

            Run run9 = new Run();

            RunProperties runProperties9 = new RunProperties();
            RunFonts runFonts20 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize18 = new FontSize() { Val = "24" };

            runProperties9.Append(runFonts20);
            runProperties9.Append(fontSize18);
            TabChar tabChar3 = new TabChar();
            Text text9 = new Text();

            //TODO add in address2
            //text9.Text = "Northcote";
            if(customer != null)
                text9.Text = customer.address2;
            else
                text9.Text = "";

            run9.Append(runProperties9);
            run9.Append(tabChar3);
            run9.Append(text9);

            paragraph11.Append(paragraphProperties11);
            paragraph11.Append(run9);

            Paragraph paragraph12 = new Paragraph() { RsidParagraphAddition = "00910498", RsidParagraphProperties = "00417926", RsidRunAdditionDefault = "00910498" };

            ParagraphProperties paragraphProperties12 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines12 = new SpacingBetweenLines() { After = "0" };

            ParagraphMarkRunProperties paragraphMarkRunProperties12 = new ParagraphMarkRunProperties();
            RunFonts runFonts21 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize19 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties12.Append(runFonts21);
            paragraphMarkRunProperties12.Append(fontSize19);

            paragraphProperties12.Append(spacingBetweenLines12);
            paragraphProperties12.Append(paragraphMarkRunProperties12);

            Run run10 = new Run();

            RunProperties runProperties10 = new RunProperties();
            RunFonts runFonts22 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize20 = new FontSize() { Val = "24" };

            runProperties10.Append(runFonts22);
            runProperties10.Append(fontSize20);
            TabChar tabChar4 = new TabChar();
            Text text10 = new Text();

            //TODO add in address3
            //text10.Text = "Auckland";
            if(customer != null)
                text10.Text = customer.address3;
            else
                text10.Text = "";

            run10.Append(runProperties10);
            run10.Append(tabChar4);
            run10.Append(text10);

            paragraph12.Append(paragraphProperties12);
            paragraph12.Append(run10);

            Paragraph paragraph13 = new Paragraph() { RsidParagraphAddition = "00910498", RsidParagraphProperties = "00417926", RsidRunAdditionDefault = "00910498" };

            ParagraphProperties paragraphProperties13 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines13 = new SpacingBetweenLines() { After = "0" };

            ParagraphMarkRunProperties paragraphMarkRunProperties13 = new ParagraphMarkRunProperties();
            RunFonts runFonts23 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize21 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties13.Append(runFonts23);
            paragraphMarkRunProperties13.Append(fontSize21);

            paragraphProperties13.Append(spacingBetweenLines13);
            paragraphProperties13.Append(paragraphMarkRunProperties13);

            Run run11 = new Run();

            RunProperties runProperties11 = new RunProperties();
            RunFonts runFonts24 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize22 = new FontSize() { Val = "24" };

            runProperties11.Append(runFonts24);
            runProperties11.Append(fontSize22);
            TabChar tabChar5 = new TabChar();
            Text text11 = new Text();

            //TODO add in postcode
            //text11.Text = "0627";
            if(customer != null)
                text11.Text = customer.postCode;
            else
                text11.Text = "";

            run11.Append(runProperties11);
            run11.Append(tabChar5);
            run11.Append(text11);

            paragraph13.Append(paragraphProperties13);
            paragraph13.Append(run11);

            Paragraph paragraph14 = new Paragraph() { RsidParagraphAddition = "00910498", RsidParagraphProperties = "00417926", RsidRunAdditionDefault = "00910498" };

            ParagraphProperties paragraphProperties14 = new ParagraphProperties();
            SpacingBetweenLines spacingBetweenLines14 = new SpacingBetweenLines() { After = "0" };

            ParagraphMarkRunProperties paragraphMarkRunProperties14 = new ParagraphMarkRunProperties();
            RunFonts runFonts25 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize23 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties14.Append(runFonts25);
            paragraphMarkRunProperties14.Append(fontSize23);

            paragraphProperties14.Append(spacingBetweenLines14);
            paragraphProperties14.Append(paragraphMarkRunProperties14);

            Run run12 = new Run();

            RunProperties runProperties12 = new RunProperties();
            RunFonts runFonts26 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize24 = new FontSize() { Val = "24" };

            runProperties12.Append(runFonts26);
            runProperties12.Append(fontSize24);
            TabChar tabChar6 = new TabChar();
            Text text12 = new Text();

            //TODO add in country
            if(customer != null)
                text12.Text = customer.country;
            else
                text12.Text = "";

            run12.Append(runProperties12);
            run12.Append(tabChar6);
            run12.Append(text12);

            paragraph14.Append(paragraphProperties14);
            paragraph14.Append(run12);

            Paragraph paragraph15 = new Paragraph() { RsidParagraphAddition = "003F6835", RsidParagraphProperties = "003F6835", RsidRunAdditionDefault = "00910498" };

            ParagraphProperties paragraphProperties15 = new ParagraphProperties();

            Tabs tabs1 = new Tabs();
            TabStop tabStop1 = new TabStop() { Val = TabStopValues.Left, Position = 2835 };

            tabs1.Append(tabStop1);
            SpacingBetweenLines spacingBetweenLines15 = new SpacingBetweenLines() { After = "0" };

            ParagraphMarkRunProperties paragraphMarkRunProperties15 = new ParagraphMarkRunProperties();
            RunFonts runFonts27 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize25 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties15.Append(runFonts27);
            paragraphMarkRunProperties15.Append(fontSize25);

            paragraphProperties15.Append(tabs1);
            paragraphProperties15.Append(spacingBetweenLines15);
            paragraphProperties15.Append(paragraphMarkRunProperties15);

            Run run13 = new Run();

            RunProperties runProperties13 = new RunProperties();
            RunFonts runFonts28 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize26 = new FontSize() { Val = "24" };

            runProperties13.Append(runFonts28);
            runProperties13.Append(fontSize26);
            Break break1 = new Break() { Type = BreakValues.Column };

            run13.Append(runProperties13);
            run13.Append(break1);

            paragraph15.Append(paragraphProperties15);
            paragraph15.Append(run13);

            Table table1 = new Table();

            TableProperties tableProperties1 = new TableProperties();
            TableStyle tableStyle1 = new TableStyle() { Val = "TableGrid" };
            TableWidth tableWidth1 = new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto };

            TableBorders tableBorders1 = new TableBorders();
            TopBorder topBorder1 = new TopBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U };
            LeftBorder leftBorder1 = new LeftBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U };
            BottomBorder bottomBorder1 = new BottomBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U };
            RightBorder rightBorder1 = new RightBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U };
            InsideHorizontalBorder insideHorizontalBorder1 = new InsideHorizontalBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U };
            InsideVerticalBorder insideVerticalBorder1 = new InsideVerticalBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U };

            tableBorders1.Append(topBorder1);
            tableBorders1.Append(leftBorder1);
            tableBorders1.Append(bottomBorder1);
            tableBorders1.Append(rightBorder1);
            tableBorders1.Append(insideHorizontalBorder1);
            tableBorders1.Append(insideVerticalBorder1);
            TableLook tableLook1 = new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true };

            tableProperties1.Append(tableStyle1);
            tableProperties1.Append(tableWidth1);
            tableProperties1.Append(tableBorders1);
            tableProperties1.Append(tableLook1);

            TableGrid tableGrid1 = new TableGrid();
            GridColumn gridColumn1 = new GridColumn() { Width = "3006" };
            GridColumn gridColumn2 = new GridColumn() { Width = "255" };
            GridColumn gridColumn3 = new GridColumn() { Width = "1099" };

            tableGrid1.Append(gridColumn1);
            tableGrid1.Append(gridColumn2);
            tableGrid1.Append(gridColumn3);

            TableRow tableRow1 = new TableRow() { RsidTableRowMarkRevision = "00613B48", RsidTableRowAddition = "00613B48", RsidTableRowProperties = "00613B48" };

            TableCell tableCell1 = new TableCell();

            TableCellProperties tableCellProperties1 = new TableCellProperties();
            TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = "3006", Type = TableWidthUnitValues.Dxa };

            tableCellProperties1.Append(tableCellWidth1);

            Paragraph paragraph16 = new Paragraph() { RsidParagraphMarkRevision = "00613B48", RsidParagraphAddition = "00613B48", RsidParagraphProperties = "00AB530E", RsidRunAdditionDefault = "00613B48" };

            ParagraphProperties paragraphProperties16 = new ParagraphProperties();

            ParagraphMarkRunProperties paragraphMarkRunProperties16 = new ParagraphMarkRunProperties();
            RunFonts runFonts29 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize27 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties16.Append(runFonts29);
            paragraphMarkRunProperties16.Append(fontSize27);

            paragraphProperties16.Append(paragraphMarkRunProperties16);

            Run run14 = new Run() { RsidRunProperties = "00613B48" };

            RunProperties runProperties14 = new RunProperties();
            RunFonts runFonts30 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize28 = new FontSize() { Val = "24" };

            runProperties14.Append(runFonts30);
            runProperties14.Append(fontSize28);
            Text text13 = new Text();
            text13.Text = "Date:";

            run14.Append(runProperties14);
            run14.Append(text13);

            paragraph16.Append(paragraphProperties16);
            paragraph16.Append(run14);

            tableCell1.Append(tableCellProperties1);
            tableCell1.Append(paragraph16);

            TableCell tableCell2 = new TableCell();

            TableCellProperties tableCellProperties2 = new TableCellProperties();
            TableCellWidth tableCellWidth2 = new TableCellWidth() { Width = "1354", Type = TableWidthUnitValues.Dxa };
            GridSpan gridSpan1 = new GridSpan() { Val = 2 };

            tableCellProperties2.Append(tableCellWidth2);
            tableCellProperties2.Append(gridSpan1);

            Paragraph paragraph17 = new Paragraph() { RsidParagraphMarkRevision = "00613B48", RsidParagraphAddition = "00613B48", RsidParagraphProperties = "00613B48", RsidRunAdditionDefault = "00613B48" };

            ParagraphProperties paragraphProperties17 = new ParagraphProperties();
            Justification justification6 = new Justification() { Val = JustificationValues.Right };

            ParagraphMarkRunProperties paragraphMarkRunProperties17 = new ParagraphMarkRunProperties();
            RunFonts runFonts31 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize29 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties17.Append(runFonts31);
            paragraphMarkRunProperties17.Append(fontSize29);

            paragraphProperties17.Append(justification6);
            paragraphProperties17.Append(paragraphMarkRunProperties17);

            Run run15 = new Run() { RsidRunProperties = "00613B48" };

            RunProperties runProperties15 = new RunProperties();
            RunFonts runFonts32 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize30 = new FontSize() { Val = "24" };

            runProperties15.Append(runFonts32);
            runProperties15.Append(fontSize30);
            Text text14 = new Text();

            //TODO add invoice date
            //text14.Text = "2/02/2016";
            text14.Text = order.invoiceDate.ToString("d/MM/yyyy"); ;

            run15.Append(runProperties15);
            run15.Append(text14);

            paragraph17.Append(paragraphProperties17);
            paragraph17.Append(run15);

            tableCell2.Append(tableCellProperties2);
            tableCell2.Append(paragraph17);

            tableRow1.Append(tableCell1);
            tableRow1.Append(tableCell2);

            TableRow tableRow2 = new TableRow() { RsidTableRowMarkRevision = "00613B48", RsidTableRowAddition = "00613B48", RsidTableRowProperties = "009B6C59" };

            TableCell tableCell3 = new TableCell();

            TableCellProperties tableCellProperties3 = new TableCellProperties();
            TableCellWidth tableCellWidth3 = new TableCellWidth() { Width = "3261", Type = TableWidthUnitValues.Dxa };
            GridSpan gridSpan2 = new GridSpan() { Val = 2 };

            tableCellProperties3.Append(tableCellWidth3);
            tableCellProperties3.Append(gridSpan2);

            Paragraph paragraph18 = new Paragraph() { RsidParagraphMarkRevision = "00613B48", RsidParagraphAddition = "00613B48", RsidParagraphProperties = "00AB530E", RsidRunAdditionDefault = "00613B48" };

            ParagraphProperties paragraphProperties18 = new ParagraphProperties();

            ParagraphMarkRunProperties paragraphMarkRunProperties18 = new ParagraphMarkRunProperties();
            RunFonts runFonts33 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize31 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties18.Append(runFonts33);
            paragraphMarkRunProperties18.Append(fontSize31);

            paragraphProperties18.Append(paragraphMarkRunProperties18);

            Run run16 = new Run() { RsidRunProperties = "00613B48" };

            RunProperties runProperties16 = new RunProperties();
            RunFonts runFonts34 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize32 = new FontSize() { Val = "24" };

            runProperties16.Append(runFonts34);
            runProperties16.Append(fontSize32);
            Text text15 = new Text();
            text15.Text = "GST Tax Invoice Number:";

            run16.Append(runProperties16);
            run16.Append(text15);

            paragraph18.Append(paragraphProperties18);
            paragraph18.Append(run16);

            tableCell3.Append(tableCellProperties3);
            tableCell3.Append(paragraph18);

            TableCell tableCell4 = new TableCell();

            TableCellProperties tableCellProperties4 = new TableCellProperties();
            TableCellWidth tableCellWidth4 = new TableCellWidth() { Width = "1099", Type = TableWidthUnitValues.Dxa };

            tableCellProperties4.Append(tableCellWidth4);

            Paragraph paragraph19 = new Paragraph() { RsidParagraphMarkRevision = "00613B48", RsidParagraphAddition = "00613B48", RsidParagraphProperties = "00613B48", RsidRunAdditionDefault = "00613B48" };

            ParagraphProperties paragraphProperties19 = new ParagraphProperties();
            Justification justification7 = new Justification() { Val = JustificationValues.Right };

            ParagraphMarkRunProperties paragraphMarkRunProperties19 = new ParagraphMarkRunProperties();
            RunFonts runFonts35 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize33 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties19.Append(runFonts35);
            paragraphMarkRunProperties19.Append(fontSize33);

            paragraphProperties19.Append(justification7);
            paragraphProperties19.Append(paragraphMarkRunProperties19);

            Run run17 = new Run() { RsidRunProperties = "00613B48" };

            RunProperties runProperties17 = new RunProperties();
            RunFonts runFonts36 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize34 = new FontSize() { Val = "24" };

            runProperties17.Append(runFonts36);
            runProperties17.Append(fontSize34);
            Text text16 = new Text();

            //TODO add invoice number/orderID
            //text16.Text = "39248";
            text16.Text = order.orderID.ToString();

            run17.Append(runProperties17);
            run17.Append(text16);

            paragraph19.Append(paragraphProperties19);
            paragraph19.Append(run17);

            tableCell4.Append(tableCellProperties4);
            tableCell4.Append(paragraph19);

            tableRow2.Append(tableCell3);
            tableRow2.Append(tableCell4);

            TableRow tableRow3 = new TableRow() { RsidTableRowMarkRevision = "00613B48", RsidTableRowAddition = "00613B48", RsidTableRowProperties = "00613B48" };

            TableCell tableCell5 = new TableCell();

            TableCellProperties tableCellProperties5 = new TableCellProperties();
            TableCellWidth tableCellWidth5 = new TableCellWidth() { Width = "3006", Type = TableWidthUnitValues.Dxa };

            tableCellProperties5.Append(tableCellWidth5);

            Paragraph paragraph20 = new Paragraph() { RsidParagraphMarkRevision = "00613B48", RsidParagraphAddition = "00613B48", RsidParagraphProperties = "00AB530E", RsidRunAdditionDefault = "00613B48" };

            ParagraphProperties paragraphProperties20 = new ParagraphProperties();

            ParagraphMarkRunProperties paragraphMarkRunProperties20 = new ParagraphMarkRunProperties();
            RunFonts runFonts37 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize35 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties20.Append(runFonts37);
            paragraphMarkRunProperties20.Append(fontSize35);

            paragraphProperties20.Append(paragraphMarkRunProperties20);

            Run run18 = new Run() { RsidRunProperties = "00613B48" };

            RunProperties runProperties18 = new RunProperties();
            RunFonts runFonts38 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize36 = new FontSize() { Val = "24" };

            runProperties18.Append(runFonts38);
            runProperties18.Append(fontSize36);
            Text text17 = new Text();
            text17.Text = "Your Reference:";

            run18.Append(runProperties18);
            run18.Append(text17);

            paragraph20.Append(paragraphProperties20);
            paragraph20.Append(run18);

            tableCell5.Append(tableCellProperties5);
            tableCell5.Append(paragraph20);

            TableCell tableCell6 = new TableCell();

            TableCellProperties tableCellProperties6 = new TableCellProperties();
            TableCellWidth tableCellWidth6 = new TableCellWidth() { Width = "1354", Type = TableWidthUnitValues.Dxa };
            GridSpan gridSpan3 = new GridSpan() { Val = 2 };

            tableCellProperties6.Append(tableCellWidth6);
            tableCellProperties6.Append(gridSpan3);

            Paragraph paragraph21 = new Paragraph() { RsidParagraphMarkRevision = "00613B48", RsidParagraphAddition = "00613B48", RsidParagraphProperties = "00613B48", RsidRunAdditionDefault = "00613B48" };

            ParagraphProperties paragraphProperties21 = new ParagraphProperties();
            Justification justification8 = new Justification() { Val = JustificationValues.Right };

            ParagraphMarkRunProperties paragraphMarkRunProperties21 = new ParagraphMarkRunProperties();
            RunFonts runFonts39 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize37 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties21.Append(runFonts39);
            paragraphMarkRunProperties21.Append(fontSize37);

            paragraphProperties21.Append(justification8);
            paragraphProperties21.Append(paragraphMarkRunProperties21);

            Run run19 = new Run() { RsidRunProperties = "00613B48" };

            RunProperties runProperties19 = new RunProperties();
            RunFonts runFonts40 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize38 = new FontSize() { Val = "24" };

            runProperties19.Append(runFonts40);
            runProperties19.Append(fontSize38);
            Text text18 = new Text();

            //TODO add order reference
            //text18.Text = "Visa";
            text18.Text = order.orderReference;

            run19.Append(runProperties19);
            run19.Append(text18);

            paragraph21.Append(paragraphProperties21);
            paragraph21.Append(run19);

            tableCell6.Append(tableCellProperties6);
            tableCell6.Append(paragraph21);

            tableRow3.Append(tableCell5);
            tableRow3.Append(tableCell6);

            table1.Append(tableProperties1);
            table1.Append(tableGrid1);
            table1.Append(tableRow1);
            table1.Append(tableRow2);
            table1.Append(tableRow3);

            Paragraph paragraph22 = new Paragraph() { RsidParagraphAddition = "00EA7D1E", RsidParagraphProperties = "007F61F5", RsidRunAdditionDefault = "00EA7D1E" };

            ParagraphProperties paragraphProperties22 = new ParagraphProperties();

            Tabs tabs2 = new Tabs();
            TabStop tabStop2 = new TabStop() { Val = TabStopValues.Left, Position = 3119 };

            tabs2.Append(tabStop2);
            SpacingBetweenLines spacingBetweenLines16 = new SpacingBetweenLines() { After = "0" };

            ParagraphMarkRunProperties paragraphMarkRunProperties22 = new ParagraphMarkRunProperties();
            RunFonts runFonts41 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize39 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties22.Append(runFonts41);
            paragraphMarkRunProperties22.Append(fontSize39);

            paragraphProperties22.Append(tabs2);
            paragraphProperties22.Append(spacingBetweenLines16);
            paragraphProperties22.Append(paragraphMarkRunProperties22);

            paragraph22.Append(paragraphProperties22);

            Paragraph paragraph23 = new Paragraph() { RsidParagraphAddition = "00EA7D1E", RsidParagraphProperties = "007F61F5", RsidRunAdditionDefault = "00EA7D1E" };

            ParagraphProperties paragraphProperties23 = new ParagraphProperties();

            Tabs tabs3 = new Tabs();
            TabStop tabStop3 = new TabStop() { Val = TabStopValues.Left, Position = 3119 };

            tabs3.Append(tabStop3);
            SpacingBetweenLines spacingBetweenLines17 = new SpacingBetweenLines() { After = "0" };

            ParagraphMarkRunProperties paragraphMarkRunProperties23 = new ParagraphMarkRunProperties();
            RunFonts runFonts42 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize40 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties23.Append(runFonts42);
            paragraphMarkRunProperties23.Append(fontSize40);

            SectionProperties sectionProperties2 = new SectionProperties() { RsidR = "00EA7D1E", RsidSect = "00015C18" };
            SectionType sectionType1 = new SectionType() { Val = SectionMarkValues.Continuous };
            PageSize pageSize2 = new PageSize() { Width = (UInt32Value)11906U, Height = (UInt32Value)16838U };
            PageMargin pageMargin2 = new PageMargin() { Top = 1440, Right = (UInt32Value)1440U, Bottom = 1440, Left = (UInt32Value)1440U, Header = (UInt32Value)708U, Footer = (UInt32Value)708U, Gutter = (UInt32Value)0U };
            Columns columns2 = new Columns() { Space = "286", ColumnCount = 2 };
            DocGrid docGrid2 = new DocGrid() { LinePitch = 360 };

            sectionProperties2.Append(sectionType1);
            sectionProperties2.Append(pageSize2);
            sectionProperties2.Append(pageMargin2);
            sectionProperties2.Append(columns2);
            sectionProperties2.Append(docGrid2);

            paragraphProperties23.Append(tabs3);
            paragraphProperties23.Append(spacingBetweenLines17);
            paragraphProperties23.Append(paragraphMarkRunProperties23);
            paragraphProperties23.Append(sectionProperties2);

            paragraph23.Append(paragraphProperties23);

            Paragraph paragraph24 = new Paragraph() { RsidParagraphMarkRevision = "00646179", RsidParagraphAddition = "00443ACA", RsidParagraphProperties = "00646179", RsidRunAdditionDefault = "00443ACA" };

            ParagraphProperties paragraphProperties24 = new ParagraphProperties();

            Tabs tabs4 = new Tabs();
            TabStop tabStop4 = new TabStop() { Val = TabStopValues.Left, Position = 3119 };

            tabs4.Append(tabStop4);
            SpacingBetweenLines spacingBetweenLines18 = new SpacingBetweenLines() { After = "0" };

            ParagraphMarkRunProperties paragraphMarkRunProperties24 = new ParagraphMarkRunProperties();
            RunFonts runFonts43 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize41 = new FontSize() { Val = "24" };

            paragraphMarkRunProperties24.Append(runFonts43);
            paragraphMarkRunProperties24.Append(fontSize41);

            paragraphProperties24.Append(tabs4);
            paragraphProperties24.Append(spacingBetweenLines18);
            paragraphProperties24.Append(paragraphMarkRunProperties24);

            paragraph24.Append(paragraphProperties24);

            Table table2 = new Table();

            TableProperties tableProperties2 = new TableProperties();
            TableStyle tableStyle2 = new TableStyle() { Val = "TableGrid" };
            TableWidth tableWidth2 = new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto };

            TableBorders tableBorders2 = new TableBorders();
            LeftBorder leftBorder2 = new LeftBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U };
            RightBorder rightBorder2 = new RightBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U };
            InsideVerticalBorder insideVerticalBorder2 = new InsideVerticalBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U };

            tableBorders2.Append(leftBorder2);
            tableBorders2.Append(rightBorder2);
            tableBorders2.Append(insideVerticalBorder2);
            TableLook tableLook2 = new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true };

            tableProperties2.Append(tableStyle2);
            tableProperties2.Append(tableWidth2);
            tableProperties2.Append(tableBorders2);
            tableProperties2.Append(tableLook2);

            TableGrid tableGrid2 = new TableGrid();
            GridColumn gridColumn4 = new GridColumn() { Width = "1418" };
            GridColumn gridColumn5 = new GridColumn() { Width = "2719" };
            GridColumn gridColumn6 = new GridColumn() { Width = "1036" };
            GridColumn gridColumn7 = new GridColumn() { Width = "1364" };
            GridColumn gridColumn8 = new GridColumn() { Width = "1411" };
            GridColumn gridColumn9 = new GridColumn() { Width = "1078" };

            tableGrid2.Append(gridColumn4);
            tableGrid2.Append(gridColumn5);
            tableGrid2.Append(gridColumn6);
            tableGrid2.Append(gridColumn7);
            tableGrid2.Append(gridColumn8);
            tableGrid2.Append(gridColumn9);

            TableRow tableRow4 = new TableRow() { RsidTableRowAddition = "00443ACA", RsidTableRowProperties = "00506382" };

            TableCell tableCell7 = new TableCell();

            TableCellProperties tableCellProperties7 = new TableCellProperties();
            TableCellWidth tableCellWidth7 = new TableCellWidth() { Width = "1418", Type = TableWidthUnitValues.Dxa };

            tableCellProperties7.Append(tableCellWidth7);

            Paragraph paragraph25 = new Paragraph() { RsidParagraphMarkRevision = "00443ACA", RsidParagraphAddition = "00443ACA", RsidParagraphProperties = "00443ACA", RsidRunAdditionDefault = "00443ACA" };

            ParagraphProperties paragraphProperties25 = new ParagraphProperties();

            Tabs tabs5 = new Tabs();
            TabStop tabStop5 = new TabStop() { Val = TabStopValues.Left, Position = 1560 };
            TabStop tabStop6 = new TabStop() { Val = TabStopValues.Left, Position = 3969 };
            TabStop tabStop7 = new TabStop() { Val = TabStopValues.Left, Position = 5387 };
            TabStop tabStop8 = new TabStop() { Val = TabStopValues.Left, Position = 6379 };
            TabStop tabStop9 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

            tabs5.Append(tabStop5);
            tabs5.Append(tabStop6);
            tabs5.Append(tabStop7);
            tabs5.Append(tabStop8);
            tabs5.Append(tabStop9);
            SpacingBetweenLines spacingBetweenLines19 = new SpacingBetweenLines() { Before = "60", After = "60" };

            ParagraphMarkRunProperties paragraphMarkRunProperties25 = new ParagraphMarkRunProperties();
            RunFonts runFonts44 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };

            paragraphMarkRunProperties25.Append(runFonts44);

            paragraphProperties25.Append(tabs5);
            paragraphProperties25.Append(spacingBetweenLines19);
            paragraphProperties25.Append(paragraphMarkRunProperties25);
            ProofError proofError1 = new ProofError() { Type = ProofingErrorValues.SpellStart };

            Run run20 = new Run() { RsidRunProperties = "00443ACA" };

            RunProperties runProperties20 = new RunProperties();
            RunFonts runFonts45 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };

            runProperties20.Append(runFonts45);
            Text text19 = new Text();
            text19.Text = "BookID";

            run20.Append(runProperties20);
            run20.Append(text19);
            ProofError proofError2 = new ProofError() { Type = ProofingErrorValues.SpellEnd };

            paragraph25.Append(paragraphProperties25);
            paragraph25.Append(proofError1);
            paragraph25.Append(run20);
            paragraph25.Append(proofError2);

            tableCell7.Append(tableCellProperties7);
            tableCell7.Append(paragraph25);

            TableCell tableCell8 = new TableCell();

            TableCellProperties tableCellProperties8 = new TableCellProperties();
            TableCellWidth tableCellWidth8 = new TableCellWidth() { Width = "2719", Type = TableWidthUnitValues.Dxa };

            tableCellProperties8.Append(tableCellWidth8);

            Paragraph paragraph26 = new Paragraph() { RsidParagraphMarkRevision = "00443ACA", RsidParagraphAddition = "00443ACA", RsidParagraphProperties = "00443ACA", RsidRunAdditionDefault = "00443ACA" };

            ParagraphProperties paragraphProperties26 = new ParagraphProperties();

            Tabs tabs6 = new Tabs();
            TabStop tabStop10 = new TabStop() { Val = TabStopValues.Left, Position = 1560 };
            TabStop tabStop11 = new TabStop() { Val = TabStopValues.Left, Position = 3969 };
            TabStop tabStop12 = new TabStop() { Val = TabStopValues.Left, Position = 5387 };
            TabStop tabStop13 = new TabStop() { Val = TabStopValues.Left, Position = 6379 };
            TabStop tabStop14 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

            tabs6.Append(tabStop10);
            tabs6.Append(tabStop11);
            tabs6.Append(tabStop12);
            tabs6.Append(tabStop13);
            tabs6.Append(tabStop14);
            SpacingBetweenLines spacingBetweenLines20 = new SpacingBetweenLines() { Before = "60", After = "60" };

            ParagraphMarkRunProperties paragraphMarkRunProperties26 = new ParagraphMarkRunProperties();
            RunFonts runFonts46 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };

            paragraphMarkRunProperties26.Append(runFonts46);

            paragraphProperties26.Append(tabs6);
            paragraphProperties26.Append(spacingBetweenLines20);
            paragraphProperties26.Append(paragraphMarkRunProperties26);

            Run run21 = new Run() { RsidRunProperties = "00443ACA" };

            RunProperties runProperties21 = new RunProperties();
            RunFonts runFonts47 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };

            runProperties21.Append(runFonts47);
            Text text20 = new Text();
            text20.Text = "Description";

            run21.Append(runProperties21);
            run21.Append(text20);

            paragraph26.Append(paragraphProperties26);
            paragraph26.Append(run21);

            tableCell8.Append(tableCellProperties8);
            tableCell8.Append(paragraph26);

            TableCell tableCell9 = new TableCell();

            TableCellProperties tableCellProperties9 = new TableCellProperties();
            TableCellWidth tableCellWidth9 = new TableCellWidth() { Width = "1036", Type = TableWidthUnitValues.Dxa };

            tableCellProperties9.Append(tableCellWidth9);

            Paragraph paragraph27 = new Paragraph() { RsidParagraphMarkRevision = "00443ACA", RsidParagraphAddition = "00443ACA", RsidParagraphProperties = "00443ACA", RsidRunAdditionDefault = "00443ACA" };

            ParagraphProperties paragraphProperties27 = new ParagraphProperties();

            Tabs tabs7 = new Tabs();
            TabStop tabStop15 = new TabStop() { Val = TabStopValues.Left, Position = 1560 };
            TabStop tabStop16 = new TabStop() { Val = TabStopValues.Left, Position = 3969 };
            TabStop tabStop17 = new TabStop() { Val = TabStopValues.Left, Position = 5387 };
            TabStop tabStop18 = new TabStop() { Val = TabStopValues.Left, Position = 6379 };
            TabStop tabStop19 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

            tabs7.Append(tabStop15);
            tabs7.Append(tabStop16);
            tabs7.Append(tabStop17);
            tabs7.Append(tabStop18);
            tabs7.Append(tabStop19);
            SpacingBetweenLines spacingBetweenLines21 = new SpacingBetweenLines() { Before = "60", After = "60" };
            Justification justification9 = new Justification() { Val = JustificationValues.Right };

            ParagraphMarkRunProperties paragraphMarkRunProperties27 = new ParagraphMarkRunProperties();
            RunFonts runFonts48 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };

            paragraphMarkRunProperties27.Append(runFonts48);

            paragraphProperties27.Append(tabs7);
            paragraphProperties27.Append(spacingBetweenLines21);
            paragraphProperties27.Append(justification9);
            paragraphProperties27.Append(paragraphMarkRunProperties27);

            Run run22 = new Run() { RsidRunProperties = "00443ACA" };

            RunProperties runProperties22 = new RunProperties();
            RunFonts runFonts49 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };

            runProperties22.Append(runFonts49);
            Text text21 = new Text();
            text21.Text = "Quantity";

            run22.Append(runProperties22);
            run22.Append(text21);

            paragraph27.Append(paragraphProperties27);
            paragraph27.Append(run22);

            tableCell9.Append(tableCellProperties9);
            tableCell9.Append(paragraph27);

            TableCell tableCell10 = new TableCell();

            TableCellProperties tableCellProperties10 = new TableCellProperties();
            TableCellWidth tableCellWidth10 = new TableCellWidth() { Width = "1364", Type = TableWidthUnitValues.Dxa };

            tableCellProperties10.Append(tableCellWidth10);

            Paragraph paragraph28 = new Paragraph() { RsidParagraphMarkRevision = "00443ACA", RsidParagraphAddition = "00443ACA", RsidParagraphProperties = "00443ACA", RsidRunAdditionDefault = "00443ACA" };

            ParagraphProperties paragraphProperties28 = new ParagraphProperties();

            Tabs tabs8 = new Tabs();
            TabStop tabStop20 = new TabStop() { Val = TabStopValues.Left, Position = 1560 };
            TabStop tabStop21 = new TabStop() { Val = TabStopValues.Left, Position = 3969 };
            TabStop tabStop22 = new TabStop() { Val = TabStopValues.Left, Position = 5387 };
            TabStop tabStop23 = new TabStop() { Val = TabStopValues.Left, Position = 6379 };
            TabStop tabStop24 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

            tabs8.Append(tabStop20);
            tabs8.Append(tabStop21);
            tabs8.Append(tabStop22);
            tabs8.Append(tabStop23);
            tabs8.Append(tabStop24);
            SpacingBetweenLines spacingBetweenLines22 = new SpacingBetweenLines() { Before = "60", After = "60" };
            Justification justification10 = new Justification() { Val = JustificationValues.Right };

            ParagraphMarkRunProperties paragraphMarkRunProperties28 = new ParagraphMarkRunProperties();
            RunFonts runFonts50 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };

            paragraphMarkRunProperties28.Append(runFonts50);

            paragraphProperties28.Append(tabs8);
            paragraphProperties28.Append(spacingBetweenLines22);
            paragraphProperties28.Append(justification10);
            paragraphProperties28.Append(paragraphMarkRunProperties28);

            Run run23 = new Run() { RsidRunProperties = "00443ACA" };

            RunProperties runProperties23 = new RunProperties();
            RunFonts runFonts51 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };

            runProperties23.Append(runFonts51);
            Text text22 = new Text();
            text22.Text = "Price";

            run23.Append(runProperties23);
            run23.Append(text22);

            paragraph28.Append(paragraphProperties28);
            paragraph28.Append(run23);

            tableCell10.Append(tableCellProperties10);
            tableCell10.Append(paragraph28);

            TableCell tableCell11 = new TableCell();

            TableCellProperties tableCellProperties11 = new TableCellProperties();
            TableCellWidth tableCellWidth11 = new TableCellWidth() { Width = "1411", Type = TableWidthUnitValues.Dxa };

            tableCellProperties11.Append(tableCellWidth11);

            Paragraph paragraph29 = new Paragraph() { RsidParagraphMarkRevision = "00443ACA", RsidParagraphAddition = "00443ACA", RsidParagraphProperties = "00443ACA", RsidRunAdditionDefault = "00443ACA" };

            ParagraphProperties paragraphProperties29 = new ParagraphProperties();

            Tabs tabs9 = new Tabs();
            TabStop tabStop25 = new TabStop() { Val = TabStopValues.Left, Position = 1560 };
            TabStop tabStop26 = new TabStop() { Val = TabStopValues.Left, Position = 3969 };
            TabStop tabStop27 = new TabStop() { Val = TabStopValues.Left, Position = 5387 };
            TabStop tabStop28 = new TabStop() { Val = TabStopValues.Left, Position = 6379 };
            TabStop tabStop29 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

            tabs9.Append(tabStop25);
            tabs9.Append(tabStop26);
            tabs9.Append(tabStop27);
            tabs9.Append(tabStop28);
            tabs9.Append(tabStop29);
            SpacingBetweenLines spacingBetweenLines23 = new SpacingBetweenLines() { Before = "60", After = "60" };
            Justification justification11 = new Justification() { Val = JustificationValues.Right };

            ParagraphMarkRunProperties paragraphMarkRunProperties29 = new ParagraphMarkRunProperties();
            RunFonts runFonts52 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };

            paragraphMarkRunProperties29.Append(runFonts52);

            paragraphProperties29.Append(tabs9);
            paragraphProperties29.Append(spacingBetweenLines23);
            paragraphProperties29.Append(justification11);
            paragraphProperties29.Append(paragraphMarkRunProperties29);

            Run run24 = new Run() { RsidRunProperties = "00443ACA" };

            RunProperties runProperties24 = new RunProperties();
            RunFonts runFonts53 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };

            runProperties24.Append(runFonts53);
            Text text23 = new Text();
            text23.Text = "Discount";

            run24.Append(runProperties24);
            run24.Append(text23);

            paragraph29.Append(paragraphProperties29);
            paragraph29.Append(run24);

            tableCell11.Append(tableCellProperties11);
            tableCell11.Append(paragraph29);

            TableCell tableCell12 = new TableCell();

            TableCellProperties tableCellProperties12 = new TableCellProperties();
            TableCellWidth tableCellWidth12 = new TableCellWidth() { Width = "1078", Type = TableWidthUnitValues.Dxa };

            tableCellProperties12.Append(tableCellWidth12);

            Paragraph paragraph30 = new Paragraph() { RsidParagraphMarkRevision = "00443ACA", RsidParagraphAddition = "00443ACA", RsidParagraphProperties = "00443ACA", RsidRunAdditionDefault = "00443ACA" };

            ParagraphProperties paragraphProperties30 = new ParagraphProperties();

            Tabs tabs10 = new Tabs();
            TabStop tabStop30 = new TabStop() { Val = TabStopValues.Left, Position = 1560 };
            TabStop tabStop31 = new TabStop() { Val = TabStopValues.Left, Position = 3969 };
            TabStop tabStop32 = new TabStop() { Val = TabStopValues.Left, Position = 5387 };
            TabStop tabStop33 = new TabStop() { Val = TabStopValues.Left, Position = 6379 };
            TabStop tabStop34 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

            tabs10.Append(tabStop30);
            tabs10.Append(tabStop31);
            tabs10.Append(tabStop32);
            tabs10.Append(tabStop33);
            tabs10.Append(tabStop34);
            SpacingBetweenLines spacingBetweenLines24 = new SpacingBetweenLines() { Before = "60", After = "60" };
            Justification justification12 = new Justification() { Val = JustificationValues.Right };

            ParagraphMarkRunProperties paragraphMarkRunProperties30 = new ParagraphMarkRunProperties();
            RunFonts runFonts54 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };

            paragraphMarkRunProperties30.Append(runFonts54);

            paragraphProperties30.Append(tabs10);
            paragraphProperties30.Append(spacingBetweenLines24);
            paragraphProperties30.Append(justification12);
            paragraphProperties30.Append(paragraphMarkRunProperties30);

            Run run25 = new Run() { RsidRunProperties = "00443ACA" };

            RunProperties runProperties25 = new RunProperties();
            RunFonts runFonts55 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };

            runProperties25.Append(runFonts55);
            Text text24 = new Text();
            text24.Text = "Total";

            run25.Append(runProperties25);
            run25.Append(text24);

            paragraph30.Append(paragraphProperties30);
            paragraph30.Append(run25);

            tableCell12.Append(tableCellProperties12);
            tableCell12.Append(paragraph30);

            tableRow4.Append(tableCell7);
            tableRow4.Append(tableCell8);
            tableRow4.Append(tableCell9);
            tableRow4.Append(tableCell10);
            tableRow4.Append(tableCell11);
            tableRow4.Append(tableCell12);

            table2.Append(tableProperties2);
            table2.Append(tableGrid2);
            table2.Append(tableRow4);

            /****** Loop from here? **********/
            foreach (OrderedStock o in orderedStock)
            {
                //Create a table row
                TableRow orderedStockRow = new TableRow() { RsidTableRowAddition = "00443ACA", RsidTableRowProperties = "00506382" };

                //Create cell to hold bookID
                TableCell cellBookID = new TableCell();

                TableCellProperties cellBookIDProperties = new TableCellProperties();
                TableCellWidth cellBookIDWidth = new TableCellWidth() { Width = "1418", Type = TableWidthUnitValues.Dxa };

                cellBookIDProperties.Append(cellBookIDWidth);

                Paragraph paragraph31 = new Paragraph() { RsidParagraphMarkRevision = "00443ACA", RsidParagraphAddition = "00443ACA", RsidParagraphProperties = "00443ACA", RsidRunAdditionDefault = "00443ACA" };

                ParagraphProperties paragraphProperties31 = new ParagraphProperties();

                Tabs tabs11 = new Tabs();
                TabStop tabStop35 = new TabStop() { Val = TabStopValues.Left, Position = 1560 };
                TabStop tabStop36 = new TabStop() { Val = TabStopValues.Left, Position = 3969 };
                TabStop tabStop37 = new TabStop() { Val = TabStopValues.Left, Position = 5387 };
                TabStop tabStop38 = new TabStop() { Val = TabStopValues.Left, Position = 6379 };
                TabStop tabStop39 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

                tabs11.Append(tabStop35);
                tabs11.Append(tabStop36);
                tabs11.Append(tabStop37);
                tabs11.Append(tabStop38);
                tabs11.Append(tabStop39);
                SpacingBetweenLines spacingBetweenLines25 = new SpacingBetweenLines() { Before = "60", After = "60" };

                ParagraphMarkRunProperties paragraphMarkRunProperties31 = new ParagraphMarkRunProperties();
                RunFonts runFonts56 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
                FontSize fontSize42 = new FontSize() { Val = "18" };

                paragraphMarkRunProperties31.Append(runFonts56);
                paragraphMarkRunProperties31.Append(fontSize42);

                paragraphProperties31.Append(tabs11);
                paragraphProperties31.Append(spacingBetweenLines25);
                paragraphProperties31.Append(paragraphMarkRunProperties31);

                Run run26 = new Run() { RsidRunProperties = "00443ACA" };

                RunProperties runProperties26 = new RunProperties();
                RunFonts runFonts57 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
                FontSize fontSize43 = new FontSize() { Val = "18" };

                runProperties26.Append(runFonts57);
                runProperties26.Append(fontSize43);
                Text text25 = new Text();

                //TODO Book ID
                text25.Text = o.bookID;

                run26.Append(runProperties26);
                run26.Append(text25);

                paragraph31.Append(paragraphProperties31);
                paragraph31.Append(run26);

                cellBookID.Append(cellBookIDProperties);
                cellBookID.Append(paragraph31);

                //Cell for description
                TableCell tableCell14 = new TableCell();

                TableCellProperties tableCellProperties14 = new TableCellProperties();
                TableCellWidth tableCellWidth14 = new TableCellWidth() { Width = "2719", Type = TableWidthUnitValues.Dxa };

                tableCellProperties14.Append(tableCellWidth14);

                Paragraph paragraph32 = new Paragraph() { RsidParagraphMarkRevision = "00443ACA", RsidParagraphAddition = "00443ACA", RsidParagraphProperties = "00443ACA", RsidRunAdditionDefault = "00443ACA" };

                ParagraphProperties paragraphProperties32 = new ParagraphProperties();

                Tabs tabs12 = new Tabs();
                TabStop tabStop40 = new TabStop() { Val = TabStopValues.Left, Position = 1560 };
                TabStop tabStop41 = new TabStop() { Val = TabStopValues.Left, Position = 3969 };
                TabStop tabStop42 = new TabStop() { Val = TabStopValues.Left, Position = 5387 };
                TabStop tabStop43 = new TabStop() { Val = TabStopValues.Left, Position = 6379 };
                TabStop tabStop44 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

                tabs12.Append(tabStop40);
                tabs12.Append(tabStop41);
                tabs12.Append(tabStop42);
                tabs12.Append(tabStop43);
                tabs12.Append(tabStop44);
                SpacingBetweenLines spacingBetweenLines26 = new SpacingBetweenLines() { Before = "60", After = "60" };

                ParagraphMarkRunProperties paragraphMarkRunProperties32 = new ParagraphMarkRunProperties();
                RunFonts runFonts58 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
                FontSize fontSize44 = new FontSize() { Val = "18" };

                paragraphMarkRunProperties32.Append(runFonts58);
                paragraphMarkRunProperties32.Append(fontSize44);

                paragraphProperties32.Append(tabs12);
                paragraphProperties32.Append(spacingBetweenLines26);
                paragraphProperties32.Append(paragraphMarkRunProperties32);

                Run run27 = new Run() { RsidRunProperties = "00443ACA" };

                RunProperties runProperties27 = new RunProperties();
                RunFonts runFonts59 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
                FontSize fontSize45 = new FontSize() { Val = "18" };

                runProperties27.Append(runFonts59);
                runProperties27.Append(fontSize45);
                Text text26 = new Text() { Space = SpaceProcessingModeValues.Preserve };

                //TODO Author name
                string author = o.author;
                text26.Text = author;

                run27.Append(runProperties27);
                run27.Append(text26);
                ProofError proofError3 = new ProofError() { Type = ProofingErrorValues.SpellStart };

                RunProperties runProperties28 = new RunProperties();
                RunFonts runFonts60 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
                FontSize fontSize46 = new FontSize() { Val = "18" };

                runProperties28.Append(runFonts60);
                runProperties28.Append(fontSize46);

                ProofError proofError4 = new ProofError() { Type = ProofingErrorValues.SpellEnd };

                paragraph32.Append(paragraphProperties32);
                paragraph32.Append(run27);
                paragraph32.Append(proofError3);

                Paragraph paragraph33 = new Paragraph() { RsidParagraphMarkRevision = "00443ACA", RsidParagraphAddition = "00443ACA", RsidParagraphProperties = "00443ACA", RsidRunAdditionDefault = "00443ACA" };

                ParagraphProperties paragraphProperties33 = new ParagraphProperties();

                Tabs tabs13 = new Tabs();
                TabStop tabStop45 = new TabStop() { Val = TabStopValues.Left, Position = 1560 };
                TabStop tabStop46 = new TabStop() { Val = TabStopValues.Left, Position = 3969 };
                TabStop tabStop47 = new TabStop() { Val = TabStopValues.Left, Position = 5387 };
                TabStop tabStop48 = new TabStop() { Val = TabStopValues.Left, Position = 6379 };
                TabStop tabStop49 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

                tabs13.Append(tabStop45);
                tabs13.Append(tabStop46);
                tabs13.Append(tabStop47);
                tabs13.Append(tabStop48);
                tabs13.Append(tabStop49);
                SpacingBetweenLines spacingBetweenLines27 = new SpacingBetweenLines() { Before = "60", After = "60" };

                ParagraphMarkRunProperties paragraphMarkRunProperties33 = new ParagraphMarkRunProperties();
                RunFonts runFonts61 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
                FontSize fontSize47 = new FontSize() { Val = "18" };

                paragraphMarkRunProperties33.Append(runFonts61);
                paragraphMarkRunProperties33.Append(fontSize47);

                paragraphProperties33.Append(tabs13);
                paragraphProperties33.Append(spacingBetweenLines27);
                paragraphProperties33.Append(paragraphMarkRunProperties33);

                Run run29 = new Run() { RsidRunProperties = "00443ACA" };

                RunProperties runProperties29 = new RunProperties();
                RunFonts runFonts62 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
                FontSize fontSize48 = new FontSize() { Val = "18" };

                runProperties29.Append(runFonts62);
                runProperties29.Append(fontSize48);
                Text text28 = new Text();

                //TODO Book title
                text28.Text = o.title;

                run29.Append(runProperties29);
                run29.Append(text28);

                paragraph33.Append(paragraphProperties33);
                paragraph33.Append(run29);

                tableCell14.Append(tableCellProperties14);
                tableCell14.Append(paragraph32);
                tableCell14.Append(paragraph33);

                //Cell for quantity
                TableCell tableCell15 = new TableCell();

                TableCellProperties tableCellProperties15 = new TableCellProperties();
                TableCellWidth tableCellWidth15 = new TableCellWidth() { Width = "1036", Type = TableWidthUnitValues.Dxa };

                tableCellProperties15.Append(tableCellWidth15);

                Paragraph paragraph34 = new Paragraph() { RsidParagraphMarkRevision = "00443ACA", RsidParagraphAddition = "00443ACA", RsidParagraphProperties = "00443ACA", RsidRunAdditionDefault = "00443ACA" };

                ParagraphProperties paragraphProperties34 = new ParagraphProperties();

                Tabs tabs14 = new Tabs();
                TabStop tabStop50 = new TabStop() { Val = TabStopValues.Left, Position = 1560 };
                TabStop tabStop51 = new TabStop() { Val = TabStopValues.Left, Position = 3969 };
                TabStop tabStop52 = new TabStop() { Val = TabStopValues.Left, Position = 5387 };
                TabStop tabStop53 = new TabStop() { Val = TabStopValues.Left, Position = 6379 };
                TabStop tabStop54 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

                tabs14.Append(tabStop50);
                tabs14.Append(tabStop51);
                tabs14.Append(tabStop52);
                tabs14.Append(tabStop53);
                tabs14.Append(tabStop54);
                SpacingBetweenLines spacingBetweenLines28 = new SpacingBetweenLines() { Before = "60", After = "60" };
                Justification justification13 = new Justification() { Val = JustificationValues.Right };

                ParagraphMarkRunProperties paragraphMarkRunProperties34 = new ParagraphMarkRunProperties();
                RunFonts runFonts63 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
                FontSize fontSize49 = new FontSize() { Val = "18" };

                paragraphMarkRunProperties34.Append(runFonts63);
                paragraphMarkRunProperties34.Append(fontSize49);

                paragraphProperties34.Append(tabs14);
                paragraphProperties34.Append(spacingBetweenLines28);
                paragraphProperties34.Append(justification13);
                paragraphProperties34.Append(paragraphMarkRunProperties34);

                Run run30 = new Run() { RsidRunProperties = "00443ACA" };

                RunProperties runProperties30 = new RunProperties();
                RunFonts runFonts64 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
                FontSize fontSize50 = new FontSize() { Val = "18" };

                runProperties30.Append(runFonts64);
                runProperties30.Append(fontSize50);
                Text text29 = new Text();

                //TODO Quantity
                text29.Text = o.quantity.ToString();

                run30.Append(runProperties30);
                run30.Append(text29);

                paragraph34.Append(paragraphProperties34);
                paragraph34.Append(run30);

                tableCell15.Append(tableCellProperties15);
                tableCell15.Append(paragraph34);

                //Cell for price
                TableCell tableCell16 = new TableCell();

                TableCellProperties tableCellProperties16 = new TableCellProperties();
                TableCellWidth tableCellWidth16 = new TableCellWidth() { Width = "1364", Type = TableWidthUnitValues.Dxa };

                tableCellProperties16.Append(tableCellWidth16);

                Paragraph paragraph35 = new Paragraph() { RsidParagraphMarkRevision = "00443ACA", RsidParagraphAddition = "00443ACA", RsidParagraphProperties = "00443ACA", RsidRunAdditionDefault = "00443ACA" };

                ParagraphProperties paragraphProperties35 = new ParagraphProperties();

                Tabs tabs15 = new Tabs();
                TabStop tabStop55 = new TabStop() { Val = TabStopValues.Left, Position = 1560 };
                TabStop tabStop56 = new TabStop() { Val = TabStopValues.Left, Position = 3969 };
                TabStop tabStop57 = new TabStop() { Val = TabStopValues.Left, Position = 5387 };
                TabStop tabStop58 = new TabStop() { Val = TabStopValues.Left, Position = 6379 };
                TabStop tabStop59 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

                tabs15.Append(tabStop55);
                tabs15.Append(tabStop56);
                tabs15.Append(tabStop57);
                tabs15.Append(tabStop58);
                tabs15.Append(tabStop59);
                SpacingBetweenLines spacingBetweenLines29 = new SpacingBetweenLines() { Before = "60", After = "60" };
                Justification justification14 = new Justification() { Val = JustificationValues.Right };

                ParagraphMarkRunProperties paragraphMarkRunProperties35 = new ParagraphMarkRunProperties();
                RunFonts runFonts65 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
                FontSize fontSize51 = new FontSize() { Val = "18" };

                paragraphMarkRunProperties35.Append(runFonts65);
                paragraphMarkRunProperties35.Append(fontSize51);

                paragraphProperties35.Append(tabs15);
                paragraphProperties35.Append(spacingBetweenLines29);
                paragraphProperties35.Append(justification14);
                paragraphProperties35.Append(paragraphMarkRunProperties35);

                Run run31 = new Run() { RsidRunProperties = "00443ACA" };

                RunProperties runProperties31 = new RunProperties();
                RunFonts runFonts66 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
                FontSize fontSize52 = new FontSize() { Val = "18" };

                runProperties31.Append(runFonts66);
                runProperties31.Append(fontSize52);
                Text text30 = new Text();

                //TODO Price
                text30.Text = "$" + String.Format("{0:0.00}", o.price);

                run31.Append(runProperties31);
                run31.Append(text30);

                paragraph35.Append(paragraphProperties35);
                paragraph35.Append(run31);

                tableCell16.Append(tableCellProperties16);
                tableCell16.Append(paragraph35);

                //Cell for discount
                TableCell tableCell17 = new TableCell();

                TableCellProperties tableCellProperties17 = new TableCellProperties();
                TableCellWidth tableCellWidth17 = new TableCellWidth() { Width = "1411", Type = TableWidthUnitValues.Dxa };

                tableCellProperties17.Append(tableCellWidth17);

                Paragraph paragraph36 = new Paragraph() { RsidParagraphMarkRevision = "00443ACA", RsidParagraphAddition = "00443ACA", RsidParagraphProperties = "00443ACA", RsidRunAdditionDefault = "00443ACA" };

                ParagraphProperties paragraphProperties36 = new ParagraphProperties();

                Tabs tabs16 = new Tabs();
                TabStop tabStop60 = new TabStop() { Val = TabStopValues.Left, Position = 1560 };
                TabStop tabStop61 = new TabStop() { Val = TabStopValues.Left, Position = 3969 };
                TabStop tabStop62 = new TabStop() { Val = TabStopValues.Left, Position = 5387 };
                TabStop tabStop63 = new TabStop() { Val = TabStopValues.Left, Position = 6379 };
                TabStop tabStop64 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

                tabs16.Append(tabStop60);
                tabs16.Append(tabStop61);
                tabs16.Append(tabStop62);
                tabs16.Append(tabStop63);
                tabs16.Append(tabStop64);
                SpacingBetweenLines spacingBetweenLines30 = new SpacingBetweenLines() { Before = "60", After = "60" };
                Justification justification15 = new Justification() { Val = JustificationValues.Right };

                ParagraphMarkRunProperties paragraphMarkRunProperties36 = new ParagraphMarkRunProperties();
                RunFonts runFonts67 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
                FontSize fontSize53 = new FontSize() { Val = "18" };

                paragraphMarkRunProperties36.Append(runFonts67);
                paragraphMarkRunProperties36.Append(fontSize53);

                paragraphProperties36.Append(tabs16);
                paragraphProperties36.Append(spacingBetweenLines30);
                paragraphProperties36.Append(justification15);
                paragraphProperties36.Append(paragraphMarkRunProperties36);

                Run run32 = new Run() { RsidRunProperties = "00443ACA" };

                RunProperties runProperties32 = new RunProperties();
                RunFonts runFonts68 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
                FontSize fontSize54 = new FontSize() { Val = "18" };

                runProperties32.Append(runFonts68);
                runProperties32.Append(fontSize54);
                Text text31 = new Text();

                //TODO Discount
                text31.Text = "$" + String.Format("{0:0.00}", o.discount);

                run32.Append(runProperties32);
                run32.Append(text31);

                paragraph36.Append(paragraphProperties36);
                paragraph36.Append(run32);

                tableCell17.Append(tableCellProperties17);
                tableCell17.Append(paragraph36);

                //Cell for total
                TableCell tableCell18 = new TableCell();

                TableCellProperties tableCellProperties18 = new TableCellProperties();
                TableCellWidth tableCellWidth18 = new TableCellWidth() { Width = "1078", Type = TableWidthUnitValues.Dxa };

                tableCellProperties18.Append(tableCellWidth18);

                Paragraph paragraph37 = new Paragraph() { RsidParagraphMarkRevision = "00443ACA", RsidParagraphAddition = "00443ACA", RsidParagraphProperties = "00443ACA", RsidRunAdditionDefault = "00443ACA" };

                ParagraphProperties paragraphProperties37 = new ParagraphProperties();

                Tabs tabs17 = new Tabs();
                TabStop tabStop65 = new TabStop() { Val = TabStopValues.Left, Position = 1560 };
                TabStop tabStop66 = new TabStop() { Val = TabStopValues.Left, Position = 3969 };
                TabStop tabStop67 = new TabStop() { Val = TabStopValues.Left, Position = 5387 };
                TabStop tabStop68 = new TabStop() { Val = TabStopValues.Left, Position = 6379 };
                TabStop tabStop69 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

                tabs17.Append(tabStop65);
                tabs17.Append(tabStop66);
                tabs17.Append(tabStop67);
                tabs17.Append(tabStop68);
                tabs17.Append(tabStop69);
                SpacingBetweenLines spacingBetweenLines31 = new SpacingBetweenLines() { Before = "60", After = "60" };
                Justification justification16 = new Justification() { Val = JustificationValues.Right };

                ParagraphMarkRunProperties paragraphMarkRunProperties37 = new ParagraphMarkRunProperties();
                RunFonts runFonts69 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
                FontSize fontSize55 = new FontSize() { Val = "18" };

                paragraphMarkRunProperties37.Append(runFonts69);
                paragraphMarkRunProperties37.Append(fontSize55);

                paragraphProperties37.Append(tabs17);
                paragraphProperties37.Append(spacingBetweenLines31);
                paragraphProperties37.Append(justification16);
                paragraphProperties37.Append(paragraphMarkRunProperties37);

                Run run33 = new Run() { RsidRunProperties = "00443ACA" };

                RunProperties runProperties33 = new RunProperties();
                RunFonts runFonts70 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
                FontSize fontSize56 = new FontSize() { Val = "18" };

                runProperties33.Append(runFonts70);
                runProperties33.Append(fontSize56);
                Text text32 = new Text();

                //Total
                double total = o.price - o.discount;

                grandTotal += total;

                //TODO have price display as decimal
                text32.Text = "$" + String.Format("{0:0.00}", total);

                run33.Append(runProperties33);
                run33.Append(text32);

                paragraph37.Append(paragraphProperties37);
                paragraph37.Append(run33);

                tableCell18.Append(tableCellProperties18);
                tableCell18.Append(paragraph37);

                //Add cells into the row
                orderedStockRow.Append(cellBookID);
                orderedStockRow.Append(tableCell14);
                orderedStockRow.Append(tableCell15);
                orderedStockRow.Append(tableCell16);
                orderedStockRow.Append(tableCell17);
                orderedStockRow.Append(tableCell18);

                //Add row for book into the table
                table2.Append(orderedStockRow);
            }
            /***************** End loop *******************/

            Paragraph paragraph38 = new Paragraph() { RsidParagraphAddition = "00B5104A", RsidParagraphProperties = "00116604", RsidRunAdditionDefault = "00B5104A" };

            ParagraphProperties paragraphProperties38 = new ParagraphProperties();

            Tabs tabs18 = new Tabs();
            TabStop tabStop70 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

            tabs18.Append(tabStop70);
            SpacingBetweenLines spacingBetweenLines32 = new SpacingBetweenLines() { Before = "40", After = "40" };

            ParagraphMarkRunProperties paragraphMarkRunProperties38 = new ParagraphMarkRunProperties();
            RunFonts runFonts71 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            Bold bold5 = new Bold();
            FontSize fontSize57 = new FontSize() { Val = "18" };

            paragraphMarkRunProperties38.Append(runFonts71);
            paragraphMarkRunProperties38.Append(bold5);
            paragraphMarkRunProperties38.Append(fontSize57);

            paragraphProperties38.Append(tabs18);
            paragraphProperties38.Append(spacingBetweenLines32);
            paragraphProperties38.Append(paragraphMarkRunProperties38);

            paragraph38.Append(paragraphProperties38);

            Table table3 = new Table();

            TableProperties tableProperties3 = new TableProperties();
            TableStyle tableStyle3 = new TableStyle() { Val = "TableGrid" };
            TableWidth tableWidth3 = new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto };
            TableIndentation tableIndentation1 = new TableIndentation() { Width = 6516, Type = TableWidthUnitValues.Dxa };

            TableBorders tableBorders3 = new TableBorders();
            TopBorder topBorder2 = new TopBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U };
            LeftBorder leftBorder3 = new LeftBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U };
            BottomBorder bottomBorder2 = new BottomBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U };
            RightBorder rightBorder3 = new RightBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U };
            InsideHorizontalBorder insideHorizontalBorder2 = new InsideHorizontalBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U };
            InsideVerticalBorder insideVerticalBorder3 = new InsideVerticalBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U };

            tableBorders3.Append(topBorder2);
            tableBorders3.Append(leftBorder3);
            tableBorders3.Append(bottomBorder2);
            tableBorders3.Append(rightBorder3);
            tableBorders3.Append(insideHorizontalBorder2);
            tableBorders3.Append(insideVerticalBorder3);
            TableLook tableLook3 = new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true };

            tableProperties3.Append(tableStyle3);
            tableProperties3.Append(tableWidth3);
            tableProperties3.Append(tableIndentation1);
            tableProperties3.Append(tableBorders3);
            tableProperties3.Append(tableLook3);

            TableGrid tableGrid3 = new TableGrid();
            GridColumn gridColumn10 = new GridColumn() { Width = "1559" };
            GridColumn gridColumn11 = new GridColumn() { Width = "941" };

            tableGrid3.Append(gridColumn10);
            tableGrid3.Append(gridColumn11);

            TableRow tableRow6 = new TableRow() { RsidTableRowAddition = "00B5104A", RsidTableRowProperties = "00BD60A1" };

            TableCell tableCell19 = new TableCell();

            TableCellProperties tableCellProperties19 = new TableCellProperties();
            TableCellWidth tableCellWidth19 = new TableCellWidth() { Width = "1559", Type = TableWidthUnitValues.Dxa };

            tableCellProperties19.Append(tableCellWidth19);

            Paragraph paragraph39 = new Paragraph() { RsidParagraphAddition = "00B5104A", RsidParagraphProperties = "00116604", RsidRunAdditionDefault = "00B5104A" };

            ParagraphProperties paragraphProperties39 = new ParagraphProperties();

            Tabs tabs19 = new Tabs();
            TabStop tabStop71 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

            tabs19.Append(tabStop71);
            SpacingBetweenLines spacingBetweenLines33 = new SpacingBetweenLines() { Before = "40", After = "40" };

            ParagraphMarkRunProperties paragraphMarkRunProperties39 = new ParagraphMarkRunProperties();
            RunFonts runFonts72 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            Bold bold6 = new Bold();
            FontSize fontSize58 = new FontSize() { Val = "20" };

            paragraphMarkRunProperties39.Append(runFonts72);
            paragraphMarkRunProperties39.Append(bold6);
            paragraphMarkRunProperties39.Append(fontSize58);

            paragraphProperties39.Append(tabs19);
            paragraphProperties39.Append(spacingBetweenLines33);
            paragraphProperties39.Append(paragraphMarkRunProperties39);

            Run run34 = new Run();

            RunProperties runProperties34 = new RunProperties();
            RunFonts runFonts73 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize59 = new FontSize() { Val = "20" };

            runProperties34.Append(runFonts73);
            runProperties34.Append(fontSize59);
            Text text33 = new Text();
            text33.Text = "Total:";

            run34.Append(runProperties34);
            run34.Append(text33);

            paragraph39.Append(paragraphProperties39);
            paragraph39.Append(run34);

            tableCell19.Append(tableCellProperties19);
            tableCell19.Append(paragraph39);

            TableCell tableCell20 = new TableCell();

            TableCellProperties tableCellProperties20 = new TableCellProperties();
            TableCellWidth tableCellWidth20 = new TableCellWidth() { Width = "941", Type = TableWidthUnitValues.Dxa };

            tableCellProperties20.Append(tableCellWidth20);

            Paragraph paragraph40 = new Paragraph() { RsidParagraphAddition = "00B5104A", RsidParagraphProperties = "00B5104A", RsidRunAdditionDefault = "00B5104A" };

            ParagraphProperties paragraphProperties40 = new ParagraphProperties();

            Tabs tabs20 = new Tabs();
            TabStop tabStop72 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

            tabs20.Append(tabStop72);
            SpacingBetweenLines spacingBetweenLines34 = new SpacingBetweenLines() { Before = "40", After = "40" };
            Justification justification17 = new Justification() { Val = JustificationValues.Right };

            ParagraphMarkRunProperties paragraphMarkRunProperties40 = new ParagraphMarkRunProperties();
            RunFonts runFonts74 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            Bold bold7 = new Bold();
            FontSize fontSize60 = new FontSize() { Val = "20" };

            paragraphMarkRunProperties40.Append(runFonts74);
            paragraphMarkRunProperties40.Append(bold7);
            paragraphMarkRunProperties40.Append(fontSize60);

            paragraphProperties40.Append(tabs20);
            paragraphProperties40.Append(spacingBetweenLines34);
            paragraphProperties40.Append(justification17);
            paragraphProperties40.Append(paragraphMarkRunProperties40);

            Run run35 = new Run();

            RunProperties runProperties35 = new RunProperties();
            RunFonts runFonts75 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize61 = new FontSize() { Val = "20" };

            runProperties35.Append(runFonts75);
            runProperties35.Append(fontSize61);
            Text text34 = new Text();

            //TODO total after the table
            text34.Text = "$" + String.Format("{0:0.00}", grandTotal);

            run35.Append(runProperties35);
            run35.Append(text34);

            paragraph40.Append(paragraphProperties40);
            paragraph40.Append(run35);

            tableCell20.Append(tableCellProperties20);
            tableCell20.Append(paragraph40);

            tableRow6.Append(tableCell19);
            tableRow6.Append(tableCell20);

            TableRow tableRow7 = new TableRow() { RsidTableRowAddition = "00B5104A", RsidTableRowProperties = "00BD60A1" };

            TableCell tableCell21 = new TableCell();

            TableCellProperties tableCellProperties21 = new TableCellProperties();
            TableCellWidth tableCellWidth21 = new TableCellWidth() { Width = "1559", Type = TableWidthUnitValues.Dxa };

            tableCellProperties21.Append(tableCellWidth21);

            Paragraph paragraph41 = new Paragraph() { RsidParagraphAddition = "00B5104A", RsidParagraphProperties = "00116604", RsidRunAdditionDefault = "00B5104A" };

            ParagraphProperties paragraphProperties41 = new ParagraphProperties();

            Tabs tabs21 = new Tabs();
            TabStop tabStop73 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

            tabs21.Append(tabStop73);
            SpacingBetweenLines spacingBetweenLines35 = new SpacingBetweenLines() { Before = "40", After = "40" };

            ParagraphMarkRunProperties paragraphMarkRunProperties41 = new ParagraphMarkRunProperties();
            RunFonts runFonts76 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize62 = new FontSize() { Val = "20" };

            paragraphMarkRunProperties41.Append(runFonts76);
            paragraphMarkRunProperties41.Append(fontSize62);

            paragraphProperties41.Append(tabs21);
            paragraphProperties41.Append(spacingBetweenLines35);
            paragraphProperties41.Append(paragraphMarkRunProperties41);

            Run run36 = new Run();

            RunProperties runProperties36 = new RunProperties();
            RunFonts runFonts77 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize63 = new FontSize() { Val = "20" };

            runProperties36.Append(runFonts77);
            runProperties36.Append(fontSize63);
            Text text35 = new Text();
            text35.Text = "Freight:";

            run36.Append(runProperties36);
            run36.Append(text35);

            paragraph41.Append(paragraphProperties41);
            paragraph41.Append(run36);

            tableCell21.Append(tableCellProperties21);
            tableCell21.Append(paragraph41);

            TableCell tableCell22 = new TableCell();

            TableCellProperties tableCellProperties22 = new TableCellProperties();
            TableCellWidth tableCellWidth22 = new TableCellWidth() { Width = "941", Type = TableWidthUnitValues.Dxa };

            tableCellProperties22.Append(tableCellWidth22);

            Paragraph paragraph42 = new Paragraph() { RsidParagraphAddition = "00B5104A", RsidParagraphProperties = "00B5104A", RsidRunAdditionDefault = "00B5104A" };

            ParagraphProperties paragraphProperties42 = new ParagraphProperties();

            Tabs tabs22 = new Tabs();
            TabStop tabStop74 = new TabStop() { Val = TabStopValues.Left, Position = 6663 };
            TabStop tabStop75 = new TabStop() { Val = TabStopValues.Left, Position = 8364 };

            tabs22.Append(tabStop74);
            tabs22.Append(tabStop75);
            SpacingBetweenLines spacingBetweenLines36 = new SpacingBetweenLines() { Before = "40", After = "40" };
            Justification justification18 = new Justification() { Val = JustificationValues.Right };

            ParagraphMarkRunProperties paragraphMarkRunProperties42 = new ParagraphMarkRunProperties();
            RunFonts runFonts78 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize64 = new FontSize() { Val = "20" };

            paragraphMarkRunProperties42.Append(runFonts78);
            paragraphMarkRunProperties42.Append(fontSize64);

            paragraphProperties42.Append(tabs22);
            paragraphProperties42.Append(spacingBetweenLines36);
            paragraphProperties42.Append(justification18);
            paragraphProperties42.Append(paragraphMarkRunProperties42);

            Run run37 = new Run();

            RunProperties runProperties37 = new RunProperties();
            RunFonts runFonts79 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize65 = new FontSize() { Val = "20" };

            runProperties37.Append(runFonts79);
            runProperties37.Append(fontSize65);
            Text text36 = new Text();

            //TODO freight price
            text36.Text = "$" + String.Format("{0:0.00}", order.freightCost);

            run37.Append(runProperties37);
            run37.Append(text36);

            paragraph42.Append(paragraphProperties42);
            paragraph42.Append(run37);

            tableCell22.Append(tableCellProperties22);
            tableCell22.Append(paragraph42);

            tableRow7.Append(tableCell21);
            tableRow7.Append(tableCell22);

            TableRow tableRow8 = new TableRow() { RsidTableRowAddition = "00B5104A", RsidTableRowProperties = "00BD60A1" };

            TableCell tableCell23 = new TableCell();

            TableCellProperties tableCellProperties23 = new TableCellProperties();
            TableCellWidth tableCellWidth23 = new TableCellWidth() { Width = "1559", Type = TableWidthUnitValues.Dxa };

            tableCellProperties23.Append(tableCellWidth23);

            Paragraph paragraph43 = new Paragraph() { RsidParagraphAddition = "00B5104A", RsidParagraphProperties = "00116604", RsidRunAdditionDefault = "00B5104A" };

            ParagraphProperties paragraphProperties43 = new ParagraphProperties();

            Tabs tabs23 = new Tabs();
            TabStop tabStop76 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

            tabs23.Append(tabStop76);
            SpacingBetweenLines spacingBetweenLines37 = new SpacingBetweenLines() { Before = "40", After = "40" };

            ParagraphMarkRunProperties paragraphMarkRunProperties43 = new ParagraphMarkRunProperties();
            RunFonts runFonts80 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize66 = new FontSize() { Val = "20" };

            paragraphMarkRunProperties43.Append(runFonts80);
            paragraphMarkRunProperties43.Append(fontSize66);

            paragraphProperties43.Append(tabs23);
            paragraphProperties43.Append(spacingBetweenLines37);
            paragraphProperties43.Append(paragraphMarkRunProperties43);

            Run run38 = new Run() { RsidRunProperties = "00690638" };

            RunProperties runProperties38 = new RunProperties();
            RunFonts runFonts81 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            Bold bold8 = new Bold();
            FontSize fontSize67 = new FontSize() { Val = "20" };

            runProperties38.Append(runFonts81);
            runProperties38.Append(bold8);
            runProperties38.Append(fontSize67);
            Text text37 = new Text();
            text37.Text = "Final Total";

            run38.Append(runProperties38);
            run38.Append(text37);

            Run run39 = new Run();

            RunProperties runProperties39 = new RunProperties();
            RunFonts runFonts82 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            Bold bold9 = new Bold();
            FontSize fontSize68 = new FontSize() { Val = "20" };

            runProperties39.Append(runFonts82);
            runProperties39.Append(bold9);
            runProperties39.Append(fontSize68);
            Text text38 = new Text();
            text38.Text = ":";

            run39.Append(runProperties39);
            run39.Append(text38);

            paragraph43.Append(paragraphProperties43);
            paragraph43.Append(run38);
            paragraph43.Append(run39);

            tableCell23.Append(tableCellProperties23);
            tableCell23.Append(paragraph43);

            TableCell tableCell24 = new TableCell();

            TableCellProperties tableCellProperties24 = new TableCellProperties();
            TableCellWidth tableCellWidth24 = new TableCellWidth() { Width = "941", Type = TableWidthUnitValues.Dxa };

            tableCellProperties24.Append(tableCellWidth24);

            Paragraph paragraph44 = new Paragraph() { RsidParagraphAddition = "00B5104A", RsidParagraphProperties = "00B5104A", RsidRunAdditionDefault = "00B5104A" };

            ParagraphProperties paragraphProperties44 = new ParagraphProperties();

            Tabs tabs24 = new Tabs();
            TabStop tabStop77 = new TabStop() { Val = TabStopValues.Left, Position = 6663 };
            TabStop tabStop78 = new TabStop() { Val = TabStopValues.Left, Position = 8364 };

            tabs24.Append(tabStop77);
            tabs24.Append(tabStop78);
            SpacingBetweenLines spacingBetweenLines38 = new SpacingBetweenLines() { Before = "40", After = "40" };
            Justification justification19 = new Justification() { Val = JustificationValues.Right };

            ParagraphMarkRunProperties paragraphMarkRunProperties44 = new ParagraphMarkRunProperties();
            RunFonts runFonts83 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            FontSize fontSize69 = new FontSize() { Val = "20" };

            paragraphMarkRunProperties44.Append(runFonts83);
            paragraphMarkRunProperties44.Append(fontSize69);

            paragraphProperties44.Append(tabs24);
            paragraphProperties44.Append(spacingBetweenLines38);
            paragraphProperties44.Append(justification19);
            paragraphProperties44.Append(paragraphMarkRunProperties44);

            Run run40 = new Run() { RsidRunProperties = "00690638" };

            RunProperties runProperties40 = new RunProperties();
            RunFonts runFonts84 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            Bold bold10 = new Bold();
            FontSize fontSize70 = new FontSize() { Val = "20" };

            runProperties40.Append(runFonts84);
            runProperties40.Append(bold10);
            runProperties40.Append(fontSize70);
            Text text39 = new Text();

            //TODO add in total + freightCost
            double finalTotal = grandTotal + order.freightCost;

            text39.Text = "$" + String.Format("{0:0.00}", finalTotal);

            run40.Append(runProperties40);
            run40.Append(text39);

            paragraph44.Append(paragraphProperties44);
            paragraph44.Append(run40);

            tableCell24.Append(tableCellProperties24);
            tableCell24.Append(paragraph44);

            tableRow8.Append(tableCell23);
            tableRow8.Append(tableCell24);

            TableRow tableRow9 = new TableRow() { RsidTableRowAddition = "00B5104A", RsidTableRowProperties = "00BD60A1" };

            TableCell tableCell25 = new TableCell();

            TableCellProperties tableCellProperties25 = new TableCellProperties();
            TableCellWidth tableCellWidth25 = new TableCellWidth() { Width = "2500", Type = TableWidthUnitValues.Dxa };
            GridSpan gridSpan4 = new GridSpan() { Val = 2 };

            tableCellProperties25.Append(tableCellWidth25);
            tableCellProperties25.Append(gridSpan4);

            Paragraph paragraph45 = new Paragraph() { RsidParagraphMarkRevision = "00690638", RsidParagraphAddition = "00B5104A", RsidParagraphProperties = "00B5104A", RsidRunAdditionDefault = "00B5104A" };

            ParagraphProperties paragraphProperties45 = new ParagraphProperties();

            Tabs tabs25 = new Tabs();
            TabStop tabStop79 = new TabStop() { Val = TabStopValues.Left, Position = 6663 };
            TabStop tabStop80 = new TabStop() { Val = TabStopValues.Left, Position = 8364 };

            tabs25.Append(tabStop79);
            tabs25.Append(tabStop80);
            SpacingBetweenLines spacingBetweenLines39 = new SpacingBetweenLines() { Before = "40", After = "40" };
            Justification justification20 = new Justification() { Val = JustificationValues.Right };

            ParagraphMarkRunProperties paragraphMarkRunProperties45 = new ParagraphMarkRunProperties();
            RunFonts runFonts85 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            Bold bold11 = new Bold();
            FontSize fontSize71 = new FontSize() { Val = "20" };

            paragraphMarkRunProperties45.Append(runFonts85);
            paragraphMarkRunProperties45.Append(bold11);
            paragraphMarkRunProperties45.Append(fontSize71);

            paragraphProperties45.Append(tabs25);
            paragraphProperties45.Append(spacingBetweenLines39);
            paragraphProperties45.Append(justification20);
            paragraphProperties45.Append(paragraphMarkRunProperties45);

            Run run41 = new Run() { RsidRunProperties = "00882792" };

            RunProperties runProperties41 = new RunProperties();
            RunFonts runFonts86 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            Bold bold12 = new Bold();
            FontSize fontSize72 = new FontSize() { Val = "18" };

            runProperties41.Append(runFonts86);
            runProperties41.Append(bold12);
            runProperties41.Append(fontSize72);
            Text text40 = new Text();
            text40.Text = "Paid in Full";

            run41.Append(runProperties41);
            run41.Append(text40);

            paragraph45.Append(paragraphProperties45);
            paragraph45.Append(run41);

            tableCell25.Append(tableCellProperties25);
            tableCell25.Append(paragraph45);

            tableRow9.Append(tableCell25);

            table3.Append(tableProperties3);
            table3.Append(tableGrid3);
            table3.Append(tableRow6);
            table3.Append(tableRow7);
            table3.Append(tableRow8);
            table3.Append(tableRow9);

            Paragraph paragraph46 = new Paragraph() { RsidParagraphMarkRevision = "00690638", RsidParagraphAddition = "00B5104A", RsidParagraphProperties = "00116604", RsidRunAdditionDefault = "00B5104A" };

            ParagraphProperties paragraphProperties46 = new ParagraphProperties();

            Tabs tabs26 = new Tabs();
            TabStop tabStop81 = new TabStop() { Val = TabStopValues.Left, Position = 7938 };

            tabs26.Append(tabStop81);
            SpacingBetweenLines spacingBetweenLines40 = new SpacingBetweenLines() { Before = "40", After = "40" };

            ParagraphMarkRunProperties paragraphMarkRunProperties46 = new ParagraphMarkRunProperties();
            RunFonts runFonts87 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" };
            Bold bold13 = new Bold();
            FontSize fontSize73 = new FontSize() { Val = "20" };

            paragraphMarkRunProperties46.Append(runFonts87);
            paragraphMarkRunProperties46.Append(bold13);
            paragraphMarkRunProperties46.Append(fontSize73);

            paragraphProperties46.Append(tabs26);
            paragraphProperties46.Append(spacingBetweenLines40);
            paragraphProperties46.Append(paragraphMarkRunProperties46);

            paragraph46.Append(paragraphProperties46);

            SectionProperties sectionProperties3 = new SectionProperties() { RsidRPr = "00690638", RsidR = "00B5104A", RsidSect = "00EA7D1E" };
            SectionType sectionType2 = new SectionType() { Val = SectionMarkValues.Continuous };
            PageSize pageSize3 = new PageSize() { Width = (UInt32Value)11906U, Height = (UInt32Value)16838U };
            PageMargin pageMargin3 = new PageMargin() { Top = 1440, Right = (UInt32Value)1440U, Bottom = 1440, Left = (UInt32Value)1440U, Header = (UInt32Value)708U, Footer = (UInt32Value)708U, Gutter = (UInt32Value)0U };
            Columns columns3 = new Columns() { Space = "286" };
            DocGrid docGrid3 = new DocGrid() { LinePitch = 360 };

            sectionProperties3.Append(sectionType2);
            sectionProperties3.Append(pageSize3);
            sectionProperties3.Append(pageMargin3);
            sectionProperties3.Append(columns3);
            sectionProperties3.Append(docGrid3);

            body1.Append(paragraph1);
            body1.Append(paragraph2);
            body1.Append(paragraph3);
            body1.Append(paragraph4);
            body1.Append(paragraph5);
            body1.Append(paragraph6);
            body1.Append(paragraph7);
            body1.Append(paragraph8);

            if (customer != null)
            {
                if (customer.firstName != "" || customer.lastName != "")
                    body1.Append(paragraph9);
            }
            else
            {
                if(order.firstName != "" || order.lastName != "")
                    body1.Append(paragraph9);
            }

            if (customer.institution != "")
                body1.Append(paragraphInstitute);
            if(customer.address1 != "")
                body1.Append(paragraph10);
            if(customer.address2 != "")
                body1.Append(paragraph11);
            if(customer.address3 != "")
                body1.Append(paragraph12);
            if(customer.postCode != "")
                body1.Append(paragraph13);
            if(customer.country != "")
                body1.Append(paragraph14);
            body1.Append(paragraph15);
            body1.Append(table1);
            body1.Append(paragraph22);
            body1.Append(paragraph23);
            body1.Append(paragraph24);
            body1.Append(table2);
            body1.Append(paragraph38);
            body1.Append(table3);
            body1.Append(paragraph46);
            body1.Append(sectionProperties3);

            document1.Append(body1);

            mainDocumentPart1.Document = document1;
        }
 private static RunProperties CloneRunPropertiesIfNotNull(RunProperties runProperties)
 {
     return(runProperties == null ? null : runProperties.CloneElement());
 }
Example #59
0
        // Generates content of mainDocumentPart1.
        private void GenerateMainDocumentPart1Content(MainDocumentPart mainDocumentPart1)
        {
            Document document1 = new Document(){ MCAttributes = new MarkupCompatibilityAttributes(){ Ignorable = "w14 w15 wp14" }  };
            document1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
            document1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            document1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
            document1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            document1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
            document1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
            document1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
            document1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
            document1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
            document1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
            document1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml");
            document1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2010/11/wordml");
            document1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
            document1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
            document1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
            document1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");

            Body body1 = new Body();

            SdtBlock sdtBlock1 = new SdtBlock();

            SdtProperties sdtProperties1 = new SdtProperties();

            RunProperties runProperties1 = new RunProperties();
            RunFonts runFonts1 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties1.Append(runFonts1);
            SdtAlias sdtAlias1 = new SdtAlias(){ Val = "Test1.1.1" };
            Tag tag1 = new Tag(){ Val = "Test1.1.1" };
            SdtId sdtId1 = new SdtId(){ Val = -1832063964 };

            SdtPlaceholder sdtPlaceholder1 = new SdtPlaceholder();
            DocPartReference docPartReference1 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868558" };

            sdtPlaceholder1.Append(docPartReference1);
            ShowingPlaceholder showingPlaceholder1 = new ShowingPlaceholder();
            SdtContentText sdtContentText1 = new SdtContentText();

            sdtProperties1.Append(runProperties1);
            sdtProperties1.Append(sdtAlias1);
            sdtProperties1.Append(tag1);
            sdtProperties1.Append(sdtId1);
            sdtProperties1.Append(sdtPlaceholder1);
            sdtProperties1.Append(showingPlaceholder1);
            sdtProperties1.Append(sdtContentText1);
            SdtEndCharProperties sdtEndCharProperties1 = new SdtEndCharProperties();

            SdtContentBlock sdtContentBlock1 = new SdtContentBlock();

            Paragraph paragraph1 = new Paragraph(){ RsidParagraphAddition = "00535C5E", RsidRunAdditionDefault = "000010BA" };

            Run run1 = new Run(){ RsidRunProperties = "003E0DED" };

            RunProperties runProperties2 = new RunProperties();
            RunStyle runStyle1 = new RunStyle(){ Val = "PlaceholderText" };

            runProperties2.Append(runStyle1);
            Text text1 = new Text();
            text1.Text = "Click here to enter text.";

            run1.Append(runProperties2);
            run1.Append(text1);

            paragraph1.Append(run1);

            sdtContentBlock1.Append(paragraph1);

            sdtBlock1.Append(sdtProperties1);
            sdtBlock1.Append(sdtEndCharProperties1);
            sdtBlock1.Append(sdtContentBlock1);

            SdtBlock sdtBlock2 = new SdtBlock();

            SdtProperties sdtProperties2 = new SdtProperties();

            RunProperties runProperties3 = new RunProperties();
            RunFonts runFonts2 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties3.Append(runFonts2);
            SdtAlias sdtAlias2 = new SdtAlias(){ Val = "Test1.1.2" };
            Tag tag2 = new Tag(){ Val = "Test1.1.2" };
            SdtId sdtId2 = new SdtId(){ Val = -2043657734 };

            SdtPlaceholder sdtPlaceholder2 = new SdtPlaceholder();
            DocPartReference docPartReference2 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868558" };

            sdtPlaceholder2.Append(docPartReference2);
            SdtContentText sdtContentText2 = new SdtContentText();

            sdtProperties2.Append(runProperties3);
            sdtProperties2.Append(sdtAlias2);
            sdtProperties2.Append(tag2);
            sdtProperties2.Append(sdtId2);
            sdtProperties2.Append(sdtPlaceholder2);
            sdtProperties2.Append(sdtContentText2);
            SdtEndCharProperties sdtEndCharProperties2 = new SdtEndCharProperties();

            SdtContentBlock sdtContentBlock2 = new SdtContentBlock();

            Paragraph paragraph2 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" };

            Run run2 = new Run();

            RunProperties runProperties4 = new RunProperties();
            RunFonts runFonts3 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties4.Append(runFonts3);
            Text text2 = new Text();
            text2.Text = "Test string";

            run2.Append(runProperties4);
            run2.Append(text2);

            paragraph2.Append(run2);

            sdtContentBlock2.Append(paragraph2);

            sdtBlock2.Append(sdtProperties2);
            sdtBlock2.Append(sdtEndCharProperties2);
            sdtBlock2.Append(sdtContentBlock2);

            SdtBlock sdtBlock3 = new SdtBlock();

            SdtProperties sdtProperties3 = new SdtProperties();

            RunProperties runProperties5 = new RunProperties();
            RunFonts runFonts4 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties5.Append(runFonts4);
            SdtAlias sdtAlias3 = new SdtAlias(){ Val = "Test1.2.1" };
            Tag tag3 = new Tag(){ Val = "Test1.2.1" };
            SdtId sdtId3 = new SdtId(){ Val = 401180698 };

            SdtPlaceholder sdtPlaceholder3 = new SdtPlaceholder();
            DocPartReference docPartReference3 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868558" };

            sdtPlaceholder3.Append(docPartReference3);
            SdtContentText sdtContentText3 = new SdtContentText();

            sdtProperties3.Append(runProperties5);
            sdtProperties3.Append(sdtAlias3);
            sdtProperties3.Append(tag3);
            sdtProperties3.Append(sdtId3);
            sdtProperties3.Append(sdtPlaceholder3);
            sdtProperties3.Append(sdtContentText3);
            SdtEndCharProperties sdtEndCharProperties3 = new SdtEndCharProperties();

            SdtContentBlock sdtContentBlock3 = new SdtContentBlock();

            Paragraph paragraph3 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" };

            Run run3 = new Run();

            RunProperties runProperties6 = new RunProperties();
            RunFonts runFonts5 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties6.Append(runFonts5);
            Text text3 = new Text();
            text3.Text = "Appearance1";

            run3.Append(runProperties6);
            run3.Append(text3);

            paragraph3.Append(run3);

            sdtContentBlock3.Append(paragraph3);

            sdtBlock3.Append(sdtProperties3);
            sdtBlock3.Append(sdtEndCharProperties3);
            sdtBlock3.Append(sdtContentBlock3);

            SdtBlock sdtBlock4 = new SdtBlock();

            SdtProperties sdtProperties4 = new SdtProperties();

            RunProperties runProperties7 = new RunProperties();
            RunFonts runFonts6 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties7.Append(runFonts6);
            SdtAlias sdtAlias4 = new SdtAlias(){ Val = "Test1.2.2" };
            Tag tag4 = new Tag(){ Val = "Test1.2.2" };
            SdtId sdtId4 = new SdtId(){ Val = 2096980748 };

            SdtPlaceholder sdtPlaceholder4 = new SdtPlaceholder();
            DocPartReference docPartReference4 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868558" };

            sdtPlaceholder4.Append(docPartReference4);
            W15.Appearance appearance1 = new W15.Appearance(){ Val = W15.SdtAppearance.Tags };
            SdtContentText sdtContentText4 = new SdtContentText();

            sdtProperties4.Append(runProperties7);
            sdtProperties4.Append(sdtAlias4);
            sdtProperties4.Append(tag4);
            sdtProperties4.Append(sdtId4);
            sdtProperties4.Append(sdtPlaceholder4);
            sdtProperties4.Append(appearance1);
            sdtProperties4.Append(sdtContentText4);
            SdtEndCharProperties sdtEndCharProperties4 = new SdtEndCharProperties();

            SdtContentBlock sdtContentBlock4 = new SdtContentBlock();

            Paragraph paragraph4 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" };

            Run run4 = new Run();

            RunProperties runProperties8 = new RunProperties();
            RunFonts runFonts7 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties8.Append(runFonts7);
            Text text4 = new Text();
            text4.Text = "Appearance2";

            run4.Append(runProperties8);
            run4.Append(text4);

            paragraph4.Append(run4);

            sdtContentBlock4.Append(paragraph4);

            sdtBlock4.Append(sdtProperties4);
            sdtBlock4.Append(sdtEndCharProperties4);
            sdtBlock4.Append(sdtContentBlock4);

            SdtBlock sdtBlock5 = new SdtBlock();

            SdtProperties sdtProperties5 = new SdtProperties();

            RunProperties runProperties9 = new RunProperties();
            RunFonts runFonts8 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties9.Append(runFonts8);
            SdtAlias sdtAlias5 = new SdtAlias(){ Val = "Test1.2.3" };
            Tag tag5 = new Tag(){ Val = "Test1.2.3" };
            SdtId sdtId5 = new SdtId(){ Val = -343394056 };

            SdtPlaceholder sdtPlaceholder5 = new SdtPlaceholder();
            DocPartReference docPartReference5 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868558" };

            sdtPlaceholder5.Append(docPartReference5);
            W15.Appearance appearance2 = new W15.Appearance(){ Val = W15.SdtAppearance.Hidden };
            SdtContentText sdtContentText5 = new SdtContentText();

            sdtProperties5.Append(runProperties9);
            sdtProperties5.Append(sdtAlias5);
            sdtProperties5.Append(tag5);
            sdtProperties5.Append(sdtId5);
            sdtProperties5.Append(sdtPlaceholder5);
            sdtProperties5.Append(appearance2);
            sdtProperties5.Append(sdtContentText5);
            SdtEndCharProperties sdtEndCharProperties5 = new SdtEndCharProperties();

            SdtContentBlock sdtContentBlock5 = new SdtContentBlock();

            Paragraph paragraph5 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" };

            Run run5 = new Run();

            RunProperties runProperties10 = new RunProperties();
            RunFonts runFonts9 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties10.Append(runFonts9);
            Text text5 = new Text();
            text5.Text = "Appearance3";

            run5.Append(runProperties10);
            run5.Append(text5);

            paragraph5.Append(run5);

            sdtContentBlock5.Append(paragraph5);

            sdtBlock5.Append(sdtProperties5);
            sdtBlock5.Append(sdtEndCharProperties5);
            sdtBlock5.Append(sdtContentBlock5);

            SdtBlock sdtBlock6 = new SdtBlock();

            SdtProperties sdtProperties6 = new SdtProperties();

            RunProperties runProperties11 = new RunProperties();
            RunFonts runFonts10 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties11.Append(runFonts10);
            SdtAlias sdtAlias6 = new SdtAlias(){ Val = "Test1.3.1" };
            Tag tag6 = new Tag(){ Val = "Test1.3.1" };
            SdtId sdtId6 = new SdtId(){ Val = 1119424041 };

            SdtPlaceholder sdtPlaceholder6 = new SdtPlaceholder();
            DocPartReference docPartReference6 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868558" };

            sdtPlaceholder6.Append(docPartReference6);
            SdtContentText sdtContentText6 = new SdtContentText();

            sdtProperties6.Append(runProperties11);
            sdtProperties6.Append(sdtAlias6);
            sdtProperties6.Append(tag6);
            sdtProperties6.Append(sdtId6);
            sdtProperties6.Append(sdtPlaceholder6);
            sdtProperties6.Append(sdtContentText6);
            SdtEndCharProperties sdtEndCharProperties6 = new SdtEndCharProperties();

            SdtContentBlock sdtContentBlock6 = new SdtContentBlock();

            Paragraph paragraph6 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" };

            Run run6 = new Run();

            RunProperties runProperties12 = new RunProperties();
            RunFonts runFonts11 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties12.Append(runFonts11);
            Text text6 = new Text();
            text6.Text = "Color Content Control1";

            run6.Append(runProperties12);
            run6.Append(text6);

            paragraph6.Append(run6);

            sdtContentBlock6.Append(paragraph6);

            sdtBlock6.Append(sdtProperties6);
            sdtBlock6.Append(sdtEndCharProperties6);
            sdtBlock6.Append(sdtContentBlock6);

            SdtBlock sdtBlock7 = new SdtBlock();

            SdtProperties sdtProperties7 = new SdtProperties();

            RunProperties runProperties13 = new RunProperties();
            RunFonts runFonts12 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties13.Append(runFonts12);
            SdtAlias sdtAlias7 = new SdtAlias(){ Val = "Test1.3.2" };
            Tag tag7 = new Tag(){ Val = "Test1.3.2" };
            SdtId sdtId7 = new SdtId(){ Val = 550972260 };

            SdtPlaceholder sdtPlaceholder7 = new SdtPlaceholder();
            DocPartReference docPartReference7 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868558" };

            sdtPlaceholder7.Append(docPartReference7);
            W15.Color color1 = new W15.Color(){ Val = "0000FF" };
            SdtContentText sdtContentText7 = new SdtContentText();

            sdtProperties7.Append(runProperties13);
            sdtProperties7.Append(sdtAlias7);
            sdtProperties7.Append(tag7);
            sdtProperties7.Append(sdtId7);
            sdtProperties7.Append(sdtPlaceholder7);
            sdtProperties7.Append(color1);
            sdtProperties7.Append(sdtContentText7);
            SdtEndCharProperties sdtEndCharProperties7 = new SdtEndCharProperties();

            SdtContentBlock sdtContentBlock7 = new SdtContentBlock();

            Paragraph paragraph7 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" };

            Run run7 = new Run();

            RunProperties runProperties14 = new RunProperties();
            RunFonts runFonts13 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties14.Append(runFonts13);
            Text text7 = new Text();
            text7.Text = "Color Content Control2";

            run7.Append(runProperties14);
            run7.Append(text7);

            paragraph7.Append(run7);

            sdtContentBlock7.Append(paragraph7);

            sdtBlock7.Append(sdtProperties7);
            sdtBlock7.Append(sdtEndCharProperties7);
            sdtBlock7.Append(sdtContentBlock7);

            SdtBlock sdtBlock8 = new SdtBlock();

            SdtProperties sdtProperties8 = new SdtProperties();

            RunProperties runProperties15 = new RunProperties();
            RunFonts runFonts14 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties15.Append(runFonts14);
            SdtAlias sdtAlias8 = new SdtAlias(){ Val = "Test1.4.1" };
            Tag tag8 = new Tag(){ Val = "Test1.4.1" };
            SdtId sdtId8 = new SdtId(){ Val = 1758249604 };
            W15.SdtRepeatedSection sdtRepeatedSection1 = new W15.SdtRepeatedSection();

            sdtProperties8.Append(runProperties15);
            sdtProperties8.Append(sdtAlias8);
            sdtProperties8.Append(tag8);
            sdtProperties8.Append(sdtId8);
            sdtProperties8.Append(sdtRepeatedSection1);
            SdtEndCharProperties sdtEndCharProperties8 = new SdtEndCharProperties();

            SdtContentBlock sdtContentBlock8 = new SdtContentBlock();

            SdtBlock sdtBlock9 = new SdtBlock();

            SdtProperties sdtProperties9 = new SdtProperties();

            RunProperties runProperties16 = new RunProperties();
            RunFonts runFonts15 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties16.Append(runFonts15);
            SdtId sdtId9 = new SdtId(){ Val = 481433089 };

            SdtPlaceholder sdtPlaceholder8 = new SdtPlaceholder();
            DocPartReference docPartReference8 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868562" };

            sdtPlaceholder8.Append(docPartReference8);
            ShowingPlaceholder showingPlaceholder2 = new ShowingPlaceholder();
            W15.SdtRepeatedSectionItem sdtRepeatedSectionItem1 = new W15.SdtRepeatedSectionItem();

            sdtProperties9.Append(runProperties16);
            sdtProperties9.Append(sdtId9);
            sdtProperties9.Append(sdtPlaceholder8);
            sdtProperties9.Append(showingPlaceholder2);
            sdtProperties9.Append(sdtRepeatedSectionItem1);
            SdtEndCharProperties sdtEndCharProperties9 = new SdtEndCharProperties();

            SdtContentBlock sdtContentBlock9 = new SdtContentBlock();

            Paragraph paragraph8 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" };

            Run run8 = new Run(){ RsidRunProperties = "003E0DED" };

            RunProperties runProperties17 = new RunProperties();
            RunStyle runStyle2 = new RunStyle(){ Val = "PlaceholderText" };

            runProperties17.Append(runStyle2);
            Text text8 = new Text();
            text8.Text = "Enter any content that you want to repeat, including other content controls. You can also insert this control around table rows in order to repeat parts of a table.";

            run8.Append(runProperties17);
            run8.Append(text8);

            paragraph8.Append(run8);

            sdtContentBlock9.Append(paragraph8);

            sdtBlock9.Append(sdtProperties9);
            sdtBlock9.Append(sdtEndCharProperties9);
            sdtBlock9.Append(sdtContentBlock9);

            sdtContentBlock8.Append(sdtBlock9);

            sdtBlock8.Append(sdtProperties8);
            sdtBlock8.Append(sdtEndCharProperties8);
            sdtBlock8.Append(sdtContentBlock8);

            SdtBlock sdtBlock10 = new SdtBlock();

            SdtProperties sdtProperties10 = new SdtProperties();

            RunProperties runProperties18 = new RunProperties();
            RunFonts runFonts16 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties18.Append(runFonts16);
            SdtAlias sdtAlias9 = new SdtAlias(){ Val = "Test1.4.2" };
            Tag tag9 = new Tag(){ Val = "Test1.4.2" };
            SdtId sdtId10 = new SdtId(){ Val = -78606169 };
            W15.SdtRepeatedSection sdtRepeatedSection2 = new W15.SdtRepeatedSection();

            sdtProperties10.Append(runProperties18);
            sdtProperties10.Append(sdtAlias9);
            sdtProperties10.Append(tag9);
            sdtProperties10.Append(sdtId10);
            sdtProperties10.Append(sdtRepeatedSection2);
            SdtEndCharProperties sdtEndCharProperties10 = new SdtEndCharProperties();

            SdtContentBlock sdtContentBlock10 = new SdtContentBlock();

            SdtBlock sdtBlock11 = new SdtBlock();

            SdtProperties sdtProperties11 = new SdtProperties();

            RunProperties runProperties19 = new RunProperties();
            RunFonts runFonts17 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties19.Append(runFonts17);
            SdtId sdtId11 = new SdtId(){ Val = -1356270719 };

            SdtPlaceholder sdtPlaceholder9 = new SdtPlaceholder();
            DocPartReference docPartReference9 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868562" };

            sdtPlaceholder9.Append(docPartReference9);
            W15.SdtRepeatedSectionItem sdtRepeatedSectionItem2 = new W15.SdtRepeatedSectionItem();

            sdtProperties11.Append(runProperties19);
            sdtProperties11.Append(sdtId11);
            sdtProperties11.Append(sdtPlaceholder9);
            sdtProperties11.Append(sdtRepeatedSectionItem2);
            SdtEndCharProperties sdtEndCharProperties11 = new SdtEndCharProperties();

            SdtContentBlock sdtContentBlock11 = new SdtContentBlock();

            Paragraph paragraph9 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" };
            ProofError proofError1 = new ProofError(){ Type = ProofingErrorValues.SpellStart };
            ProofError proofError2 = new ProofError(){ Type = ProofingErrorValues.GrammarStart };

            Run run9 = new Run();

            RunProperties runProperties20 = new RunProperties();
            RunFonts runFonts18 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties20.Append(runFonts18);
            Text text9 = new Text();
            text9.Text = "repeatingSectionItem";

            run9.Append(runProperties20);
            run9.Append(text9);
            ProofError proofError3 = new ProofError(){ Type = ProofingErrorValues.SpellEnd };
            ProofError proofError4 = new ProofError(){ Type = ProofingErrorValues.GrammarEnd };

            paragraph9.Append(proofError1);
            paragraph9.Append(proofError2);
            paragraph9.Append(run9);
            paragraph9.Append(proofError3);
            paragraph9.Append(proofError4);

            sdtContentBlock11.Append(paragraph9);

            sdtBlock11.Append(sdtProperties11);
            sdtBlock11.Append(sdtEndCharProperties11);
            sdtBlock11.Append(sdtContentBlock11);

            sdtContentBlock10.Append(sdtBlock11);

            sdtBlock10.Append(sdtProperties10);
            sdtBlock10.Append(sdtEndCharProperties10);
            sdtBlock10.Append(sdtContentBlock10);

            SdtBlock sdtBlock12 = new SdtBlock();

            SdtProperties sdtProperties12 = new SdtProperties();

            RunProperties runProperties21 = new RunProperties();
            RunFonts runFonts19 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties21.Append(runFonts19);
            SdtAlias sdtAlias10 = new SdtAlias(){ Val = "Test1.4.3" };
            Tag tag10 = new Tag(){ Val = "Test1.4.3" };
            SdtId sdtId12 = new SdtId(){ Val = -294221661 };

            W15.SdtRepeatedSection sdtRepeatedSection3 = new W15.SdtRepeatedSection();
            W15.DoNotAllowInsertDeleteSection doNotAllowInsertDeleteSection1 = new W15.DoNotAllowInsertDeleteSection(){ Val = true };

            sdtRepeatedSection3.Append(doNotAllowInsertDeleteSection1);

            sdtProperties12.Append(runProperties21);
            sdtProperties12.Append(sdtAlias10);
            sdtProperties12.Append(tag10);
            sdtProperties12.Append(sdtId12);
            sdtProperties12.Append(sdtRepeatedSection3);
            SdtEndCharProperties sdtEndCharProperties12 = new SdtEndCharProperties();

            SdtContentBlock sdtContentBlock12 = new SdtContentBlock();

            SdtBlock sdtBlock13 = new SdtBlock();

            SdtProperties sdtProperties13 = new SdtProperties();

            RunProperties runProperties22 = new RunProperties();
            RunFonts runFonts20 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties22.Append(runFonts20);
            SdtId sdtId13 = new SdtId(){ Val = 2112001363 };
            Lock lock1 = new Lock(){ Val = LockingValues.SdtLocked };

            SdtPlaceholder sdtPlaceholder10 = new SdtPlaceholder();
            DocPartReference docPartReference10 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868562" };

            sdtPlaceholder10.Append(docPartReference10);
            W15.SdtRepeatedSectionItem sdtRepeatedSectionItem3 = new W15.SdtRepeatedSectionItem();

            sdtProperties13.Append(runProperties22);
            sdtProperties13.Append(sdtId13);
            sdtProperties13.Append(lock1);
            sdtProperties13.Append(sdtPlaceholder10);
            sdtProperties13.Append(sdtRepeatedSectionItem3);
            SdtEndCharProperties sdtEndCharProperties13 = new SdtEndCharProperties();

            SdtContentBlock sdtContentBlock13 = new SdtContentBlock();

            Paragraph paragraph10 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" };
            ProofError proofError5 = new ProofError(){ Type = ProofingErrorValues.SpellStart };
            ProofError proofError6 = new ProofError(){ Type = ProofingErrorValues.GrammarStart };

            Run run10 = new Run();

            RunProperties runProperties23 = new RunProperties();
            RunFonts runFonts21 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties23.Append(runFonts21);
            Text text10 = new Text();
            text10.Text = "doNotAllowInsertDeleteSection";

            run10.Append(runProperties23);
            run10.Append(text10);
            ProofError proofError7 = new ProofError(){ Type = ProofingErrorValues.SpellEnd };
            ProofError proofError8 = new ProofError(){ Type = ProofingErrorValues.GrammarEnd };

            paragraph10.Append(proofError5);
            paragraph10.Append(proofError6);
            paragraph10.Append(run10);
            paragraph10.Append(proofError7);
            paragraph10.Append(proofError8);

            sdtContentBlock13.Append(paragraph10);

            sdtBlock13.Append(sdtProperties13);
            sdtBlock13.Append(sdtEndCharProperties13);
            sdtBlock13.Append(sdtContentBlock13);

            sdtContentBlock12.Append(sdtBlock13);

            sdtBlock12.Append(sdtProperties12);
            sdtBlock12.Append(sdtEndCharProperties12);
            sdtBlock12.Append(sdtContentBlock12);

            SdtBlock sdtBlock14 = new SdtBlock();

            SdtProperties sdtProperties14 = new SdtProperties();

            RunProperties runProperties24 = new RunProperties();
            RunFonts runFonts22 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties24.Append(runFonts22);
            SdtAlias sdtAlias11 = new SdtAlias(){ Val = "Test1.4.4" };
            Tag tag11 = new Tag(){ Val = "Test1.4.4" };
            SdtId sdtId14 = new SdtId(){ Val = -248501389 };

            W15.SdtRepeatedSection sdtRepeatedSection4 = new W15.SdtRepeatedSection();
            W15.SectionTitle sectionTitle1 = new W15.SectionTitle(){ Val = "Section title string" };

            sdtRepeatedSection4.Append(sectionTitle1);

            sdtProperties14.Append(runProperties24);
            sdtProperties14.Append(sdtAlias11);
            sdtProperties14.Append(tag11);
            sdtProperties14.Append(sdtId14);
            sdtProperties14.Append(sdtRepeatedSection4);
            SdtEndCharProperties sdtEndCharProperties14 = new SdtEndCharProperties();

            SdtContentBlock sdtContentBlock14 = new SdtContentBlock();

            SdtBlock sdtBlock15 = new SdtBlock();

            SdtProperties sdtProperties15 = new SdtProperties();

            RunProperties runProperties25 = new RunProperties();
            RunFonts runFonts23 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties25.Append(runFonts23);
            SdtId sdtId15 = new SdtId(){ Val = 1971018620 };

            SdtPlaceholder sdtPlaceholder11 = new SdtPlaceholder();
            DocPartReference docPartReference11 = new DocPartReference(){ Val = "DefaultPlaceholder_1081868562" };

            sdtPlaceholder11.Append(docPartReference11);
            W15.SdtRepeatedSectionItem sdtRepeatedSectionItem4 = new W15.SdtRepeatedSectionItem();

            sdtProperties15.Append(runProperties25);
            sdtProperties15.Append(sdtId15);
            sdtProperties15.Append(sdtPlaceholder11);
            sdtProperties15.Append(sdtRepeatedSectionItem4);
            SdtEndCharProperties sdtEndCharProperties15 = new SdtEndCharProperties();

            SdtContentBlock sdtContentBlock15 = new SdtContentBlock();

            Paragraph paragraph11 = new Paragraph(){ RsidParagraphAddition = "000010BA", RsidRunAdditionDefault = "000010BA" };
            ProofError proofError9 = new ProofError(){ Type = ProofingErrorValues.SpellStart };
            ProofError proofError10 = new ProofError(){ Type = ProofingErrorValues.GrammarStart };

            Run run11 = new Run();

            RunProperties runProperties26 = new RunProperties();
            RunFonts runFonts24 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties26.Append(runFonts24);
            Text text11 = new Text();
            text11.Text = "sectionTitle";

            run11.Append(runProperties26);
            run11.Append(text11);
            ProofError proofError11 = new ProofError(){ Type = ProofingErrorValues.SpellEnd };
            ProofError proofError12 = new ProofError(){ Type = ProofingErrorValues.GrammarEnd };

            paragraph11.Append(proofError9);
            paragraph11.Append(proofError10);
            paragraph11.Append(run11);
            paragraph11.Append(proofError11);
            paragraph11.Append(proofError12);

            sdtContentBlock15.Append(paragraph11);

            sdtBlock15.Append(sdtProperties15);
            sdtBlock15.Append(sdtEndCharProperties15);
            sdtBlock15.Append(sdtContentBlock15);

            sdtContentBlock14.Append(sdtBlock15);

            sdtBlock14.Append(sdtProperties14);
            sdtBlock14.Append(sdtEndCharProperties14);
            sdtBlock14.Append(sdtContentBlock14);

            Table table1 = new Table();

            TableProperties tableProperties1 = new TableProperties();
            TableWidth tableWidth1 = new TableWidth(){ Width = "0", Type = TableWidthUnitValues.Auto };

            TableBorders tableBorders1 = new TableBorders();
            TopBorder topBorder1 = new TopBorder(){ Val = BorderValues.Double, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
            LeftBorder leftBorder1 = new LeftBorder(){ Val = BorderValues.Double, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
            BottomBorder bottomBorder1 = new BottomBorder(){ Val = BorderValues.Double, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
            RightBorder rightBorder1 = new RightBorder(){ Val = BorderValues.Double, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
            InsideHorizontalBorder insideHorizontalBorder1 = new InsideHorizontalBorder(){ Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
            InsideVerticalBorder insideVerticalBorder1 = new InsideVerticalBorder(){ Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };

            tableBorders1.Append(topBorder1);
            tableBorders1.Append(leftBorder1);
            tableBorders1.Append(bottomBorder1);
            tableBorders1.Append(rightBorder1);
            tableBorders1.Append(insideHorizontalBorder1);
            tableBorders1.Append(insideVerticalBorder1);
            TableLayout tableLayout1 = new TableLayout(){ Type = TableLayoutValues.Fixed };
            TableLook tableLook1 = new TableLook(){ Val = "0000" };

            tableProperties1.Append(tableWidth1);
            tableProperties1.Append(tableBorders1);
            tableProperties1.Append(tableLayout1);
            tableProperties1.Append(tableLook1);

            TableGrid tableGrid1 = new TableGrid();
            GridColumn gridColumn1 = new GridColumn(){ Width = "4788" };
            GridColumn gridColumn2 = new GridColumn(){ Width = "4788" };

            tableGrid1.Append(gridColumn1);
            tableGrid1.Append(gridColumn2);

            SdtRow sdtRow1 = new SdtRow();

            SdtProperties sdtProperties16 = new SdtProperties();
            SdtId sdtId16 = new SdtId(){ Val = 1391384564 };

            SdtPlaceholder sdtPlaceholder12 = new SdtPlaceholder();
            DocPartReference docPartReference12 = new DocPartReference(){ Val = "B207B2DF6D0E4E13956E6616811860CA" };

            sdtPlaceholder12.Append(docPartReference12);
            W15.DataBinding dataBinding1 = new W15.DataBinding(){ XPath = "/books[1]/book", StoreItemId = "{F6DB09CA-2A79-464E-B71A-D37E08A01059}" };
            W15.Appearance appearance3 = new W15.Appearance(){ Val = W15.SdtAppearance.Tags };
            W15.SdtRepeatedSection sdtRepeatedSection5 = new W15.SdtRepeatedSection();

            sdtProperties16.Append(sdtId16);
            sdtProperties16.Append(sdtPlaceholder12);
            sdtProperties16.Append(dataBinding1);
            sdtProperties16.Append(appearance3);
            sdtProperties16.Append(sdtRepeatedSection5);
            SdtEndCharProperties sdtEndCharProperties16 = new SdtEndCharProperties();

            SdtContentRow sdtContentRow1 = new SdtContentRow();

            SdtRow sdtRow2 = new SdtRow();

            SdtProperties sdtProperties17 = new SdtProperties();
            SdtId sdtId17 = new SdtId(){ Val = 1787311118 };
            W15.Appearance appearance4 = new W15.Appearance(){ Val = W15.SdtAppearance.Tags };
            W15.SdtRepeatedSectionItem sdtRepeatedSectionItem5 = new W15.SdtRepeatedSectionItem();

            sdtProperties17.Append(sdtId17);
            sdtProperties17.Append(appearance4);
            sdtProperties17.Append(sdtRepeatedSectionItem5);
            SdtEndCharProperties sdtEndCharProperties17 = new SdtEndCharProperties();

            SdtContentRow sdtContentRow2 = new SdtContentRow();

            TableRow tableRow1 = new TableRow(){ RsidTableRowAddition = "00E930A2", RsidTableRowProperties = "00242789" };

            SdtCell sdtCell1 = new SdtCell();

            SdtProperties sdtProperties18 = new SdtProperties();
            SdtAlias sdtAlias12 = new SdtAlias(){ Val = "Test1.5.1_1" };
            Tag tag12 = new Tag(){ Val = "Test1.5.1_1" };
            SdtId sdtId18 = new SdtId(){ Val = -1276551752 };

            SdtPlaceholder sdtPlaceholder13 = new SdtPlaceholder();
            DocPartReference docPartReference13 = new DocPartReference(){ Val = "B207B2DF6D0E4E13956E6616811860CA" };

            sdtPlaceholder13.Append(docPartReference13);
            DataBinding dataBinding2 = new DataBinding(){ XPath = "/books[1]/book[1]/title[1]", StoreItemId = "{F6DB09CA-2A79-464E-B71A-D37E08A01059}" };
            SdtContentText sdtContentText8 = new SdtContentText();

            sdtProperties18.Append(sdtAlias12);
            sdtProperties18.Append(tag12);
            sdtProperties18.Append(sdtId18);
            sdtProperties18.Append(sdtPlaceholder13);
            sdtProperties18.Append(dataBinding2);
            sdtProperties18.Append(sdtContentText8);
            SdtEndCharProperties sdtEndCharProperties18 = new SdtEndCharProperties();

            SdtContentCell sdtContentCell1 = new SdtContentCell();

            TableCell tableCell1 = new TableCell();

            TableCellProperties tableCellProperties1 = new TableCellProperties();
            TableCellWidth tableCellWidth1 = new TableCellWidth(){ Width = "4788", Type = TableWidthUnitValues.Dxa };
            Shading shading1 = new Shading(){ Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" };

            tableCellProperties1.Append(tableCellWidth1);
            tableCellProperties1.Append(shading1);

            Paragraph paragraph12 = new Paragraph(){ RsidParagraphAddition = "00E930A2", RsidParagraphProperties = "00E86739", RsidRunAdditionDefault = "00E930A2" };

            Run run12 = new Run();

            RunProperties runProperties27 = new RunProperties();
            RunFonts runFonts25 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties27.Append(runFonts25);
            Text text12 = new Text();
            text12.Text = "Repeating Section,Row1";

            run12.Append(runProperties27);
            run12.Append(text12);

            Run run13 = new Run(){ RsidRunAddition = "00E86739" };

            RunProperties runProperties28 = new RunProperties();
            RunFonts runFonts26 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties28.Append(runFonts26);
            Text text13 = new Text();
            text13.Text = ",Cell1";

            run13.Append(runProperties28);
            run13.Append(text13);

            paragraph12.Append(run12);
            paragraph12.Append(run13);

            tableCell1.Append(tableCellProperties1);
            tableCell1.Append(paragraph12);

            sdtContentCell1.Append(tableCell1);

            sdtCell1.Append(sdtProperties18);
            sdtCell1.Append(sdtEndCharProperties18);
            sdtCell1.Append(sdtContentCell1);

            SdtCell sdtCell2 = new SdtCell();

            SdtProperties sdtProperties19 = new SdtProperties();

            RunProperties runProperties29 = new RunProperties();
            Kern kern1 = new Kern(){ Val = (UInt32Value)0U };

            runProperties29.Append(kern1);
            SdtAlias sdtAlias13 = new SdtAlias(){ Val = "Test1.5.1_2" };
            Tag tag13 = new Tag(){ Val = "Test1.5.1_2" };
            SdtId sdtId19 = new SdtId(){ Val = -1317331761 };

            SdtPlaceholder sdtPlaceholder14 = new SdtPlaceholder();
            DocPartReference docPartReference14 = new DocPartReference(){ Val = "B207B2DF6D0E4E13956E6616811860CA" };

            sdtPlaceholder14.Append(docPartReference14);
            DataBinding dataBinding3 = new DataBinding(){ XPath = "/books[1]/book[1]/author[1]", StoreItemId = "{F6DB09CA-2A79-464E-B71A-D37E08A01059}" };
            SdtContentText sdtContentText9 = new SdtContentText();

            sdtProperties19.Append(runProperties29);
            sdtProperties19.Append(sdtAlias13);
            sdtProperties19.Append(tag13);
            sdtProperties19.Append(sdtId19);
            sdtProperties19.Append(sdtPlaceholder14);
            sdtProperties19.Append(dataBinding3);
            sdtProperties19.Append(sdtContentText9);
            SdtEndCharProperties sdtEndCharProperties19 = new SdtEndCharProperties();

            SdtContentCell sdtContentCell2 = new SdtContentCell();

            TableCell tableCell2 = new TableCell();

            TableCellProperties tableCellProperties2 = new TableCellProperties();
            TableCellWidth tableCellWidth2 = new TableCellWidth(){ Width = "4788", Type = TableWidthUnitValues.Dxa };
            Shading shading2 = new Shading(){ Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" };

            tableCellProperties2.Append(tableCellWidth2);
            tableCellProperties2.Append(shading2);

            Paragraph paragraph13 = new Paragraph(){ RsidParagraphAddition = "00E930A2", RsidParagraphProperties = "00E86739", RsidRunAdditionDefault = "00E930A2" };

            Run run14 = new Run();

            RunProperties runProperties30 = new RunProperties();
            Kern kern2 = new Kern(){ Val = (UInt32Value)0U };

            runProperties30.Append(kern2);
            Text text14 = new Text();
            text14.Text = "Repeating Section";

            run14.Append(runProperties30);
            run14.Append(text14);

            Run run15 = new Run(){ RsidRunAddition = "00E86739" };

            RunProperties runProperties31 = new RunProperties();
            RunFonts runFonts27 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };
            Kern kern3 = new Kern(){ Val = (UInt32Value)0U };

            runProperties31.Append(runFonts27);
            runProperties31.Append(kern3);
            Text text15 = new Text();
            text15.Text = ",";

            run15.Append(runProperties31);
            run15.Append(text15);

            Run run16 = new Run();

            RunProperties runProperties32 = new RunProperties();
            Kern kern4 = new Kern(){ Val = (UInt32Value)0U };

            runProperties32.Append(kern4);
            Text text16 = new Text();
            text16.Text = "Row1";

            run16.Append(runProperties32);
            run16.Append(text16);

            Run run17 = new Run(){ RsidRunAddition = "00E86739" };

            RunProperties runProperties33 = new RunProperties();
            RunFonts runFonts28 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };
            Kern kern5 = new Kern(){ Val = (UInt32Value)0U };

            runProperties33.Append(runFonts28);
            runProperties33.Append(kern5);
            Text text17 = new Text();
            text17.Text = ",Cell2";

            run17.Append(runProperties33);
            run17.Append(text17);

            paragraph13.Append(run14);
            paragraph13.Append(run15);
            paragraph13.Append(run16);
            paragraph13.Append(run17);

            tableCell2.Append(tableCellProperties2);
            tableCell2.Append(paragraph13);

            sdtContentCell2.Append(tableCell2);

            sdtCell2.Append(sdtProperties19);
            sdtCell2.Append(sdtEndCharProperties19);
            sdtCell2.Append(sdtContentCell2);

            tableRow1.Append(sdtCell1);
            tableRow1.Append(sdtCell2);

            sdtContentRow2.Append(tableRow1);

            sdtRow2.Append(sdtProperties17);
            sdtRow2.Append(sdtEndCharProperties17);
            sdtRow2.Append(sdtContentRow2);

            SdtRow sdtRow3 = new SdtRow();

            SdtProperties sdtProperties20 = new SdtProperties();
            SdtId sdtId20 = new SdtId(){ Val = 689805002 };
            W15.Appearance appearance5 = new W15.Appearance(){ Val = W15.SdtAppearance.Tags };
            W15.SdtRepeatedSectionItem sdtRepeatedSectionItem6 = new W15.SdtRepeatedSectionItem();

            sdtProperties20.Append(sdtId20);
            sdtProperties20.Append(appearance5);
            sdtProperties20.Append(sdtRepeatedSectionItem6);
            SdtEndCharProperties sdtEndCharProperties20 = new SdtEndCharProperties();

            SdtContentRow sdtContentRow3 = new SdtContentRow();

            TableRow tableRow2 = new TableRow(){ RsidTableRowAddition = "00E930A2", RsidTableRowProperties = "00242789" };

            SdtCell sdtCell3 = new SdtCell();

            SdtProperties sdtProperties21 = new SdtProperties();
            SdtAlias sdtAlias14 = new SdtAlias(){ Val = "Test1.5.1_3" };
            Tag tag14 = new Tag(){ Val = "Test1.5.1_3" };
            SdtId sdtId21 = new SdtId(){ Val = 880594776 };

            SdtPlaceholder sdtPlaceholder15 = new SdtPlaceholder();
            DocPartReference docPartReference15 = new DocPartReference(){ Val = "4B632797D8B1461898B8F461443A20E0" };

            sdtPlaceholder15.Append(docPartReference15);
            DataBinding dataBinding4 = new DataBinding(){ XPath = "/books[1]/book[4]/title[1]", StoreItemId = "{F6DB09CA-2A79-464E-B71A-D37E08A01059}" };
            SdtContentText sdtContentText10 = new SdtContentText();

            sdtProperties21.Append(sdtAlias14);
            sdtProperties21.Append(tag14);
            sdtProperties21.Append(sdtId21);
            sdtProperties21.Append(sdtPlaceholder15);
            sdtProperties21.Append(dataBinding4);
            sdtProperties21.Append(sdtContentText10);

            SdtEndCharProperties sdtEndCharProperties21 = new SdtEndCharProperties();

            RunProperties runProperties34 = new RunProperties();
            Kern kern6 = new Kern(){ Val = (UInt32Value)0U };

            runProperties34.Append(kern6);

            sdtEndCharProperties21.Append(runProperties34);

            SdtContentCell sdtContentCell3 = new SdtContentCell();

            TableCell tableCell3 = new TableCell();

            TableCellProperties tableCellProperties3 = new TableCellProperties();
            TableCellWidth tableCellWidth3 = new TableCellWidth(){ Width = "4788", Type = TableWidthUnitValues.Dxa };
            Shading shading3 = new Shading(){ Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" };

            tableCellProperties3.Append(tableCellWidth3);
            tableCellProperties3.Append(shading3);

            Paragraph paragraph14 = new Paragraph(){ RsidParagraphAddition = "00E930A2", RsidParagraphProperties = "00E86739", RsidRunAdditionDefault = "00E930A2" };

            Run run18 = new Run();

            RunProperties runProperties35 = new RunProperties();
            Kern kern7 = new Kern(){ Val = (UInt32Value)0U };

            runProperties35.Append(kern7);
            Text text18 = new Text();
            text18.Text = "Repeating Section";

            run18.Append(runProperties35);
            run18.Append(text18);

            Run run19 = new Run(){ RsidRunAddition = "00E86739" };

            RunProperties runProperties36 = new RunProperties();
            RunFonts runFonts29 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };
            Kern kern8 = new Kern(){ Val = (UInt32Value)0U };

            runProperties36.Append(runFonts29);
            runProperties36.Append(kern8);
            Text text19 = new Text();
            text19.Text = ",";

            run19.Append(runProperties36);
            run19.Append(text19);

            Run run20 = new Run();

            RunProperties runProperties37 = new RunProperties();
            Kern kern9 = new Kern(){ Val = (UInt32Value)0U };

            runProperties37.Append(kern9);
            Text text20 = new Text();
            text20.Text = "Row";

            run20.Append(runProperties37);
            run20.Append(text20);

            Run run21 = new Run();

            RunProperties runProperties38 = new RunProperties();
            RunFonts runFonts30 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };
            Kern kern10 = new Kern(){ Val = (UInt32Value)0U };

            runProperties38.Append(runFonts30);
            runProperties38.Append(kern10);
            Text text21 = new Text();
            text21.Text = "2";

            run21.Append(runProperties38);
            run21.Append(text21);

            Run run22 = new Run(){ RsidRunAddition = "00E86739" };

            RunProperties runProperties39 = new RunProperties();
            RunFonts runFonts31 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };
            Kern kern11 = new Kern(){ Val = (UInt32Value)0U };

            runProperties39.Append(runFonts31);
            runProperties39.Append(kern11);
            Text text22 = new Text();
            text22.Text = ",Cell1";

            run22.Append(runProperties39);
            run22.Append(text22);

            paragraph14.Append(run18);
            paragraph14.Append(run19);
            paragraph14.Append(run20);
            paragraph14.Append(run21);
            paragraph14.Append(run22);

            tableCell3.Append(tableCellProperties3);
            tableCell3.Append(paragraph14);

            sdtContentCell3.Append(tableCell3);

            sdtCell3.Append(sdtProperties21);
            sdtCell3.Append(sdtEndCharProperties21);
            sdtCell3.Append(sdtContentCell3);

            SdtCell sdtCell4 = new SdtCell();

            SdtProperties sdtProperties22 = new SdtProperties();

            RunProperties runProperties40 = new RunProperties();
            Kern kern12 = new Kern(){ Val = (UInt32Value)0U };

            runProperties40.Append(kern12);
            SdtAlias sdtAlias15 = new SdtAlias(){ Val = "Test1.5.1_4" };
            Tag tag15 = new Tag(){ Val = "Test1.5.1_4" };
            SdtId sdtId22 = new SdtId(){ Val = -1022928317 };

            SdtPlaceholder sdtPlaceholder16 = new SdtPlaceholder();
            DocPartReference docPartReference16 = new DocPartReference(){ Val = "4B632797D8B1461898B8F461443A20E0" };

            sdtPlaceholder16.Append(docPartReference16);
            DataBinding dataBinding5 = new DataBinding(){ XPath = "/books[1]/book[4]/author[1]", StoreItemId = "{F6DB09CA-2A79-464E-B71A-D37E08A01059}" };
            SdtContentText sdtContentText11 = new SdtContentText();

            sdtProperties22.Append(runProperties40);
            sdtProperties22.Append(sdtAlias15);
            sdtProperties22.Append(tag15);
            sdtProperties22.Append(sdtId22);
            sdtProperties22.Append(sdtPlaceholder16);
            sdtProperties22.Append(dataBinding5);
            sdtProperties22.Append(sdtContentText11);
            SdtEndCharProperties sdtEndCharProperties22 = new SdtEndCharProperties();

            SdtContentCell sdtContentCell4 = new SdtContentCell();

            TableCell tableCell4 = new TableCell();

            TableCellProperties tableCellProperties4 = new TableCellProperties();
            TableCellWidth tableCellWidth4 = new TableCellWidth(){ Width = "4788", Type = TableWidthUnitValues.Dxa };
            Shading shading4 = new Shading(){ Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" };

            tableCellProperties4.Append(tableCellWidth4);
            tableCellProperties4.Append(shading4);

            Paragraph paragraph15 = new Paragraph(){ RsidParagraphAddition = "00E930A2", RsidParagraphProperties = "00E86739", RsidRunAdditionDefault = "009651D6" };

            Run run23 = new Run();

            RunProperties runProperties41 = new RunProperties();
            Kern kern13 = new Kern(){ Val = (UInt32Value)0U };

            runProperties41.Append(kern13);
            Text text23 = new Text();
            text23.Text = "Repeating Section";

            run23.Append(runProperties41);
            run23.Append(text23);

            Run run24 = new Run(){ RsidRunAddition = "00E86739" };

            RunProperties runProperties42 = new RunProperties();
            RunFonts runFonts32 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };
            Kern kern14 = new Kern(){ Val = (UInt32Value)0U };

            runProperties42.Append(runFonts32);
            runProperties42.Append(kern14);
            Text text24 = new Text();
            text24.Text = ",Row2,Cell2";

            run24.Append(runProperties42);
            run24.Append(text24);

            paragraph15.Append(run23);
            paragraph15.Append(run24);

            tableCell4.Append(tableCellProperties4);
            tableCell4.Append(paragraph15);

            sdtContentCell4.Append(tableCell4);

            sdtCell4.Append(sdtProperties22);
            sdtCell4.Append(sdtEndCharProperties22);
            sdtCell4.Append(sdtContentCell4);

            tableRow2.Append(sdtCell3);
            tableRow2.Append(sdtCell4);

            sdtContentRow3.Append(tableRow2);

            sdtRow3.Append(sdtProperties20);
            sdtRow3.Append(sdtEndCharProperties20);
            sdtRow3.Append(sdtContentRow3);

            sdtContentRow1.Append(sdtRow2);
            sdtContentRow1.Append(sdtRow3);

            sdtRow1.Append(sdtProperties16);
            sdtRow1.Append(sdtEndCharProperties16);
            sdtRow1.Append(sdtContentRow1);

            TableRow tableRow3 = new TableRow(){ RsidTableRowAddition = "00E930A2", RsidTableRowProperties = "00242789" };

            TableCell tableCell5 = new TableCell();

            TableCellProperties tableCellProperties5 = new TableCellProperties();
            TableCellWidth tableCellWidth5 = new TableCellWidth(){ Width = "4788", Type = TableWidthUnitValues.Dxa };
            Shading shading5 = new Shading(){ Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" };

            tableCellProperties5.Append(tableCellWidth5);
            tableCellProperties5.Append(shading5);
            Paragraph paragraph16 = new Paragraph(){ RsidParagraphAddition = "00E930A2", RsidParagraphProperties = "00242789", RsidRunAdditionDefault = "00E930A2" };

            tableCell5.Append(tableCellProperties5);
            tableCell5.Append(paragraph16);

            TableCell tableCell6 = new TableCell();

            TableCellProperties tableCellProperties6 = new TableCellProperties();
            TableCellWidth tableCellWidth6 = new TableCellWidth(){ Width = "4788", Type = TableWidthUnitValues.Dxa };
            Shading shading6 = new Shading(){ Val = ShadingPatternValues.Clear, Color = "auto", Fill = "auto" };

            tableCellProperties6.Append(tableCellWidth6);
            tableCellProperties6.Append(shading6);
            Paragraph paragraph17 = new Paragraph(){ RsidParagraphAddition = "00E930A2", RsidParagraphProperties = "00242789", RsidRunAdditionDefault = "00E930A2" };

            tableCell6.Append(tableCellProperties6);
            tableCell6.Append(paragraph17);

            tableRow3.Append(tableCell5);
            tableRow3.Append(tableCell6);

            table1.Append(tableProperties1);
            table1.Append(tableGrid1);
            table1.Append(sdtRow1);
            table1.Append(tableRow3);
            Paragraph paragraph18 = new Paragraph(){ RsidParagraphAddition = "00E930A2", RsidRunAdditionDefault = "00E930A2" };

            SectionProperties sectionProperties1 = new SectionProperties(){ RsidR = "00E930A2" };
            PageSize pageSize1 = new PageSize(){ Width = (UInt32Value)11906U, Height = (UInt32Value)16838U };
            PageMargin pageMargin1 = new PageMargin(){ Top = 1985, Right = (UInt32Value)1701U, Bottom = 1701, Left = (UInt32Value)1701U, Header = (UInt32Value)851U, Footer = (UInt32Value)992U, Gutter = (UInt32Value)0U };
            Columns columns1 = new Columns(){ Space = "425" };
            DocGrid docGrid1 = new DocGrid(){ Type = DocGridValues.Lines, LinePitch = 360 };

            sectionProperties1.Append(pageSize1);
            sectionProperties1.Append(pageMargin1);
            sectionProperties1.Append(columns1);
            sectionProperties1.Append(docGrid1);

            body1.Append(sdtBlock1);
            body1.Append(sdtBlock2);
            body1.Append(sdtBlock3);
            body1.Append(sdtBlock4);
            body1.Append(sdtBlock5);
            body1.Append(sdtBlock6);
            body1.Append(sdtBlock7);
            body1.Append(sdtBlock8);
            body1.Append(sdtBlock10);
            body1.Append(sdtBlock12);
            body1.Append(sdtBlock14);
            body1.Append(table1);
            body1.Append(paragraph18);
            body1.Append(sectionProperties1);

            document1.Append(body1);

            mainDocumentPart1.Document = document1;
        }
Example #60
0
        public byte[] CreateWordDocument(Schema schemaData, string templateLocation)
        {
            byte[] binFile = null;


            byte[] byteArray = File.ReadAllBytes(templateLocation);
            using (MemoryStream mem = new MemoryStream())
            {
                mem.Write(byteArray, 0, (int)byteArray.Length);

                using (WordprocessingDocument doc = WordprocessingDocument.Open(mem, true))
                {
                    Table table = doc.MainDocumentPart.Document.Body.GetFirstChild <Table>();

                    RunFonts textFonts =
                        table.GetFirstChild <TableRow>().GetFirstChild <TableCell>().GetFirstChild <Paragraph>().
                        GetFirstChild <ParagraphProperties>().GetFirstChild <ParagraphMarkRunProperties>().
                        GetFirstChild <RunFonts>();
                    string paragraphPropertiesOuterXml = getParagraphPropertiesXml(textFonts);
                    string runPropertiesOuterXml       = getRunPropertiesXml(textFonts);


                    table.Elements <TableRow>().ElementAt(0).Elements <TableCell>().ElementAt(1).Elements <Paragraph>().ElementAt(0).Append(new Run(new RunProperties(runPropertiesOuterXml), new Text(schemaData.Title)));
                    table.Elements <TableRow>().ElementAt(1).Elements <TableCell>().ElementAt(1).Elements <Paragraph>().ElementAt(0).Append(new Run(new RunProperties(runPropertiesOuterXml), new Text(schemaData.Description)));
                    table.Elements <TableRow>().ElementAt(2).Elements <TableCell>().ElementAt(1).Elements <Paragraph>().ElementAt(0).Append(new Run(new RunProperties(runPropertiesOuterXml), new Text(schemaData.SchemaType + TEXT_SCHEMA)));
                    table.Elements <TableRow>().ElementAt(3).Elements <TableCell>().ElementAt(1).Elements <Paragraph>().ElementAt(0).Append(new Run(new RunProperties(runPropertiesOuterXml), new Text(schemaData.RootElementName)));
                    table.Elements <TableRow>().ElementAt(4).Elements <TableCell>().ElementAt(1).Elements <Paragraph>().ElementAt(0).Append(new Run(new RunProperties(runPropertiesOuterXml), new Text(schemaData.NamespaceUri)));


                    // Save properties for metadata row
                    TableRowProperties metaDataRowProperties =
                        table.Elements <TableRow>().ElementAt(5).GetFirstChild <TableRowProperties>();
                    TableCellProperties metaDataCellProperties =
                        table.Elements <TableRow>().ElementAt(5).GetFirstChild <TableCell>().GetFirstChild <TableCellProperties>();
                    ParagraphProperties metaDataParagraphProperties =
                        table.Elements <TableRow>().ElementAt(5).GetFirstChild <TableCell>().GetFirstChild <Paragraph>().GetFirstChild <ParagraphProperties>();
                    RunProperties metaDataRunProperties =
                        table.Elements <TableRow>().ElementAt(5).GetFirstChild <TableCell>().GetFirstChild <Paragraph>().GetFirstChild <Run>().GetFirstChild <RunProperties>();


                    // Clear empty rows
                    foreach (TableRow row in table.Elements <TableRow>())
                    {
                        Text text = row.Elements <TableCell>().ElementAt(1).GetFirstChild <Paragraph>().GetFirstChild <Run>().GetFirstChild <Text>();

                        if (string.IsNullOrEmpty(text.InnerText.Trim()))
                        {
                            table.RemoveChild(row);
                        }
                    }

                    foreach (SchemaField field in schemaData.Fields)
                    {
                        TableRow tr = new TableRow();

                        TableCell tc1 = new TableCell();
                        tc1.Append(new Paragraph(new ParagraphProperties(paragraphPropertiesOuterXml), new Run(new RunProperties(runPropertiesOuterXml), new Text(field.Description))));
                        tr.Append(tc1);

                        TableCell tc2 = new TableCell();
                        tc2.Append(new Paragraph(new ParagraphProperties(paragraphPropertiesOuterXml), new Run(new RunProperties(runPropertiesOuterXml), new Text(field.XmlName))));
                        tr.Append(tc2);

                        TableCell tc3 = new TableCell();
                        tc3.Append(new Paragraph(new ParagraphProperties(paragraphPropertiesOuterXml), new Run(new RunProperties(runPropertiesOuterXml), new Text(field.FieldType))));
                        tr.Append(tc3);

                        TableCell tc4 = new TableCell();
                        tc4.Append(new Paragraph(new ParagraphProperties(paragraphPropertiesOuterXml), new Run(new RunProperties(runPropertiesOuterXml), new Text((field.Required) ? TEXT_YES : TEXT_NO))));
                        tr.Append(tc4);

                        TableCell tc5 = new TableCell();
                        tc5.Append(new Paragraph(new ParagraphProperties(paragraphPropertiesOuterXml), new Run(new RunProperties(runPropertiesOuterXml), new Text((field.MultiValue) ? TEXT_YES : TEXT_NO))));
                        tr.Append(tc5);

                        TableCell tc6 = new TableCell();
                        tc6.Append(new Paragraph(new ParagraphProperties(paragraphPropertiesOuterXml), new Run(new RunProperties(runPropertiesOuterXml), new Text(field.Properties))));
                        tr.Append(tc6);

                        table.Append(tr);
                    }


                    if (schemaData.MetadataFields.Count > 0 && schemaData.SchemaType == "Component")
                    {
                        TableRow            tr           = new TableRow();
                        TableCell           tc           = new TableCell();
                        TableCellProperties tcProperties = new TableCellProperties(metaDataCellProperties.OuterXml);
                        GridSpan            gridSpan     = new GridSpan()
                        {
                            Val = 6
                        };
                        tcProperties.Append(gridSpan);

                        tr.Append(new TableRowProperties(metaDataRowProperties.OuterXml));
                        tc.Append(tcProperties);
                        tc.Append(new Paragraph(new ParagraphProperties(metaDataParagraphProperties.OuterXml), new Run(new RunProperties(metaDataRunProperties.OuterXml), new Text(TEXT_METADATA))));
                        tr.Append(tc);
                        table.Append(tr);
                    }


                    foreach (SchemaField field in schemaData.MetadataFields)
                    {
                        TableRow tr = new TableRow();

                        TableCell tc1 = new TableCell();
                        tc1.Append(new Paragraph(new ParagraphProperties(paragraphPropertiesOuterXml), new Run(new RunProperties(runPropertiesOuterXml), new Text(field.Description))));
                        tr.Append(tc1);

                        TableCell tc2 = new TableCell();
                        tc2.Append(new Paragraph(new ParagraphProperties(paragraphPropertiesOuterXml), new Run(new RunProperties(runPropertiesOuterXml), new Text(field.XmlName))));
                        tr.Append(tc2);

                        TableCell tc3 = new TableCell();
                        tc3.Append(new Paragraph(new ParagraphProperties(paragraphPropertiesOuterXml), new Run(new RunProperties(runPropertiesOuterXml), new Text(field.FieldType))));
                        tr.Append(tc3);

                        TableCell tc4 = new TableCell();
                        tc4.Append(new Paragraph(new ParagraphProperties(paragraphPropertiesOuterXml), new Run(new RunProperties(runPropertiesOuterXml), new Text((field.Required) ? TEXT_YES : TEXT_NO))));
                        tr.Append(tc4);

                        TableCell tc5 = new TableCell();
                        tc5.Append(new Paragraph(new ParagraphProperties(paragraphPropertiesOuterXml), new Run(new RunProperties(runPropertiesOuterXml), new Text((field.MultiValue) ? TEXT_YES : TEXT_NO))));
                        tr.Append(tc5);

                        TableCell tc6 = new TableCell();
                        tc6.Append(new Paragraph(new ParagraphProperties(paragraphPropertiesOuterXml), new Run(new RunProperties(runPropertiesOuterXml), new Text(field.Properties))));
                        tr.Append(tc6);

                        table.Append(tr);
                    }
                }

                binFile = mem.ToArray();
            }

            return(binFile);
        }