//____________________________________________________________________ // /// <summary> /// Apply all the current Html tag to the specified table cell. /// </summary> public override void ApplyTags(OpenXmlCompositeElement tableCell) { if (tags.Count > 0) { TableCellProperties properties = tableCell.GetFirstChild<TableCellProperties>(); if (properties == null) tableCell.PrependChild<TableCellProperties>(properties = new TableCellProperties()); var en = tags.GetEnumerator(); while (en.MoveNext()) { TagsAtSameLevel tagsOfSameLevel = en.Current.Value.Peek(); foreach (OpenXmlElement tag in tagsOfSameLevel.Array) properties.Append(tag.CloneNode(true)); } } // Apply some style attributes on the unique Paragraph tag contained inside a table cell. if (tagsParagraph.Count > 0) { Paragraph p = tableCell.GetFirstChild<Paragraph>(); ParagraphProperties properties = p.GetFirstChild<ParagraphProperties>(); if (properties == null) p.PrependChild<ParagraphProperties>(properties = new ParagraphProperties()); var en = tagsParagraph.GetEnumerator(); while (en.MoveNext()) { TagsAtSameLevel tagsOfSameLevel = en.Current.Value.Peek(); foreach (OpenXmlElement tag in tagsOfSameLevel.Array) properties.Append(tag.CloneNode(true)); } } }
public static Paragraph ApplyStyle(this Paragraph paragrah, string style) { ParagraphProperties properties = new ParagraphProperties(); properties.ParagraphStyleId = new ParagraphStyleId() { Val = style }; paragrah.Append(properties); return paragrah; }
private void ApplyFooter(FooterPart footerPart) { var footer1 = new Footer(); footer1.AddNamespaceDeclaration("ve", "http://schemas.openxmlformats.org/markup-compatibility/2006"); footer1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office"); footer1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); footer1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); footer1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml"); footer1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); footer1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word"); footer1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); footer1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); var paragraph1 = new Paragraph { RsidParagraphAddition = "005641D2", RsidRunAdditionDefault = "005641D2" }; var paragraphProperties1 = new ParagraphProperties(); var paragraphStyleId1 = new ParagraphStyleId { Val = "Footer" }; paragraphProperties1.Append(paragraphStyleId1); var run1 = new Run(); var text1 = new Text(); text1.Text = "Generated with Pickles " + Assembly.GetExecutingAssembly().GetName().Version; run1.Append(text1); paragraph1.Append(paragraphProperties1); paragraph1.Append(run1); footer1.Append(paragraph1); footerPart.Footer = footer1; }
public static void GenerateParagraph(this Body body, string text, string styleId) { var paragraph = new Paragraph { RsidParagraphAddition = "00CC1B7A", RsidParagraphProperties = "0016335E", RsidRunAdditionDefault = "0016335E" }; var paragraphProperties = new ParagraphProperties(); var paragraphStyleId = new ParagraphStyleId {Val = styleId}; paragraphProperties.Append(paragraphStyleId); var run1 = new Run(); var text1 = new Text(); text1.Text = text; run1.Append(text1); paragraph.Append(paragraphProperties); paragraph.Append(run1); body.Append(paragraph); }
/// <summary> /// Returns a OpenXMl paragraph representing formatted listItem. /// </summary> /// <param name="item">listItem object</param> /// <param name="numStyleId">style id to use</param> /// <returns></returns> private static Paragraph GetListItem(Model.ListItem item, int numStyleId) { Paragraph listItemPara = new Paragraph(); ParagraphProperties paraProps = new ParagraphProperties(); NumberingProperties numberingProps = new NumberingProperties(); NumberingLevelReference numberingLevelReference = new NumberingLevelReference() { Val = 0 }; NumberingId numberingId = new NumberingId() { Val = numStyleId }; numberingProps.Append(numberingLevelReference); numberingProps.Append(numberingId); paraProps.Append(numberingProps); Run listRun = new Run(); Text listItemText = new Text() { Text = item.Body }; listRun.Append(listItemText); listItemPara.Append(paraProps); listItemPara.Append(listRun); return listItemPara; }
private static ParagraphProperties GetParagraphProperties(Model.Paragraph paragraph) { ParagraphProperties paraProps = new ParagraphProperties(); SpacingBetweenLines paraSpacing = new SpacingBetweenLines() { Before = Utilities.GetDxaFromPoints(paragraph.SpacingBefore), After = Utilities.GetDxaFromPoints(paragraph.SpacingAfter), LineRule = LineSpacingRuleValues.Auto, //If the value of the lineRule attribute is auto, then the value of the line attribute shall be interpreted as 240ths of a line Line = (paragraph.Leading * 240).ToString() }; Justification justification = new Justification(); switch (paragraph.Justification) { case DocGen.ObjectModel.Justification.Left: justification.Val = JustificationValues.Left; break; case DocGen.ObjectModel.Justification.Center: justification.Val = JustificationValues.Center; break; case DocGen.ObjectModel.Justification.Right: justification.Val = JustificationValues.Right; break; case DocGen.ObjectModel.Justification.Justified: justification.Val = JustificationValues.Both; break; } paraProps.Append(justification); paraProps.Append(paraSpacing); return paraProps; }
public OXMLParagraphFormatWrap(Paragraph paragraph) { if (paragraph.ParagraphProperties == null) paragraph.ParagraphProperties = new ParagraphProperties(); pPr = paragraph.ParagraphProperties; if (pPr.Justification == null) pPr.Justification = new Justification() { Val = JustificationValues.Left }; }
public static void Test_Style_01() { SetDirectory(); string file = "test_Style_01.docx"; Trace.WriteLine("create docx \"{0}\" using OXmlDoc", file); using (WordprocessingDocument doc = WordprocessingDocument.Create(zPath.Combine(_directory, file), WordprocessingDocumentType.Document)) { MainDocumentPart mainPart = doc.AddMainDocumentPart(); mainPart.Document = new Document(); Body body = mainPart.Document.AppendChild(new Body()); //body.AppendChild(Test_OXmlCreator.CreateSectionProperties()); SectionProperties sectionProperties = body.AppendChild(new SectionProperties()); Test_OpenXml_Creator.SetSectionPage(sectionProperties); //SectionProperties sectionProperties = new SectionProperties(); //// PageSize, <w:pgSz w:w="11907" w:h="16839"/>, 11907 1/20 point = 21 cm, 16839 1/20 point = 29.7 cm, unit = 1/20 point, 11907 1/20 point = 595.35 point //sectionProperties.AppendChild(new PageSize { Width = 11907, Height = 16839 }); //// top 1.27 cm, bottom 1.27 cm, left 2.5 cm, right 2.5 cm, header 0.5 cm, footer 0.5 cm //// <w:pgMar w:top="720" w:right="1418" w:bottom="720" w:left="1418" w:header="284" w:footer="284" w:gutter="0"/> //sectionProperties.AppendChild(new PageMargin { Top = 720, Bottom = 720, Left = 1418, Right = 1418, Header = 284, Footer = 284 }); //body.AppendChild(sectionProperties); //Trace.WriteLine("add StyleDefinitionsPart"); Styles styles = Test_OpenXml_Creator.CreateStyles(mainPart); //Trace.WriteLine("create DocDefaults"); styles.DocDefaults = Test_OpenXml_Creator.CreateDocDefaults(); //string tinyParagraphStyleId = Test_OXmlCreator.CreateStyleTinyParagraph(styles); string tinyParagraphStyleId = "TinyParagraph"; styles.Append(Test_OpenXml_Creator.CreateTinyParagraphStyle(tinyParagraphStyleId)); //string styleAliases = "style_01"; //Trace.WriteLine($"create style {styleId}"); //Paragraph paragraph = body.AppendChild(new Paragraph()); //Run run = paragraph.AppendChild(new Run()); //run.RunProperties = new RunProperties(new RunFonts() { Ascii = "Arial" }); //RunProperties runProperties = new RunProperties(new RunFonts() { Ascii = "Arial" }); //Run r = package.MainDocumentPart.Document.Descendants<Run>().First(); //r.PrependChild<RunProperties>(rPr); ParagraphProperties paragraphProperties = new ParagraphProperties(); // ParagraphStyleId, <w:pStyle> paragraphProperties.ParagraphStyleId = new ParagraphStyleId { Val = tinyParagraphStyleId }; //AddText(body); //AddText(body, paragraphProperties); body.Append(Test_OpenXml_Creator.CreateText_01(paragraphProperties)); } }
/// <summary> /// создание параграфа /// </summary> /// <param name="text">null = пустая строка</param> /// <param name="parProp">null = настройки из стиля</param> /// <returns></returns> public void GenerateParagraph(Run run = null, ParagraphProperties parProp = null) { var paragraph = new Paragraph(); parProp = parProp ?? GetParagraphProperties(); paragraph.Append(parProp); if (run != null) { paragraph.Append(run); } _body.Append(paragraph); }
public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart) { var result = new DocumentFormat.OpenXml.Wordprocessing.Paragraph(); var paragraphProperties = new ParagraphProperties(); var numberingProperties = new NumberingProperties(); var numberingLevelReference = new NumberingLevelReference() { Val = 0 }; NumberingId numberingId; ParagraphStyleId paragraphStyleId; if (Parent is OrderedListFormattedElement) { paragraphStyleId = new ParagraphStyleId() { Val = "NumberedList" }; numberingId = new NumberingId() { Val = ((OrderedListFormattedElement)Parent).NumberingInstanceId }; var indentation = new Indentation() { Left = "1440", Hanging = "720" }; paragraphProperties.Append(indentation); } else { paragraphStyleId = new ParagraphStyleId() { Val = "UnorderedListStyle" }; numberingId = new NumberingId() { Val = 3 }; } numberingProperties.Append(numberingLevelReference); numberingProperties.Append(numberingId); var spacingBetweenLines= new SpacingBetweenLines() { After = "100", AfterAutoSpacing = true }; paragraphProperties.Append(paragraphStyleId); paragraphProperties.Append(numberingProperties); paragraphProperties.Append(spacingBetweenLines); result.Append(paragraphProperties); ForEachChild(x => { if (x is TextFormattedElement) { result.Append( new DocumentFormat.OpenXml.Wordprocessing.Run(x.ToOpenXmlElements(mainDocumentPart)) ); } else { result.Append(x.ToOpenXmlElements(mainDocumentPart)); } }); return new List<OpenXmlElement> { result }; }
private void SetListProperties(NumberFormatValues numberFormat, ParagraphProperties paragraphProperties) { ParagraphStyleId paragraphStyleId = new ParagraphStyleId() { Val = "ListParagraph" }; NumberingProperties numberingProperties = new NumberingProperties(); NumberingLevelReference numberingLevelReference = new NumberingLevelReference() { Val = 0 }; NumberingId numberingId = new NumberingId() { Val = ((Int32)numberFormat) + 1 }; numberingProperties.Append(numberingLevelReference); numberingProperties.Append(numberingId); paragraphProperties.Append(paragraphStyleId); paragraphProperties.Append(numberingProperties); }
/// <summary> /// создание параграфа /// </summary> /// <param name="text">список ранов</param> /// <param name="parProp">null = настройки из стиля</param> /// <returns></returns> public void GenerateParagraph(List<Run> runs, ParagraphProperties parProp = null) { var paragraph = new Paragraph(); parProp = parProp ?? GetParagraphProperties(); paragraph.Append(parProp); foreach (var run in runs) { if (run != null) { paragraph.Append(run); } } _body.Append(paragraph); }
static bool IsSectionProps(ParagraphProperties pPr) { SectionProperties sectPr = pPr.GetFirstChild<SectionProperties>(); if (sectPr == null) return false; else return true; }
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; }
/// <summary> /// Apply all the current Html tag (Paragraph properties) to the specified paragrah. /// </summary> public override void ApplyTags(OpenXmlCompositeElement paragraph) { if (tags.Count == 0) return; ParagraphProperties properties = paragraph.GetFirstChild<ParagraphProperties>(); if (properties == null) paragraph.PrependChild<ParagraphProperties>(properties = new ParagraphProperties()); var en = tags.GetEnumerator(); while (en.MoveNext()) { TagsAtSameLevel tagsOfSameLevel = en.Current.Value.Peek(); foreach (OpenXmlElement tag in tagsOfSameLevel.Array) properties.Append(tag.CloneNode(true)); } }
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; }
private void ProcessBorder(DocxNode node, ParagraphProperties properties) { ParagraphBorders paragraphBorders = new ParagraphBorders(); DocxBorder.ApplyBorders(paragraphBorders, node.ExtractStyleValue(DocxBorder.borderName), node.ExtractStyleValue(DocxBorder.leftBorderName), node.ExtractStyleValue(DocxBorder.topBorderName), node.ExtractStyleValue(DocxBorder.rightBorderName), node.ExtractStyleValue(DocxBorder.bottomBorderName), false); if (paragraphBorders.HasChildren) { properties.Append(paragraphBorders); } }
private static void AddHeaderRow(DataTable table, Table wordTable, TableStyle tableStyle) { // Create a row. TableRow tRow = new TableRow(); foreach (DataColumn iColumn in table.Columns) { // Create a cell. TableCell tCell = new TableCell(); TableCellProperties tCellProperties = new TableCellProperties(); // Set Cell Color Shading tCellColor = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = System.Drawing.ColorTranslator.ToHtml(tableStyle.HeaderBackgroundColor) }; tCellProperties.Append(tCellColor); // Append properties to the cell tCell.Append(tCellProperties); ParagraphProperties paragProperties = new ParagraphProperties(); Justification justification1 = new Justification() { Val = JustificationValues.Center }; SpacingBetweenLines spacingBetweenLines1 = new SpacingBetweenLines() { After = "0" }; paragProperties.Append(spacingBetweenLines1); paragProperties.Append(justification1); var parag = new Paragraph(); parag.Append(paragProperties); var run = new Run(new Text(iColumn.ColumnName)); ApplyFontProperties(tableStyle, RowIdentification.Header, run); parag.Append(run); // Specify the table cell content. tCell.Append(parag); // Append the table cell to the table row. tRow.Append(tCell); } // Append the table row to the table. wordTable.Append(tRow); }
// Creates an TableCell instance and adds its children. public static void AddSpacerCell(this TableRow row, string width = "173") { TableCell tableCell1 = new TableCell(); TableCellProperties tableCellProperties1 = new TableCellProperties(); TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = width, Type = TableWidthUnitValues.Dxa }; tableCellProperties1.Append(tableCellWidth1); Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "005A43FA", RsidParagraphProperties = "005A43FA", RsidRunAdditionDefault = "005A43FA" }; ParagraphProperties paragraphProperties1 = new ParagraphProperties(); Indentation indentation1 = new Indentation() { Left = "95", Right = "95" }; paragraphProperties1.Append(indentation1); paragraph1.Append(paragraphProperties1); tableCell1.Append(tableCellProperties1); tableCell1.Append(paragraph1); row.Append(tableCell1); }
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(); }
public static void GenerateHeaderPartContent(HeaderPart part) { Header header1 = new Header() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 wp14" } }; header1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"); header1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); header1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office"); header1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); header1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); header1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml"); header1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"); header1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); header1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word"); header1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); header1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml"); header1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"); header1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk"); header1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); header1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "00164C17", RsidRunAdditionDefault = "00164C17" }; ParagraphProperties paragraphProperties1 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId1 = new ParagraphStyleId() { Val = "Header" }; paragraphProperties1.Append(paragraphStyleId1); Run run1 = new Run(); Text text1 = new Text(); text1.Text = "Header"; run1.Append(text1); paragraph1.Append(paragraphProperties1); paragraph1.Append(run1); header1.Append(paragraph1); part.Header = header1; }
internal void Process(Paragraph element, DocxNode node) { ParagraphProperties properties = element.ParagraphProperties; if (properties == null) { properties = new ParagraphProperties(); } //Order of assigning styles to paragraph property is important. The order should not change. ProcessBorder(node, 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); } DocxMargin margin = new DocxMargin(node); margin.ProcessParagraphMargin(properties); string textAlign = node.ExtractStyleValue(DocxAlignment.textAlign); if (!string.IsNullOrEmpty(textAlign)) { DocxAlignment.ApplyTextAlign(textAlign, properties); } if (element.ParagraphProperties == null && properties.HasChildren) { element.ParagraphProperties = properties; } }
private static void GenerateFooterPartContent(FooterPart part) { var footer1 = new Footer() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 wp14" } }; var paragraph1 = new Paragraph() { RsidParagraphAddition = "00164C17", RsidRunAdditionDefault = "00164C17" }; var paragraphProperties1 = new ParagraphProperties(); var paragraphStyleId1 = new ParagraphStyleId() { Val = "Footer" }; paragraphProperties1.Append(paragraphStyleId1); var run1 = new Run(); var text1 = new Text { Text = "Footer" }; run1.Append(text1); paragraph1.Append(paragraphProperties1); paragraph1.Append(run1); footer1.Append(paragraph1); part.Footer = footer1; }
private static IEnumerable<OpenXmlElement> CreateTopicText(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart, FormattedContent formattedContent) { var formattedContentParagraphs = formattedContent.ToOpenXmlElements(mainDocumentPart); foreach (var para in formattedContentParagraphs) { if (para is Paragraph) { if (((Paragraph)para).ParagraphProperties == null) { ParagraphProperties paragraphProperties22 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId22 = new ParagraphStyleId() { Val = "StyleAfter0pt" }; SpacingBetweenLines spacingBetweenLines16 = new SpacingBetweenLines() { After = "360" }; paragraphProperties22.Append(paragraphStyleId22); paragraphProperties22.Append(spacingBetweenLines16); para.InsertAt(paragraphProperties22, 0); } } } return formattedContentParagraphs; }
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; }
public void DoParagraphBelowTable3(Paragraph paragraph473) { ParagraphProperties paragraphProperties473 = new ParagraphProperties(); ParagraphMarkRunProperties paragraphMarkRunProperties473 = new ParagraphMarkRunProperties(); RunFonts runFonts602 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" }; FontSize fontSize261 = new FontSize() { Val = "18" }; FontSizeComplexScript fontSizeComplexScript259 = new FontSizeComplexScript() { Val = "22" }; paragraphMarkRunProperties473.Append(runFonts602); paragraphMarkRunProperties473.Append(fontSize261); paragraphMarkRunProperties473.Append(fontSizeComplexScript259); paragraphProperties473.Append(paragraphMarkRunProperties473); paragraph473.Append(paragraphProperties473); Paragraph paragraph474 = new Paragraph() { RsidParagraphMarkRevision = "00D10A17", RsidParagraphAddition = "00004340", RsidRunAdditionDefault = "00D53280" }; ParagraphProperties paragraphProperties474 = new ParagraphProperties(); ParagraphMarkRunProperties paragraphMarkRunProperties474 = new ParagraphMarkRunProperties(); RunFonts runFonts603 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" }; FontSize fontSize262 = new FontSize() { Val = "18" }; FontSizeComplexScript fontSizeComplexScript260 = new FontSizeComplexScript() { Val = "22" }; paragraphMarkRunProperties474.Append(runFonts603); paragraphMarkRunProperties474.Append(fontSize262); paragraphMarkRunProperties474.Append(fontSizeComplexScript260); paragraphProperties474.Append(paragraphMarkRunProperties474); Run run131 = new Run() { RsidRunProperties = "00D10A17" }; RunProperties runProperties131 = new RunProperties(); RunFonts runFonts604 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" }; FontSize fontSize263 = new FontSize() { Val = "18" }; FontSizeComplexScript fontSizeComplexScript261 = new FontSizeComplexScript() { Val = "22" }; runProperties131.Append(runFonts604); runProperties131.Append(fontSize263); runProperties131.Append(fontSizeComplexScript261); Text text131 = new Text(); text131.Text = "Note: All required information as per section 5.10.2 of ISO/IEC 17025 is available from the Laboratory Supervisor."; run131.Append(runProperties131); run131.Append(text131); paragraph474.Append(paragraphProperties474); paragraph474.Append(run131); }
private TableCell PrepareCell(string text, int width, bool centre = true, int mergeCount = 0) { var tc = new TableCell(); TableCellProperties props = new TableCellProperties( new TableCellWidth { Width = width.ToString() }, new TableCellMargin( new BottomMargin { Width = "30" }, new TopMargin { Width = "30" }, new LeftMargin { Width = "30" }, new RightMargin { Width = "30" } ), new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center } ); if (mergeCount > 0) { props.Append(new GridSpan { Val = mergeCount }); } ; tc.AppendChild <TableCellProperties>(props); if (centre) { ParagraphProperties pprop = new ParagraphProperties(); Justification CenterHeading = new Justification() { Val = JustificationValues.Center }; pprop.Append(CenterHeading); tc.AppendChild <ParagraphProperties>(pprop); } ; RunProperties runProperties = new RunProperties(); FontSize fs = new FontSize(); fs.Val = "20"; runProperties.AppendChild(fs); Run run = new Run(); run.AppendChild(runProperties); run.AppendChild(new Text(text)); tc.Append(new Paragraph(run)); return(tc); }
// Creates an Body instance and adds its children. public static Body GenerateBody() { Body body1 = new Body(); Paragraph paragraph1 = new Paragraph() { RsidParagraphMarkRevision = "000E101D", RsidParagraphAddition = "00CF6683", RsidParagraphProperties = "00CF6683", RsidRunAdditionDefault = "00CF6683", ParagraphId = "0E6D6057", TextId = "77777777" }; ParagraphProperties paragraphProperties1 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId1 = new ParagraphStyleId() { Val = "Heading1" }; NumberingProperties numberingProperties1 = new NumberingProperties(); NumberingLevelReference numberingLevelReference1 = new NumberingLevelReference() { Val = 0 }; NumberingId numberingId1 = new NumberingId() { Val = 2 }; numberingProperties1.Append(numberingLevelReference1); numberingProperties1.Append(numberingId1); paragraphProperties1.Append(paragraphStyleId1); paragraphProperties1.Append(numberingProperties1); BookmarkStart bookmarkStart1 = new BookmarkStart() { Name = "_Toc128902458", Id = "0" }; Run run1 = new Run(); Break break1 = new Break(); run1.Append(break1); BookmarkEnd bookmarkEnd1 = new BookmarkEnd() { Id = "0" }; Run run2 = new Run(); Text text1 = new Text(); text1.Text = "First"; run2.Append(text1); paragraph1.Append(paragraphProperties1); paragraph1.Append(bookmarkStart1); paragraph1.Append(run1); paragraph1.Append(bookmarkEnd1); paragraph1.Append(run2); Paragraph paragraph2 = new Paragraph() { RsidParagraphMarkRevision = "000E101D", RsidParagraphAddition = "00CF6683", RsidParagraphProperties = "00CF6683", RsidRunAdditionDefault = "00CF6683", ParagraphId = "1515913F", TextId = "77777777" }; ParagraphProperties paragraphProperties2 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId2 = new ParagraphStyleId() { Val = "Heading1" }; NumberingProperties numberingProperties2 = new NumberingProperties(); NumberingLevelReference numberingLevelReference2 = new NumberingLevelReference() { Val = 0 }; NumberingId numberingId2 = new NumberingId() { Val = 2 }; numberingProperties2.Append(numberingLevelReference2); numberingProperties2.Append(numberingId2); paragraphProperties2.Append(paragraphStyleId2); paragraphProperties2.Append(numberingProperties2); BookmarkStart bookmarkStart2 = new BookmarkStart() { Name = "_Toc128902483", Id = "1" }; Run run3 = new Run(); Break break2 = new Break(); Text text2 = new Text(); text2.Text = "SEc"; run3.Append(break2); run3.Append(text2); paragraph2.Append(paragraphProperties2); paragraph2.Append(bookmarkStart2); paragraph2.Append(run3); Paragraph paragraph3 = new Paragraph() { RsidParagraphAddition = "000D0026", RsidParagraphProperties = "000D0026", RsidRunAdditionDefault = "00CF6683", ParagraphId = "3D4C030D", TextId = "707DD937" }; ParagraphProperties paragraphProperties3 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId3 = new ParagraphStyleId() { Val = "Heading1" }; paragraphProperties3.Append(paragraphStyleId3); Run run4 = new Run(); Break break3 = new Break(); run4.Append(break3); BookmarkEnd bookmarkEnd2 = new BookmarkEnd() { Id = "1" }; Run run5 = new Run(); Text text3 = new Text(); text3.Text = "THIRD"; run5.Append(text3); paragraph3.Append(paragraphProperties3); paragraph3.Append(run4); paragraph3.Append(bookmarkEnd2); paragraph3.Append(run5); Paragraph paragraph4 = new Paragraph() { RsidParagraphMarkRevision = "000D0026", RsidParagraphAddition = "000D0026", RsidParagraphProperties = "000D0026", RsidRunAdditionDefault = "000D0026", ParagraphId = "270303F9", TextId = "4BFC761E" }; ParagraphProperties paragraphProperties4 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId4 = new ParagraphStyleId() { Val = "Heading1" }; paragraphProperties4.Append(paragraphStyleId4); Run run6 = new Run(); Break break4 = new Break(); Text text4 = new Text(); text4.Text = "FoURTH"; run6.Append(break4); run6.Append(text4); BookmarkStart bookmarkStart3 = new BookmarkStart() { Name = "_GoBack", Id = "2" }; BookmarkEnd bookmarkEnd3 = new BookmarkEnd() { Id = "2" }; paragraph4.Append(paragraphProperties4); paragraph4.Append(run6); paragraph4.Append(bookmarkStart3); paragraph4.Append(bookmarkEnd3); SectionProperties sectionProperties1 = new SectionProperties() { RsidRPr = "000D0026", RsidR = "000D0026", RsidSect = "00F73F69" }; FooterReference footerReference1 = new FooterReference() { Type = HeaderFooterValues.Even, Id = "rId7" }; FooterReference footerReference2 = new FooterReference() { Type = HeaderFooterValues.Default, Id = "rId8" }; PageSize pageSize1 = new PageSize() { Width = 12240U, Height = 15840U, Code = (UInt16Value)1U }; PageMargin pageMargin1 = new PageMargin() { Top = 1440, Right = 1440U, Bottom = 1440, Left = 1440U, Header = 720U, Footer = 720U, Gutter = 0U }; PageNumberType pageNumberType1 = new PageNumberType() { Start = 1 }; Columns columns1 = new Columns() { Space = "720" }; TitlePage titlePage1 = new TitlePage(); DocGrid docGrid1 = new DocGrid() { LinePitch = 360 }; sectionProperties1.Append(footerReference1); sectionProperties1.Append(footerReference2); sectionProperties1.Append(pageSize1); sectionProperties1.Append(pageMargin1); sectionProperties1.Append(pageNumberType1); sectionProperties1.Append(columns1); sectionProperties1.Append(titlePage1); sectionProperties1.Append(docGrid1); body1.Append(paragraph1); body1.Append(paragraph2); body1.Append(paragraph3); body1.Append(paragraph4); body1.Append(sectionProperties1); return(body1); }
private void InitTextProperties(WordDocHolder docHolder, OpenXmlElement inputCell) { Text = ""; foreach (var p in inputCell.Elements <Paragraph>()) { foreach (var textOrBreak in p.Descendants()) { if (textOrBreak.LocalName == "r" && textOrBreak is Run) { Run r = textOrBreak as Run; RunProperties rProps = r.RunProperties; if (rProps != null) { if (rProps.FontSize != null) { int runFontSize = Int32.Parse(rProps.FontSize.Val); if (runFontSize <= 28) { FontSize = runFontSize; // if font is too large, it is is an ocr error, ignore it } } if (rProps.RunFonts != null) { FontName = rProps.RunFonts.ComplexScript; } } } else if (textOrBreak.LocalName == "t") { Text += textOrBreak.InnerText; } else if (textOrBreak.LocalName == "cr") { Text += "\n"; } else if (textOrBreak.LocalName == "br") /* do not use lastRenderedPageBreak, see MinRes2011 for wrong lastRenderedPageBreak in Семенов || || (textOrBreak.Name == w + "lastRenderedPageBreak") */ { Text += "\n"; } else if (textOrBreak.LocalName == "numPr") { Text += "- "; } } Text += "\n"; ParagraphProperties pPr = p.ParagraphProperties; if (pPr != null) { for (int l = 0; l < AfterLinesCount(pPr.SpacingBetweenLines); ++l) { Text += "\n"; } } } IsEmpty = Text.IsNullOrWhiteSpace(); if (string.IsNullOrEmpty(FontName)) { FontName = docHolder.DefaultFontName; } if (FontSize == 0) { FontSize = docHolder.DefaultFontSize; } }
public ITableCell CreateTableCell(IList <IRun> cellContents, TableCellPropertiesModel cellModel) { if (cellContents == null) { throw new ArgumentNullException("cellContents must not be null"); } if (cellContents.Count == 0) { throw new ArgumentNullException("cellContents must not be an empty list"); } if (cellContents.Any(e => e == null)) { throw new ArgumentNullException("All elements of cellContents must be not null"); } if (cellModel == null) { throw new ArgumentNullException("cellModel must not be null"); } var platformCellTable = PlatformTableCell.New(); if (cellModel != null) { AutoMapper.Mapper.Map(cellModel, platformCellTable.Properties); } TableCell tc = platformCellTable.ContentItem as TableCell; var tableCellProperties = platformCellTable.Properties.ContentItem as TableCellProperties; tableCellProperties.Append(new TableCellVerticalAlignment { Val = (DocumentFormat.OpenXml.Wordprocessing.TableVerticalAlignmentValues)(int) cellModel.TableVerticalAlignementValues }); // Modification de la rotation du texte dans la cellule if (cellModel.TextDirectionValues.HasValue) { tableCellProperties.Append(new TextDirection { Val = cellModel.TextDirectionValues.ToOOxml() }); } Paragraph par = new Paragraph(); ParagraphProperties pr = new ParagraphProperties(); //new SpacingBetweenLines() { After = cellModel.SpacingAfter, Before = cellModel.SpacingBefore, Line = "240" }); if (cellModel.Justification.HasValue) { pr.Append(new Justification() { Val = cellModel.Justification.Value.ToOOxml() }); } if (cellModel.ParagraphSolidarity) { pr.Append(new KeepNext()); } par.Append(pr); for (int i = 0; i < cellContents.Count; i++) { par.Append(cellContents[i].ContentItem as Run); } tc.Append(par); return(new PlatformTableCell(tc)); }
// Creates an Endnotes instance and adds its children. public static Endnotes CreateDefaultEndnotes() { Endnotes endnotes1 = new Endnotes() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 w15 w16se w16cid w16 w16cex wp14" } }; endnotes1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"); endnotes1.AddNamespaceDeclaration("cx", "http://schemas.microsoft.com/office/drawing/2014/chartex"); endnotes1.AddNamespaceDeclaration("cx1", "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex"); endnotes1.AddNamespaceDeclaration("cx2", "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex"); endnotes1.AddNamespaceDeclaration("cx3", "http://schemas.microsoft.com/office/drawing/2016/5/9/chartex"); endnotes1.AddNamespaceDeclaration("cx4", "http://schemas.microsoft.com/office/drawing/2016/5/10/chartex"); endnotes1.AddNamespaceDeclaration("cx5", "http://schemas.microsoft.com/office/drawing/2016/5/11/chartex"); endnotes1.AddNamespaceDeclaration("cx6", "http://schemas.microsoft.com/office/drawing/2016/5/12/chartex"); endnotes1.AddNamespaceDeclaration("cx7", "http://schemas.microsoft.com/office/drawing/2016/5/13/chartex"); endnotes1.AddNamespaceDeclaration("cx8", "http://schemas.microsoft.com/office/drawing/2016/5/14/chartex"); endnotes1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); endnotes1.AddNamespaceDeclaration("aink", "http://schemas.microsoft.com/office/drawing/2016/ink"); endnotes1.AddNamespaceDeclaration("am3d", "http://schemas.microsoft.com/office/drawing/2017/model3d"); endnotes1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office"); endnotes1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); endnotes1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); endnotes1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml"); endnotes1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"); endnotes1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); endnotes1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word"); endnotes1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); endnotes1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml"); endnotes1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2012/wordml"); endnotes1.AddNamespaceDeclaration("w16cex", "http://schemas.microsoft.com/office/word/2018/wordml/cex"); endnotes1.AddNamespaceDeclaration("w16cid", "http://schemas.microsoft.com/office/word/2016/wordml/cid"); endnotes1.AddNamespaceDeclaration("w16", "http://schemas.microsoft.com/office/word/2018/wordml"); endnotes1.AddNamespaceDeclaration("w16se", "http://schemas.microsoft.com/office/word/2015/wordml/symex"); endnotes1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"); endnotes1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk"); endnotes1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); endnotes1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); Endnote endnote1 = new Endnote() { Type = FootnoteEndnoteValues.Separator, Id = -1 }; string rsidAdditionGuid = OfficeHelpers.CreateNewRsid(); string rsidPropsGuid = OfficeHelpers.CreateNewRsid(); Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = rsidAdditionGuid, RsidParagraphProperties = rsidPropsGuid, RsidRunAdditionDefault = rsidAdditionGuid, ParagraphId = OfficeHelpers.CreateNewRsid(), TextId = "77777777" }; ParagraphProperties paragraphProperties1 = new ParagraphProperties(); SpacingBetweenLines spacingBetweenLines1 = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto }; paragraphProperties1.Append(spacingBetweenLines1); Run run1 = new Run(); SeparatorMark separatorMark1 = new SeparatorMark(); run1.Append(separatorMark1); paragraph1.Append(paragraphProperties1); paragraph1.Append(run1); endnote1.Append(paragraph1); Endnote endnote2 = new Endnote() { Type = FootnoteEndnoteValues.ContinuationSeparator, Id = 0 }; Paragraph paragraph2 = new Paragraph() { RsidParagraphAddition = rsidAdditionGuid, RsidParagraphProperties = rsidPropsGuid, RsidRunAdditionDefault = rsidAdditionGuid, ParagraphId = OfficeHelpers.CreateNewRsid(), TextId = "77777777" }; ParagraphProperties paragraphProperties2 = new ParagraphProperties(); SpacingBetweenLines spacingBetweenLines2 = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto }; paragraphProperties2.Append(spacingBetweenLines2); Run run2 = new Run(); ContinuationSeparatorMark continuationSeparatorMark1 = new ContinuationSeparatorMark(); run2.Append(continuationSeparatorMark1); paragraph2.Append(paragraphProperties2); paragraph2.Append(run2); endnote2.Append(paragraph2); endnotes1.Append(endnote1); endnotes1.Append(endnote2); return(endnotes1); }
public Paragraph MakeImageParagraph(string imagePath, string caption) { ImagePart imagePart = this.m_Document.MainDocumentPart.AddImagePart(ImagePartType.Jpeg); int imgWidth = 0; int imgHeight = 0; using (Bitmap bmp = new Bitmap(imagePath)) { imgWidth = bmp.Width * 9525; imgHeight = bmp.Height * 9525; long pageWidth = (int)(this.GetPageWidth() * 635.27); //Pacsiszám de ez jött ki if (imgWidth > pageWidth) { imgHeight = (int)(imgHeight * (pageWidth / (float)imgWidth)); imgWidth = (int)pageWidth; } } using (FileStream stream = new FileStream(imagePath, FileMode.Open)) { imagePart.FeedData(stream); } Drawing element = new Drawing( new DW.Inline( new DW.Extent() { Cx = imgWidth, Cy = imgHeight }, new DW.EffectExtent() { LeftEdge = 0L, TopEdge = 0L, RightEdge = 0L, BottomEdge = 0L }, new DW.DocProperties() { Id = (UInt32Value)1U, Name = caption }, new DW.NonVisualGraphicFrameDrawingProperties( new A.GraphicFrameLocks() { NoChangeAspect = true }), new A.Graphic( new A.GraphicData( new PIC.Picture( new PIC.NonVisualPictureProperties( new PIC.NonVisualDrawingProperties() { Id = (UInt32Value)0U, Name = caption }, new PIC.NonVisualPictureDrawingProperties()), new PIC.BlipFill( new A.Blip(new A.BlipExtensionList(new A.BlipExtension() { Uri = "{28A0092B-C50C-407E-A947-70E740481C1C}" })) { Embed = this.m_Document.MainDocumentPart.GetIdOfPart(imagePart), CompressionState = A.BlipCompressionValues.Print }, new A.Stretch(new A.FillRectangle()) ), new PIC.ShapeProperties ( new A.Transform2D( new A.Offset() { X = 0L, Y = 0L }, new A.Extents() { Cx = imgWidth, Cy = imgHeight }), new A.PresetGeometry(new A.AdjustValueList()) { Preset = A.ShapeTypeValues.Rectangle })) ) { Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" }) ) { DistanceFromTop = (UInt32Value)0U, DistanceFromBottom = (UInt32Value)0U, DistanceFromLeft = (UInt32Value)0U, DistanceFromRight = (UInt32Value)0U, EditId = "50D07946" }); //paragraph properties ParagraphProperties centerProps = new ParagraphProperties(); centerProps.Append(new Justification() { Val = JustificationValues.Center }); RunProperties rp = new RunProperties(new Italic() { Val = new OnOffValue(true) }); return(new Paragraph(new OpenXmlElement[] { centerProps, new Run(element), new Break(), new Run(rp, new Text(caption)), })); }
// 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; }
public void GetChildMcTest() { MCContext mcContext = new MCContext(); ParagraphProperties pPr; Run run1, run2; Paragraph p = new Paragraph( pPr = new ParagraphProperties() { WordWrap = new WordWrap() { Val = true } }, new OpenXmlMiscNode(System.Xml.XmlNodeType.Comment, "<!-- comments -->"), run1 = new Run(new Text("Text 1.")), run2 = new Run(new Text("Text 2."))); var target = p.GetFirstChildMc(mcContext, FileFormatVersions.Office2007); Assert.Same(pPr, target); target = p.GetNextChildMc(target, mcContext, FileFormatVersions.Office2007); Assert.Same(run1, target); target = p.GetNextChildMc(target, mcContext, FileFormatVersions.Office2007); Assert.Same(run2, target); OpenXmlUnknownElement ignorableElement = new OpenXmlUnknownElement("w14test", "span", "http://w14.com"); p.AddNamespaceDeclaration("w14test", "http://w14.com"); ignorableElement.MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14test" }; p.InsertAfter(ignorableElement, pPr); mcContext = new MCContext(); target = p.GetFirstChildMc(mcContext, FileFormatVersions.Office2007); Assert.Same(pPr, target); target = p.GetNextChildMc(target, mcContext, FileFormatVersions.Office2007); Assert.Same(run1, target); target = p.GetNextChildMc(target, mcContext, FileFormatVersions.Office2007); Assert.Same(run2, target); Run runInAcb = new Run(new Text("Text in ACB.")); AlternateContent acb = new AlternateContent( new AlternateContentChoice() { Requires = "w14test" }, new AlternateContentFallback(runInAcb)); p.InsertAfter(acb, pPr); mcContext = new MCContext(); target = p.GetFirstChildMc(mcContext, FileFormatVersions.Office2007); Assert.Same(pPr, target); target = p.GetNextChildMc(target, mcContext, FileFormatVersions.Office2007); Assert.Same(runInAcb, target); target = p.GetNextChildMc(target, mcContext, FileFormatVersions.Office2007); Assert.Same(run1, target); target = p.GetNextChildMc(target, mcContext, FileFormatVersions.Office2007); Assert.Same(run2, target); }
public 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); }
/** * Performs an operation on a ParagraphProperties object. Used to uncompress * from a papx. * * @param newPAP The ParagraphProperties object to perform the operation on. * @param operand The operand that defines the operation. * @param param The operation's parameter. * @param varParam The operation's variable length parameter. * @param grpprl The original papx. * @param offset The current offset in the papx. * @param spra A part of the sprm that defined this operation. */ static void UncompressPAPOperation(ParagraphProperties newPAP, SprmOperation sprm) { switch (sprm.Operation) { case 0: newPAP.SetIstd(sprm.Operand); break; case 0x1: // Used only for piece table grpprl's not for PAPX // int istdFirst = LittleEndian.Getshort (varParam, 2); // int istdLast = LittleEndian.Getshort (varParam, 4); // if ((newPAP.GetIstd () > istdFirst) || (newPAP.GetIstd () <= istdLast)) // { // permuteIstd (newPAP, varParam, opSize); // } break; case 0x2: if (newPAP.GetIstd() <= 9 || newPAP.GetIstd() >= 1) { byte paramTmp = (byte)sprm.Operand; newPAP.SetIstd(newPAP.GetIstd() + paramTmp); newPAP.SetLvl((byte)(newPAP.GetLvl() + paramTmp)); if (((paramTmp >> 7) & 0x01) == 1) { newPAP.SetIstd(Math.Max(newPAP.GetIstd(), 1)); } else { newPAP.SetIstd(Math.Min(newPAP.GetIstd(), 9)); } } break; case 0x3: // Physical justification of the paragraph newPAP.SetJc((byte)sprm.Operand); break; case 0x4: newPAP.SetFSideBySide(sprm.Operand != 0); break; case 0x5: newPAP.SetFKeep(sprm.Operand != 0); break; case 0x6: newPAP.SetFKeepFollow(sprm.Operand != 0); break; case 0x7: newPAP.SetFPageBreakBefore(sprm.Operand != 0); break; case 0x8: newPAP.SetBrcl((byte)sprm.Operand); break; case 0x9: newPAP.SetBrcp((byte)sprm.Operand); break; case 0xa: newPAP.SetIlvl((byte)sprm.Operand); break; case 0xb: newPAP.SetIlfo(sprm.Operand); break; case 0xc: newPAP.SetFNoLnn(sprm.Operand != 0); break; case 0xd: /**handle tabs . variable parameter. seperate Processing needed*/ handleTabs(newPAP, sprm); break; case 0xe: newPAP.SetDxaRight(sprm.Operand); break; case 0xf: newPAP.SetDxaLeft(sprm.Operand); break; case 0x10: // sprmPNest is only stored in grpprls linked to a piece table. newPAP.SetDxaLeft(newPAP.GetDxaLeft() + sprm.Operand); newPAP.SetDxaLeft(Math.Max(0, newPAP.GetDxaLeft())); break; case 0x11: newPAP.SetDxaLeft1(sprm.Operand); break; case 0x12: newPAP.SetLspd(new LineSpacingDescriptor(sprm.Grpprl, sprm.GrpprlOffset)); break; case 0x13: newPAP.SetDyaBefore(sprm.Operand); break; case 0x14: newPAP.SetDyaAfter(sprm.Operand); break; case 0x15: // fast saved only //ApplySprmPChgTabs (newPAP, varParam, opSize); break; case 0x16: newPAP.SetFInTable(sprm.Operand != 0); break; case 0x17: newPAP.SetFTtp(sprm.Operand != 0); break; case 0x18: newPAP.SetDxaAbs(sprm.Operand); break; case 0x19: newPAP.SetDyaAbs(sprm.Operand); break; case 0x1a: newPAP.SetDxaWidth(sprm.Operand); break; case 0x1b: byte param = (byte)sprm.Operand; /** @todo handle paragraph postioning*/ byte pcVert = (byte)((param & 0x0c) >> 2); byte pcHorz = (byte)(param & 0x03); if (pcVert != 3) { newPAP.SetPcVert(pcVert); } if (pcHorz != 3) { newPAP.SetPcHorz(pcHorz); } break; // BrcXXX1 is older Version. Brc is used case 0x1c: //newPAP.SetBrcTop1((short)param); break; case 0x1d: //newPAP.SetBrcLeft1((short)param); break; case 0x1e: //newPAP.SetBrcBottom1((short)param); break; case 0x1f: //newPAP.SetBrcRight1((short)param); break; case 0x20: //newPAP.SetBrcBetween1((short)param); break; case 0x21: //newPAP.SetBrcBar1((byte)param); break; case 0x22: newPAP.SetDxaFromText(sprm.Operand); break; case 0x23: newPAP.SetWr((byte)sprm.Operand); break; case 0x24: newPAP.SetBrcTop(new BorderCode(sprm.Grpprl, sprm.GrpprlOffset)); break; case 0x25: newPAP.SetBrcLeft(new BorderCode(sprm.Grpprl, sprm.GrpprlOffset)); break; case 0x26: newPAP.SetBrcBottom(new BorderCode(sprm.Grpprl, sprm.GrpprlOffset)); break; case 0x27: newPAP.SetBrcRight(new BorderCode(sprm.Grpprl, sprm.GrpprlOffset)); break; case 0x28: newPAP.SetBrcBetween(new BorderCode(sprm.Grpprl, sprm.GrpprlOffset)); break; case 0x29: newPAP.SetBrcBar(new BorderCode(sprm.Grpprl, sprm.GrpprlOffset)); break; case 0x2a: newPAP.SetFNoAutoHyph(sprm.Operand != 0); break; case 0x2b: newPAP.SetDyaHeight(sprm.Operand); break; case 0x2c: newPAP.SetDcs(new DropCapSpecifier((short)sprm.Operand)); break; case 0x2d: newPAP.SetShd(new ShadingDescriptor((short)sprm.Operand)); break; case 0x2e: newPAP.SetDyaFromText(sprm.Operand); break; case 0x2f: newPAP.SetDxaFromText(sprm.Operand); break; case 0x30: newPAP.SetFLocked(sprm.Operand != 0); break; case 0x31: newPAP.SetFWidowControl(sprm.Operand != 0); break; case 0x32: //undocumented break; case 0x33: newPAP.SetFKinsoku(sprm.Operand != 0); break; case 0x34: newPAP.SetFWordWrap(sprm.Operand != 0); break; case 0x35: newPAP.SetFOverflowPunct(sprm.Operand != 0); break; case 0x36: newPAP.SetFTopLinePunct(sprm.Operand != 0); break; case 0x37: newPAP.SetFAutoSpaceDE(sprm.Operand != 0); break; case 0x38: newPAP.SetFAutoSpaceDN(sprm.Operand != 0); break; case 0x39: newPAP.SetWAlignFont(sprm.Operand); break; case 0x3a: newPAP.SetFontAlign((short)sprm.Operand); break; case 0x3b: //obsolete break; case 0x3e: byte[] buf = new byte[sprm.Size - 3]; Array.Copy(buf, 0, sprm.Grpprl, sprm.GrpprlOffset, buf.Length); newPAP.SetAnld(buf); break; case 0x3f: //don't really need this. spec is confusing regarding this //sprm byte[] varParam = sprm.Grpprl; int offset = sprm.GrpprlOffset; newPAP.SetFPropRMark(varParam[offset] != 0); newPAP.SetIbstPropRMark(LittleEndian.GetShort(varParam, offset + 1)); newPAP.SetDttmPropRMark(new DateAndTime(varParam, offset + 3)); break; case 0x40: // This condition commented out, as Word seems to set outline levels even for // paragraph with other styles than Heading 1..9, even though specification // does not say so. See bug 49820 for discussion. //if (newPAP.GetIstd () < 1 && newPAP.GetIstd () > 9) //{ newPAP.SetLvl((byte)sprm.Operand); //} break; case 0x41: // undocumented break; case 0x43: //pap.fNumRMIns newPAP.SetFNumRMIns(sprm.Operand != 0); break; case 0x44: //undocumented break; case 0x45: if (sprm.SizeCode == 6) { byte[] buf1 = new byte[sprm.Size - 3]; Array.Copy(buf1, 0, sprm.Grpprl, sprm.GrpprlOffset, buf1.Length); newPAP.SetNumrm(buf1); } else { /**@todo handle large PAPX from data stream*/ } break; case 0x47: newPAP.SetFUsePgsuSettings(sprm.Operand != 0); break; case 0x48: newPAP.SetFAdjustRight(sprm.Operand != 0); break; case 0x49: // sprmPItap -- 0x6649 newPAP.SetItap(sprm.Operand); break; case 0x4a: // sprmPDtap -- 0x664a newPAP.SetItap((byte)(newPAP.GetItap() + sprm.Operand)); break; case 0x4b: // sprmPFInnerTableCell -- 0x244b newPAP.SetFInnerTableCell(sprm.Operand != 0); break; case 0x4c: // sprmPFInnerTtp -- 0x244c newPAP.SetFTtpEmbedded(sprm.Operand != 0); break; case 0x61: // sprmPJc newPAP.SetJustificationLogical((byte)sprm.Operand); break; default: break; } }
public static List <Paragraph> GetBulletList(WordprocessingDocument doc, List <Tuple <string, int> > list) { var items = new List <Paragraph>(); var numberingPart = GetOrCreateNumberingDefinitionsPart(doc); // Insert an AbstractNum into the numbering part numbering list. The order seems to matter or it will not pass the // Open XML SDK Productity Tools validation test. AbstractNum comes first and then NumberingInstance and we want to // insert this AFTER the last AbstractNum and BEFORE the first NumberingInstance or we will get a validation error. var abstractNumberId = numberingPart.Numbering.Elements <AbstractNum>().Count() + 1; var abstractLevel1 = new Level(new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "·" }) { LevelIndex = 0 }; var abstractLevel2 = new Level(new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "o" }) { LevelIndex = 1 }; var abstractLevel3 = new Level(new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "·" }) { LevelIndex = 2 }; var abstractLevel4 = new Level(new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "o" }) { LevelIndex = 3 }; var ml = new MultiLevelType() { Val = MultiLevelValues.HybridMultilevel }; var abstractNum1 = new AbstractNum(ml) { AbstractNumberId = abstractNumberId }; abstractNum1.Append(abstractLevel1); abstractNum1.Append(abstractLevel2); abstractNum1.Append(abstractLevel3); abstractNum1.Append(abstractLevel4); if (abstractNumberId == 1) { numberingPart.Numbering.Append(abstractNum1); } else { AbstractNum lastAbstractNum = numberingPart.Numbering.Elements <AbstractNum>().Last(); numberingPart.Numbering.InsertAfter(abstractNum1, lastAbstractNum); } // Insert an NumberingInstance into the numbering part numbering list. The order seems to matter or it will not pass the // Open XML SDK Productity Tools validation test. AbstractNum comes first and then NumberingInstance and we want to // insert this AFTER the last NumberingInstance and AFTER all the AbstractNum entries or we will get a validation error. var numberId = numberingPart.Numbering.Elements <NumberingInstance>().Count() + 1; NumberingInstance numberingInstance1 = new NumberingInstance() { NumberID = numberId }; AbstractNumId abstractNumId1 = new AbstractNumId() { Val = abstractNumberId }; numberingInstance1.Append(abstractNumId1); if (numberId == 1) { numberingPart.Numbering.Append(numberingInstance1); } else { var lastNumberingInstance = numberingPart.Numbering.Elements <NumberingInstance>().Last(); numberingPart.Numbering.InsertAfter(numberingInstance1, lastNumberingInstance); } Body body = doc.MainDocumentPart.Document.Body; foreach (var item in list) { // Create items for paragraph properties var numberingProperties = new NumberingProperties(new NumberingLevelReference() { Val = item.Item2 }, new NumberingId() { Val = numberId }); var spacingBetweenLines1 = new SpacingBetweenLines() { After = "0" }; // Get rid of space between bullets var indentation = new Indentation() { Left = (720 + 360 * item.Item2).ToString(), Hanging = (360).ToString(), }; // correct indentation ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties(); if (item.Item2 % 2 == 0) { RunFonts runFonts1 = new RunFonts() { Ascii = "Symbol", HighAnsi = "Symbol" }; paragraphMarkRunProperties1.Append(runFonts1); } else { RunFonts runFonts1 = new RunFonts() { Ascii = "Courier New", HighAnsi = "Courier New" }; paragraphMarkRunProperties1.Append(runFonts1); } // create paragraph properties var paragraphProperties = new ParagraphProperties(numberingProperties, spacingBetweenLines1, indentation, paragraphMarkRunProperties1); // Create paragraph var newPara = new Paragraph(paragraphProperties); // Add run to the paragraph newPara.AppendChild(new Run(new Text(item.Item1))); // Add one bullet item to the body items.Add(newPara); } return(items); }
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(); } }
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; }
private static Paragraph TitleParagraphStyle(string texto) { // <w:p w14:paraId="2F58E943" // w14:textId="77777777" // w:rsidR="00F653E2" // w:rsidRPr="00CE2347" // w:rsidRDefault="006B06AF"> // <w:pPr> // <w:pStyle w:val="titulocp11craya"/> // <w:divId w:val="1202479076"/> // <w:rPr> // <w:rFonts w:cs="Arial"/> // <w:lang w:val="es-ES"/> // </w:rPr> // </w:pPr> // <w:r w:rsidRPr="00CE2347"> // <w:rPr> // <w:rFonts w:cs="Arial"/> // <w:lang w:val="es-ES"/> // </w:rPr> // <w:t>INSCRIPCIÓN</w:t> // </w:r> //</w:p> Paragraph p = new Paragraph(); ParagraphProperties pp = new ParagraphProperties(); ParagraphStyleId ps = new ParagraphStyleId() { Val = "titulocp11craya" }; pp.Append(ps); ParagraphMarkRunProperties prpr = new ParagraphMarkRunProperties(); RunFonts prf = new RunFonts() { ComplexScript = "Arial" }; Languages pLang = new Languages() { Val = "es-ES" }; prpr.Append(prf); prpr.Append(pLang); pp.Append(prpr); p.Append(pp); Run r = new Run(); RunProperties rpr = new RunProperties(); RunFonts rFonts = new RunFonts() { ComplexScript = "Arial" }; Languages lang = new Languages() { Val = "es-ES" }; rpr.Append(rFonts); rpr.Append(lang); r.Append(rpr); Text text = new Text() { Text = texto }; r.Append(text); p.Append(r); return(p); }
private static List <OpenXmlElement> TextParagraphStyle(string texto) { // <w:p w14:paraId="2F58E944" // w14:textId="77777777" // w:rsidR="00F653E2" // w:rsidRPr="00CE2347" // w:rsidRDefault="006B06AF"> // <w:pPr> // <w:pStyle w:val="sangrianovedades"/> // <w:divId w:val="1202479076"/> // <w:rPr> // <w:rFonts w:cs="Arial"/> // <w:lang w:val="es-ES"/> // </w:rPr> // </w:pPr> // <w:r w:rsidRPr="00CE2347"> // <w:rPr> // <w:rFonts w:cs="Arial"/> // <w:lang w:val="es-ES"/> // </w:rPr> // <w:t>La administración de consorcios no puede ejercerse a título oneroso ni gratuito sin la previa inscripción en el Registro Público de Administradores de Consorcios de Propiedad Horizontal.</w:t> // </w:r> //</w:p> List <OpenXmlElement> parrafos = new List <OpenXmlElement>(); foreach (string linea in texto.Split('\r')) { Paragraph p = new Paragraph(); ParagraphProperties pp = new ParagraphProperties(); ParagraphStyleId ps = new ParagraphStyleId() { Val = "sangrianovedades" }; pp.Append(ps); ParagraphMarkRunProperties prpr = new ParagraphMarkRunProperties(); RunFonts prf = new RunFonts() { ComplexScript = "Arial" }; Languages pLang = new Languages() { Val = "es-ES" }; prpr.Append(prf); prpr.Append(pLang); pp.Append(prpr); p.Append(pp); Run r = new Run(); RunProperties rpr = new RunProperties(); RunFonts rFonts = new RunFonts() { ComplexScript = "Arial" }; Languages lang = new Languages() { Val = "es-ES" }; rpr.Append(rFonts); rpr.Append(lang); r.Append(rpr); Text text = new Text() { Text = linea }; r.Append(text); p.Append(r); parrafos.Add(p); } return(parrafos); }
private static Footer GetFooter() { // <w:ftr mc:Ignorable="w14 wp14" // <w:p w14:paraId="2F58EA34" // w14:textId="77777777" // w:rsidR="006B06AF" // w:rsidRPr="006B06AF" // w:rsidRDefault="006B06AF" // w:rsidP="006B06AF"> // <w:pPr> // <w:pStyle w:val="Piedepgina"/> // <w:pBdr> // <w:top w:val="single" // w:sz="4" // w:space="1" // w:color="auto"/> // </w:pBdr> // <w:jc w:val="right"/> // <w:rPr> // <w:rFonts w:ascii="Verdana" // w:hAnsi="Verdana"/> // <w:color w:val="000000"/> // <w:sz w:val="18"/> // </w:rPr> // </w:pPr> // <w:r> // <w:rPr> // <w:rFonts w:ascii="Verdana" // w:hAnsi="Verdana"/> // <w:color w:val="000000"/> // <w:sz w:val="18"/> // </w:rPr> // <w:t>Editorial Errepar</w:t> // </w:r> // </w:p> //</w:ftr> Footer f = new Footer(); Paragraph p = new Paragraph(); ParagraphProperties pp = new ParagraphProperties(); ParagraphStyleId pStyle = new ParagraphStyleId() { Val = "Piedepagina" }; TopBorder tb = new TopBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 4, Space = 1, Color = "auto" }; ParagraphBorders pb = new ParagraphBorders { TopBorder = tb }; pp.Append(pStyle, pb); Justification jc = new Justification() { Val = new EnumValue <JustificationValues>(JustificationValues.Right) }; pp.Append(jc); ParagraphMarkRunProperties prpr = new ParagraphMarkRunProperties(); RunFonts prf = new RunFonts() { Ascii = "Verdana", HighAnsi = "Verdana" }; Color pc = new Color() { Val = "000000" }; FontSize psz = new FontSize() { Val = "18" }; prpr.Append(prf, pc, psz); pp.Append(prpr); Run r = new Run(); RunProperties rp = new RunProperties(); RunFonts rf = new RunFonts() { Ascii = "Verdana", HighAnsi = "Verdana" }; Color c = new Color() { Val = "000000" }; FontSize sz = new FontSize() { Val = "18" }; rp.Append(rf, c, sz); r.Append(rp); Text text = new Text() { Text = "Editorial Errepar" }; r.Append(text); p.Append(pp, r); f.Append(p); return(f); }
private void AppendDataTable(Document document, DataTable dataTable) { int dataTableRows = dataTable.Rows.Count; int dataTableColumns = dataTable.Columns.Count; List <string> columnsToDisplay = new List <string>(); for (int i = 0; i < dataTableColumns; i++) { string name = dataTable.Columns[i].ColumnName; // Skip PrimaryKey columns if (!name.ToUpper().EndsWith("ID")) { columnsToDisplay.Add(name); } } document.BeginUpdate(); Table table = document.Tables.Create(document.Range.End, dataTableRows + 1, columnsToDisplay.Count, AutoFitBehaviorType.AutoFitToWindow); table.TableLayout = TableLayoutType.Fixed; table.Borders.InsideHorizontalBorder.LineColor = Color.DarkBlue; table.Borders.InsideVerticalBorder.LineColor = Color.DarkBlue; table.Borders.InsideHorizontalBorder.LineThickness = 0.5f; table.Borders.InsideHorizontalBorder.LineStyle = TableBorderLineStyle.Single; table.Borders.InsideVerticalBorder.LineThickness = 0.5f; table.Borders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.Single; table.LeftPadding = Units.InchesToDocumentsF(0.01f); table.FirstRow.Height = Units.InchesToDocumentsF(0.5f); table.FirstRow.HeightType = HeightType.Exact; ParagraphProperties pp = document.BeginUpdateParagraphs(table.FirstRow.Range); pp.Alignment = ParagraphAlignment.Center; document.EndUpdateParagraphs(pp); CharacterProperties cp = document.BeginUpdateCharacters(table.FirstRow.Range); cp.FontName = "Courier New"; cp.ForeColor = Color.White; document.EndUpdateCharacters(cp); for (int i = 0; i < table.FirstRow.Cells.Count; i++) { table.FirstRow.Cells[i].BackgroundColor = Color.DarkBlue; table.FirstRow.Cells[i].VerticalAlignment = TableCellVerticalAlignment.Center; } // Fill table header with column names for (int i = 0; i < columnsToDisplay.Count; i++) { document.InsertText(table[0, i].Range.Start, columnsToDisplay[i]); } // Fill table body with data table.ForEachCell(delegate(TableCell cell, int rowIndex, int cellIndex) { if (rowIndex > 0) { document.InsertText(cell.Range.Start, dataTable.Rows[rowIndex - 1][columnsToDisplay[cellIndex]].ToString()); } }); document.EndUpdate(); }
public CssClass RegisterParagraph( ParagraphProperties inlineProps, (int, int)?numbering = null)
public ActionResult MakeReport() { using (var stream = new MemoryStream()) { using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(stream, WordprocessingDocumentType.Document, true)) { MainDocumentPart mainPart = wordDocument.AddMainDocumentPart(); mainPart.Document = new Document(); Body body = mainPart.Document.AppendChild(new Body()); { ParagraphProperties pp = new ParagraphProperties(); Justification j1 = new Justification() { Val = JustificationValues.Center }; pp.Append(j1); Paragraph title = body.AppendChild(new Paragraph(pp)); title.Append(new Run(new Text("Звіт"))); Paragraph par = body.AppendChild(new Paragraph()); par.Append(new Run(new Text($"Звіт створено: {DateTime.UtcNow.ToLongDateString()} {DateTime.UtcNow.ToShortTimeString()} (UTC+0)"))); par = body.AppendChild(new Paragraph()); //par.Append(new Run(new Break())); } { List <Tuple <string, string> > amounts = new List <Tuple <string, string> >(); amounts.Add(new Tuple <string, string>("Виконавці", $"{_context.Artists.Count()}")); amounts.Add(new Tuple <string, string>("Виконавці / Жанри", $"{_context.ArtistsGenres.Count()}")); amounts.Add(new Tuple <string, string>("Міста", $"{_context.Cities.Count()}")); amounts.Add(new Tuple <string, string>("Клієнти", $"{_context.Clients.Count()}")); amounts.Add(new Tuple <string, string>("Концерти", $"{_context.Concerts.Count()}")); amounts.Add(new Tuple <string, string>("Концерти / Виконавці", $"{_context.ConcertsArtists.Count()}")); amounts.Add(new Tuple <string, string>("Країни", $"{_context.Countries.Count()}")); amounts.Add(new Tuple <string, string>("Жанри", $"{_context.Genres.Count()}")); amounts.Add(new Tuple <string, string>("Місця", $"{_context.Locations.Count()}")); amounts.Add(new Tuple <string, string>("Сектори", $"{_context.Sectors.Count()}")); amounts.Add(new Tuple <string, string>("Квитки", $"{_context.Tickets.Count()}")); Paragraph t = body.AppendChild(new Paragraph()); t.Append(new Run(new Text("Кількість записів в БД:"))); foreach (Tuple <string, string> amount in amounts) { Paragraph par = body.AppendChild(new Paragraph()); par.ParagraphProperties = new ParagraphProperties(new Tabs(new TabStop() { Val = TabStopValues.Right, Position = 9000, Leader = TabStopLeaderCharValues.Dot })); par.Append(new Run(new Text(amount.Item1))); par.Append(new Run(new TabChar())); par.Append(new Run(new Text(amount.Item2))); } } { Paragraph par = body.AppendChild(new Paragraph()); decimal sum = 0; var t = _context.Tickets.Include(t => t.Sector); foreach (Tickets ticket in t) { sum += ticket.Sector.Price; } par = body.AppendChild(new Paragraph()); par.Append(new Run(new Text($"Загальна вартість квитків - {sum.ToString("F2")} грн"))); par = body.AppendChild(new Paragraph()); par.Append(new Run(new Text($"Середня вартість квитка - {(sum/(decimal)_context.Tickets.Count()).ToString("F2")} грн"))); if (_context.Concerts.Count() > 0) { int maxTickets = 0; Concerts maxConcert = null; foreach (Concerts c in _context.Concerts) { int count = _context.Tickets.Count(t => t.Sector.ConcertId == c.Id); if (count > maxTickets) { maxTickets = count; maxConcert = c; } } par = body.AppendChild(new Paragraph()); par.Append(new Run(new Text($"Найпопулярніший концерт - {maxConcert.Name} (Квитки: {maxTickets})"))); } } mainPart.Document.Save(); wordDocument.Close(); stream.Flush(); return(new FileContentResult(stream.ToArray(), "application/vnd.openxmlformats-officedocument.wordprocessingml.document") { FileDownloadName = $"report_{DateTime.UtcNow.ToShortDateString()}.docx" }); } } }
private SdtBlock GetTableOfContents() { SdtBlock tableOfContents = new SdtBlock(); RunProperties tocRpr = new RunProperties(new RunFonts() { HighAnsi = renderData.RenderSettings.FontFamily }, new Color() { Val = "auto" }, new FontSize() { Val = renderData.RenderSettings.DefaultTextSize }); SdtContentDocPartObject sdtContentDocPartObject = new SdtContentDocPartObject( new DocPartGallery() { Val = "Table of Contents" }, new DocPartUnique()); SdtProperties sdtProperties = new SdtProperties(tocRpr, sdtContentDocPartObject); tableOfContents.Append(sdtProperties); tableOfContents.Append(new SdtEndCharProperties()); SdtContentBlock sdtContentBlock = new SdtContentBlock(); WordParagraph p = new WordParagraph(); ParagraphProperties ppr = new ParagraphProperties() { Justification = new Justification() { Val = JustificationValues.Center } }; p.Append(ppr); RunProperties rpr = new RunProperties(new RunFonts() { Ascii = renderData.RenderSettings.FontFamily, HighAnsi = renderData.RenderSettings.FontFamily }) { Bold = new Bold(), Caps = new Caps(), FontSize = new FontSize() { Val = renderData.RenderSettings.DefaultTextSize } }; Run run = new Run(); run.Append(rpr); Text text = new Text("Содержание"); run.Append(text); p.Append(run); sdtContentBlock.Append(p); string index = "0"; foreach (DocumentElementRenderDto element in renderData.Document.Elements) { index = (int.Parse(index) + 1).ToString(); UploadItemsToTableOfContents(element, sdtContentBlock, 0, index); } tableOfContents.Append(sdtContentBlock); return(tableOfContents); }
private void ValidatePpr(SdbSchemaDatas sdbSchemaDatas) { ValidationContext validationContext = new ValidationContext(); ValidationResult actual = new ValidationResult(); validationContext.ValidationErrorEventHandler += actual.OnValidationError; OpenXmlElement errorChild; ParagraphProperties pPr = new ParagraphProperties(); var particleConstraint = sdbSchemaDatas.GetSchemaTypeData(pPr).ParticleConstraint; var target = particleConstraint.ParticleValidator as ParticleValidator; validationContext.Element = pPr; var expected = pPr; //<xsd:complexType name="CT_PPr"> // <xsd:complexContent> // <xsd:extension base="CT_PPrBase"> // <xsd:sequence> // <xsd:element name="rPr" type="CT_ParaRPr" minOccurs="0"> // <xsd:element name="sectPr" type="CT_SectPr" minOccurs="0"> // <xsd:element name="pPrChange" type="CT_PPrChange" minOccurs="0"> // </xsd:sequence> // </xsd:extension> // </xsd:complexContent> //</xsd:complexType> //<xsd:complexType name="CT_PPrBase"> // <xsd:sequence> // <xsd:element name="pStyle" type="CT_String" minOccurs="0"> // <xsd:element name="keepNext" type="CT_OnOff" minOccurs="0"> // <xsd:element name="keepLines" type="CT_OnOff" minOccurs="0"> // <xsd:element name="pageBreakBefore" type="CT_OnOff" minOccurs="0"> // <xsd:element name="framePr" type="CT_FramePr" minOccurs="0"> // <xsd:element name="widowControl" type="CT_OnOff" minOccurs="0"> // <xsd:element name="numPr" type="CT_NumPr" minOccurs="0"> // <xsd:element name="suppressLineNumbers" type="CT_OnOff" minOccurs="0"> // <xsd:element name="pBdr" type="CT_PBdr" minOccurs="0"> // <xsd:element name="shd" type="CT_Shd" minOccurs="0"> // <xsd:element name="tabs" type="CT_Tabs" minOccurs="0"> // <xsd:element name="suppressAutoHyphens" type="CT_OnOff" minOccurs="0"> // <xsd:element name="kinsoku" type="CT_OnOff" minOccurs="0"> // <xsd:element name="wordWrap" type="CT_OnOff" minOccurs="0"> // <xsd:element name="overflowPunct" type="CT_OnOff" minOccurs="0"> // <xsd:element name="topLinePunct" type="CT_OnOff" minOccurs="0"> // <xsd:element name="autoSpaceDE" type="CT_OnOff" minOccurs="0"> // <xsd:element name="autoSpaceDN" type="CT_OnOff" minOccurs="0"> // <xsd:element name="bidi" type="CT_OnOff" minOccurs="0"> // <xsd:element name="adjustRightInd" type="CT_OnOff" minOccurs="0"> // <xsd:element name="snapToGrid" type="CT_OnOff" minOccurs="0"> // <xsd:element name="spacing" type="CT_Spacing" minOccurs="0"> // <xsd:element name="ind" type="CT_Ind" minOccurs="0"> // <xsd:element name="contextualSpacing" type="CT_OnOff" minOccurs="0"> // <xsd:element name="mirrorIndents" type="CT_OnOff" minOccurs="0"> // <xsd:element name="suppressOverlap" type="CT_OnOff" minOccurs="0"> // <xsd:element name="jc" type="CT_Jc" minOccurs="0"> // <xsd:element name="textDirection" type="CT_TextDirection" minOccurs="0"> // <xsd:element name="textAlignment" type="CT_TextAlignment" minOccurs="0"> // <xsd:element name="textboxTightWrap" type="CT_TextboxTightWrap" minOccurs="0"> // <xsd:element name="outlineLvl" type="CT_DecimalNumber" minOccurs="0"> // <xsd:element name="divId" type="CT_DecimalNumber" minOccurs="0"> // <xsd:element name="cnfStyle" type="CT_Cnf" minOccurs="0" maxOccurs="1"> // </xsd:sequence> //</xsd:complexType> // ***** good case ****** // empty is ok target.Validate(validationContext); Assert.True(actual.Valid); // pPr.AppendChild(new KeepLines()); target.Validate(validationContext); Assert.True(actual.Valid); // pPr.AppendChild(new Tabs()); target.Validate(validationContext); Assert.True(actual.Valid); // pPr.AppendChild(new Kinsoku()); target.Validate(validationContext); Assert.True(actual.Valid); // pPr.AppendChild(new OutlineLevel()); target.Validate(validationContext); Assert.True(actual.Valid); // pPr.AppendChild(new ConditionalFormatStyle()); target.Validate(validationContext); Assert.True(actual.Valid); // pPr.AppendChild(new ParagraphMarkRunProperties()); target.Validate(validationContext); Assert.True(actual.Valid); // pPr.AppendChild(new SectionProperties()); target.Validate(validationContext); Assert.True(actual.Valid); // pPr.AppendChild(new ParagraphPropertiesChange()); target.Validate(validationContext); Assert.True(actual.Valid); // ***** error case ****** // SectionProperties dup error errorChild = pPr.AppendChild(new SectionProperties()); target.Validate(validationContext); Assert.False(actual.Valid); Assert.Single(actual.Errors); Assert.Same(expected, actual.Errors[0].Node); Assert.Equal(ValidationErrorType.Schema, actual.Errors[0].ErrorType); Assert.Equal("Sch_UnexpectedElementContentExpectingComplex", actual.Errors[0].Id); Assert.DoesNotContain(ValidationErrorStrings.Fmt_ListOfPossibleElements, actual.Errors[0].Description); pPr.RemoveChild(errorChild); actual.Clear(); // SectionProperties order wrong errorChild = pPr.FirstChild; pPr.PrependChild(new SectionProperties()); target.Validate(validationContext); Assert.False(actual.Valid); Assert.Single(actual.Errors); Assert.Same(expected, actual.Errors[0].Node); Assert.Same(errorChild, actual.Errors[0].RelatedNode); Assert.Equal(ValidationErrorType.Schema, actual.Errors[0].ErrorType); Assert.Equal("Sch_UnexpectedElementContentExpectingComplex", actual.Errors[0].Id); Assert.DoesNotContain(ValidationErrorStrings.Fmt_ListOfPossibleElements, actual.Errors[0].Description); pPr.RemoveChild(pPr.FirstChild); }
public static FileStream GenerateMedicalTestProtocol(List <Recruit> recruits, string teamNumber, DateTime sendDate) { const string templateFile = TemplatePath + "MedicalTest/Protocol.docx"; const string tempFile = TempPath + "Protocol.docx"; CopyTemplateFileToTempDirectory(templateFile, tempFile); var replaceTextDictionary = new Dictionary <string, string> { { "TEAMNUM", teamNumber }, { "CURRENTDATE", sendDate.Day.ToString() }, { "CURRENTMONTH", sendDate.GetMonthName() }, { "CURRENTYEAR", sendDate.Year.ToString() }, { "RESULT", $"в {recruits.Count} исследуемых пробах из {recruits.Count} не обнаружены антитела SARS-CoV-2." } }; using (var document = WordprocessingDocument.Open(tempFile, true)) { try { var bookMarks = FindBookmarks(document.MainDocumentPart.Document); RemoveBookMarkContent(bookMarks); var runFonts = new RunFonts() { Ascii = "Times New Roman", HighAnsi = "Times New Roman" }; var fontSize = new FontSize() { Val = "24" }; var fontSizeComplexScript = new FontSizeComplexScript() { Val = "24" }; var runProperties = new RunProperties(new Bold(), runFonts, fontSize, fontSizeComplexScript); foreach (var(bookmarkStart, bookmarkEnd) in bookMarks) { if (!replaceTextDictionary.Select(m => m.Key).Contains <string>(bookmarkStart.Name)) { continue; } var replaceText = replaceTextDictionary.First(m => m.Key == bookmarkStart.Name).Value; var run = new Run(); var text = new Text(replaceText); run.Append(runProperties.CloneNode(true), text); bookmarkEnd.InsertAfterSelf(run); } var body = document.MainDocumentPart.Document.Body; var index = 1; var runFontsTable = new RunFonts() { Ascii = "Times New Roman", HighAnsi = "Times New Roman" }; var fontSizeTable = new FontSize() { Val = "22" }; var fontSizeComplexScriptTable = new FontSizeComplexScript() { Val = "22" }; var runPropertiesTable = new RunProperties(runFontsTable, fontSizeTable, fontSizeComplexScriptTable); var paragraphProperties = new ParagraphProperties(new SpacingBetweenLines() { After = "0" }); foreach (var table in body.Descendants <Table>()) { foreach (var recruit in recruits) { var tableCellIndex = new TableCell(new Paragraph(paragraphProperties.CloneNode(true), new Run(runPropertiesTable.CloneNode(true), new Text(index.ToString())))); var tableCellFullName = new TableCell(new Paragraph(paragraphProperties.CloneNode(true), new Run(runPropertiesTable.CloneNode(true), new Text(recruit.FullName)))); var tableCellDisc = new TableCell(new Paragraph(paragraphProperties.CloneNode(true), new Run(runPropertiesTable.CloneNode(true), new Text("антитела SARS-CoV-2")))); var tableCellTestNum = new TableCell(new Paragraph(paragraphProperties.CloneNode(true), new Run(runPropertiesTable.CloneNode(true), new Text( $"{recruit.AdditionalData.TestNum} от {recruit.AdditionalData.TestDate?.ToShortDateString()}")))); var tableCellResult = new TableCell(new Paragraph(paragraphProperties.CloneNode(true), new Run(runPropertiesTable.CloneNode(true), new Text("не обнаружены")))); var tableRow = new TableRow(); tableRow.Append(tableCellIndex, tableCellFullName, tableCellDisc, tableCellTestNum, tableCellResult); table.AppendChild(tableRow); index++; } var nullTCell = new TableCell(new Paragraph(paragraphProperties.CloneNode(true), new Run(new Text("")))); var nullTRow = new TableRow(nullTCell.CloneNode(true), nullTCell.CloneNode(true), nullTCell.CloneNode(true), nullTCell.CloneNode(true), nullTCell.CloneNode(true)); table.AppendChild(nullTRow.CloneNode(true)); table.AppendChild(nullTRow.CloneNode(true)); table.AppendChild(nullTRow.CloneNode(true)); } document.MainDocumentPart.Document.Save(); } catch { document.MainDocumentPart.Document.Save(); throw new Exception("Неизвестная ошибка"); } } return(new FileStream(tempFile, FileMode.Open)); }
private void AddImageToBody(WordprocessingDocument wordDoc, string relationshipId) { // Define the reference of the image. var element = new Drawing( new DW.Inline( new DW.Extent() { Cx = 1757548L, Cy = 253064L }, new DW.EffectExtent() { LeftEdge = 0L, TopEdge = 0L, RightEdge = 0L, BottomEdge = 0L }, new DW.DocProperties() { Id = (UInt32Value)1U, Name = "Picture 1" }, new DW.NonVisualGraphicFrameDrawingProperties( new A.GraphicFrameLocks() { NoChangeAspect = true }), new A.Graphic( new A.GraphicData( new PIC.Picture( new PIC.NonVisualPictureProperties( new PIC.NonVisualDrawingProperties() { Id = (UInt32Value)0U, Name = "New Bitmap Image.jpg" }, new PIC.NonVisualPictureDrawingProperties()), new PIC.BlipFill( new A.Blip( new A.BlipExtensionList( new A.BlipExtension() { Uri = "{28A0092B-C50C-407E-A947-70E740481C1C}" }) ) { Embed = relationshipId, CompressionState = A.BlipCompressionValues.Print }, new A.Stretch( new A.FillRectangle())), new PIC.ShapeProperties( new A.Transform2D( new A.Offset() { X = 0L, Y = 0L }, new A.Extents() { Cx = 1757548L, Cy = 253064L }), new A.PresetGeometry( new A.AdjustValueList() ) { Preset = A.ShapeTypeValues.Rectangle })) ) { Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" }) ) { DistanceFromTop = (UInt32Value)0U, DistanceFromBottom = (UInt32Value)0U, DistanceFromLeft = (UInt32Value)0U, DistanceFromRight = (UInt32Value)0U, EditId = "50D07946" }); Paragraph paragraph = new Paragraph(); ParagraphProperties pprop = new ParagraphProperties(); Justification centerHeading = new Justification() { Val = JustificationValues.Center }; pprop.Append(centerHeading); pprop.ParagraphStyleId = new ParagraphStyleId() { Val = "bodyimage" }; paragraph.Append(pprop); Run run = new Run(); run.AppendChild(element); paragraph.Append(run); // Append the reference to body, the element should be in a Run. wordDoc.MainDocumentPart.Document.Body.AppendChild(paragraph); }
public static FileStream GeneratePersonalGuidanceReport(List <SpecialPerson> persons, MilitaryComissariat militaryComissariat) { const string templateFile = TemplatePath + "PersonalGuidance/person_report.docx"; var tempFile = TempPath + $"PersonalGuidance/{militaryComissariat.Name}.docx"; if (!Directory.Exists(TempPath + "PersonalGuidance")) { Directory.CreateDirectory(TempPath + "PersonalGuidance"); } CopyTemplateFileToTempDirectory(templateFile, tempFile); var replaceTextDictionary = new Dictionary <string, string> { { "MilitaryComissariat", militaryComissariat.Name }, }; using (var document = WordprocessingDocument.Open(tempFile, true)) { try { var bookMarks = FindBookmarks(document.MainDocumentPart.Document); RemoveBookMarkContent(bookMarks); var runFonts = new RunFonts() { Ascii = "Times New Roman", HighAnsi = "Times New Roman" }; var fontSize = new FontSize() { Val = "28" }; var fontSizeComplexScript = new FontSizeComplexScript() { Val = "28" }; var runProperties = new RunProperties(new Bold(), runFonts, fontSize, fontSizeComplexScript); foreach (var(bookmarkStart, bookmarkEnd) in bookMarks) { if (!replaceTextDictionary.Select(m => m.Key).Contains <string>(bookmarkStart.Name)) { continue; } var replaceText = replaceTextDictionary.First(m => m.Key == bookmarkStart.Name).Value; var run = new Run(); var text = new Text(replaceText); run.Append(runProperties.CloneNode(true), text); bookmarkEnd.InsertAfterSelf(run); } var body = document.MainDocumentPart.Document.Body; var index = 1; var runFontsTable = new RunFonts() { Ascii = "Times New Roman", HighAnsi = "Times New Roman" }; var fontSizeTable = new FontSize() { Val = "24" }; var fontSizeComplexScriptTable = new FontSizeComplexScript() { Val = "24" }; var runPropertiesTable = new RunProperties(runFontsTable, fontSizeTable, fontSizeComplexScriptTable); var paragraphProperties = new ParagraphProperties(new SpacingBetweenLines() { After = "0" }); foreach (var table in body.Descendants <Table>()) { foreach (var person in persons) { var tableCellIndex = new TableCell(new Paragraph(paragraphProperties.CloneNode(true), new Run(runPropertiesTable.CloneNode(true), new Text(index.ToString())))); var tableCellFullName = new TableCell(new Paragraph(paragraphProperties.CloneNode(true), new Run(runPropertiesTable.CloneNode(true), new Text(person.FullName)))); var tableCellBirthYear = new TableCell(new Paragraph(paragraphProperties.CloneNode(true), new Run(runPropertiesTable.CloneNode(true), new Text(person.BirthYear.ToString())))); var tableCellMilitaryUnitCode = new TableCell(new Paragraph( paragraphProperties.CloneNode(true), new Run(runPropertiesTable.CloneNode(true), new Text(person.Requirement.MilitaryUnitCode)))); var tableCellMilitaryUnitName = new TableCell(new Paragraph( paragraphProperties.CloneNode(true), new Run(runPropertiesTable.CloneNode(true), new Text(person.Requirement.MilitaryUnit.Name)))); var tableCellSendDate = new TableCell(new Paragraph(paragraphProperties.CloneNode(true), new Run(runPropertiesTable.CloneNode(true), new Text(person.Notice)))); var tableRow = new TableRow(); tableRow.Append(tableCellIndex, tableCellFullName, tableCellBirthYear, tableCellMilitaryUnitCode, tableCellMilitaryUnitName, tableCellSendDate); table.AppendChild(tableRow); index++; } } document.MainDocumentPart.Document.Save(); } catch { document.MainDocumentPart.Document.Save(); throw new Exception("Неизвестная ошибка"); } } return(new FileStream(tempFile, FileMode.Open)); }
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; }
public static byte[] WordDokumanOlustur(string sablon, DataSet dataset, Dictionary <string, string> degerler) { byte[] buffer = File.ReadAllBytes(sablon); string[] switches = (string[])null; using (MemoryStream memoryStream = new MemoryStream()) { memoryStream.Write(buffer, 0, buffer.Length); using (WordprocessingDocument docx = WordprocessingDocument.Open((Stream)memoryStream, true)) { DocumentMerge.ConvertFieldCodes((OpenXmlElement)docx.MainDocumentPart.Document); foreach (SimpleField field in docx.MainDocumentPart.Document.Descendants <SimpleField>()) { string fieldName = DocumentMerge.GetFieldName(field, out switches); if (!string.IsNullOrEmpty(fieldName) && fieldName.StartsWith("TBL_")) { TableRow firstParent1 = DocumentMerge.GetFirstParent <TableRow>((OpenXmlElement)field); if (firstParent1 != null) { Table firstParent2 = DocumentMerge.GetFirstParent <Table>((OpenXmlElement)firstParent1); if (firstParent2 != null) { string nameFromFieldName = DocumentMerge.GetTableNameFromFieldName(fieldName); if (dataset != null && dataset.Tables.Contains(nameFromFieldName) && dataset.Tables[nameFromFieldName].Rows.Count != 0) { DataTable dataTable = dataset.Tables[nameFromFieldName]; List <TableCellProperties> list1 = new List <TableCellProperties>(); List <string> list2 = new List <string>(); List <string> list3 = new List <string>(); List <SimpleField> list4 = new List <SimpleField>(); foreach (TableCell tableCell in firstParent1.Descendants <TableCell>()) { list1.Add(tableCell.GetFirstChild <TableCellProperties>()); Paragraph firstChild1 = tableCell.GetFirstChild <Paragraph>(); if (firstChild1 != null) { ParagraphProperties firstChild2 = firstChild1.GetFirstChild <ParagraphProperties>(); if (firstChild2 != null) { list3.Add(firstChild2.OuterXml); } else { list3.Add((string)null); } } else { list3.Add((string)null); } string str = string.Empty; SimpleField simpleField = (SimpleField)null; using (IEnumerator <SimpleField> enumerator = tableCell.Descendants <SimpleField>().GetEnumerator()) { if (enumerator.MoveNext()) { SimpleField current = enumerator.Current; simpleField = current; str = DocumentMerge.GetColumnNameFromFieldName(DocumentMerge.GetFieldName(current, out switches)); } } list2.Add(str); if (str != "") { list4.Add(simpleField); } } TableRowProperties firstChild = firstParent1.GetFirstChild <TableRowProperties>(); foreach (DataRow dataRow in (InternalDataCollectionBase)dataTable.Rows) { TableRow tableRow = new TableRow(); if (firstChild != null) { tableRow.Append(new OpenXmlElement[1] { (OpenXmlElement) new TableRowProperties(firstChild.OuterXml) }); } for (int index = 0; index < list1.Count; ++index) { TableCellProperties tableCellProperties = new TableCellProperties(list1[index].OuterXml); TableCell tableCell = new TableCell(); tableCell.Append(new OpenXmlElement[1] { (OpenXmlElement)tableCellProperties }); Paragraph paragraph = new Paragraph(new OpenXmlElement[1] { (OpenXmlElement) new ParagraphProperties(list3[index]) }); tableCell.Append(new OpenXmlElement[1] { (OpenXmlElement)paragraph }); try { if (!string.IsNullOrEmpty(list2[index])) { if (!dataTable.Columns.Contains(list2[index])) { throw new Exception(string.Format("Unable to complete template: column name '{0}' is unknown in parameter tables !", (object)list2[index])); } if (!dataRow.IsNull(list2[index])) { string text = dataRow[list2[index]].ToString(); paragraph.Append(new OpenXmlElement[1] { (OpenXmlElement)DocumentMerge.GetRunElementForText(text, list4[index]) }); } } } catch { } tableRow.Append(new OpenXmlElement[1] { (OpenXmlElement)tableCell }); } firstParent2.Append(new OpenXmlElement[1] { (OpenXmlElement)tableRow }); } firstParent1.Remove(); } } } } } foreach (SimpleField field in docx.MainDocumentPart.Document.Descendants <SimpleField>()) { string fieldName = DocumentMerge.GetFieldName(field, out switches); if (!string.IsNullOrEmpty(fieldName) && fieldName.StartsWith("TBL_")) { TableRow firstParent1 = DocumentMerge.GetFirstParent <TableRow>((OpenXmlElement)field); if (firstParent1 != null) { Table firstParent2 = DocumentMerge.GetFirstParent <Table>((OpenXmlElement)firstParent1); if (firstParent2 != null) { string nameFromFieldName = DocumentMerge.GetTableNameFromFieldName(fieldName); if ((dataset == null || !dataset.Tables.Contains(nameFromFieldName) || dataset.Tables[nameFromFieldName].Rows.Count == 0) && Enumerable.Contains <string>((IEnumerable <string>)switches, "dt")) { firstParent2.Remove(); } } } } } DocumentMerge.FillWordFieldsInElement(docx, degerler, (OpenXmlElement)docx.MainDocumentPart.Document); ((OpenXmlPartRootElement)docx.MainDocumentPart.Document).Save(); foreach (HeaderPart headerPart in docx.MainDocumentPart.HeaderParts) { DocumentMerge.ConvertFieldCodes((OpenXmlElement)headerPart.Header); DocumentMerge.FillWordFieldsInElement(docx, degerler, (OpenXmlElement)headerPart.Header); ((OpenXmlPartRootElement)headerPart.Header).Save(); } foreach (FooterPart footerPart in docx.MainDocumentPart.FooterParts) { DocumentMerge.ConvertFieldCodes((OpenXmlElement)footerPart.Footer); DocumentMerge.FillWordFieldsInElement(docx, degerler, (OpenXmlElement)footerPart.Footer); ((OpenXmlPartRootElement)footerPart.Footer).Save(); } } memoryStream.Seek(0L, SeekOrigin.Begin); return(memoryStream.ToArray()); } }
public IActionResult Create(LeaseContract model) { var carQuery = _context.Cars .Include(c => c.CarOwner) .Include(c => c.CarModel).ThenInclude(c => c.Manufacturer) .Include(c => c.CarStatuses).ThenInclude(c => c.Unit).ThenInclude(c => c.Firm).ThenInclude(c => c.Employee); model.Car = carQuery.Where(c => c.Id == model.CarId).First(); model.LeaseAmmount = (decimal)model.LeaseAmmount; //CreateLeaseContractArchive(model); model.ManagerId = 3; //Save document to storage //string uploadFolder = Path.Combine(hostingEnvironment.WebRootPath, "AccountingDocuments"); //uploadFolder = Path.Combine(uploadFolder, model.Car.RegistrationNumber); //try //{ // if (!Directory.Exists(uploadFolder)) // { // DirectoryInfo di = Directory.CreateDirectory(uploadFolder); // } //} //catch (Exception) //{ // //throw; //} _context.Add(model); _context.SaveChanges(); return(RedirectToPage($"/cars/details/{model.CarId}"));// RedirectToAction("Edit", new {id= model.ID } ); //return View(model); /// 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 = "The OpenXML SDK rocks!" }; // 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(); Text text2 = new Text(); text2.Text = "Teste aqui"; run2.AppendChild(new Break()); run2.AppendChild(new Text("Hello")); run2.AppendChild(new Break()); run2.AppendChild(new Text("world")); 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")); } }
public static byte[] GetOwnerVerification(OwnerVerificationReportModel reportModel, string name) { try { // ****************************************************** // get document template // ****************************************************** Assembly assembly = Assembly.GetExecutingAssembly(); byte[] byteArray; int ownerCount = 0; using (Stream templateStream = assembly.GetManifestResourceStream(ResourceName)) { byteArray = new byte[templateStream.Length]; templateStream.Read(byteArray, 0, byteArray.Length); templateStream.Close(); } using (MemoryStream documentStream = new MemoryStream()) { WordprocessingDocument wordDocument = WordprocessingDocument.Create(documentStream, WordprocessingDocumentType.Document, true); // add a main document part wordDocument.AddMainDocumentPart(); using (MemoryStream templateStream = new MemoryStream()) { templateStream.Write(byteArray, 0, byteArray.Length); WordprocessingDocument wordTemplate = WordprocessingDocument.Open(templateStream, true); if (wordTemplate == null) { throw new Exception("Owner Verification template not found"); } // ****************************************************** // merge document content // ****************************************************** foreach (HetOwner owner in reportModel.Owners) { ownerCount++; using (MemoryStream ownerStream = new MemoryStream()) { WordprocessingDocument ownerDocument = (WordprocessingDocument)wordTemplate.Clone(ownerStream); ownerDocument.Save(); Dictionary <string, string> values = new Dictionary <string, string> { { "classification", owner.Classification }, { "districtAddress", reportModel.DistrictAddress }, { "districtContact", reportModel.DistrictContact }, { "organizationName", owner.OrganizationName }, { "address1", owner.Address1 }, { "address2", owner.Address2 }, { "reportDate", reportModel.ReportDate }, { "ownerCode", owner.OwnerCode }, { "sharedKeyHeader", owner.SharedKeyHeader }, { "sharedKey", owner.SharedKey }, { "workPhoneNumber", owner.PrimaryContact.WorkPhoneNumber } }; // update classification number first [ClassificationNumber] owner.Classification = owner.Classification.Replace("&", "&"); bool found = false; foreach (OpenXmlElement paragraphs in ownerDocument.MainDocumentPart.Document.Body.Elements()) { foreach (OpenXmlElement paragraphRun in paragraphs.Elements()) { foreach (OpenXmlElement text in paragraphRun.Elements()) { if (text.InnerText.Contains("ClassificationNumber")) { // replace text text.InnerXml = text.InnerXml.Replace("<w:t>ClassificationNumber</w:t>", $"<w:t xml:space='preserve'>ORCS: {owner.Classification}</w:t>"); found = true; break; } } if (found) { break; } } if (found) { break; } } ownerDocument.MainDocumentPart.Document.Save(); ownerDocument.Save(); // update merge fields MergeHelper.ConvertFieldCodes(ownerDocument.MainDocumentPart.Document); MergeHelper.MergeFieldsInElement(values, ownerDocument.MainDocumentPart.Document); ownerDocument.MainDocumentPart.Document.Save(); // setup table for equipment data Table equipmentTable = GenerateEquipmentTable(owner.HetEquipment); Paragraph tableParagraph = null; found = false; foreach (OpenXmlElement paragraphs in ownerDocument.MainDocumentPart.Document.Body.Elements()) { foreach (OpenXmlElement paragraphRun in paragraphs.Elements()) { foreach (OpenXmlElement text in paragraphRun.Elements()) { if (text.InnerText.Contains("Owner Equipment Table")) { // insert table here... text.RemoveAllChildren(); tableParagraph = (Paragraph)paragraphRun.Parent; found = true; break; } } if (found) { break; } } if (found) { break; } } // append table to document if (tableParagraph != null) { Run run = tableParagraph.AppendChild(new Run()); run.AppendChild(equipmentTable); } ownerDocument.MainDocumentPart.Document.Save(); ownerDocument.Save(); // merge owner into the master document if (ownerCount == 1) { // update document header foreach (HeaderPart headerPart in ownerDocument.MainDocumentPart.HeaderParts) { MergeHelper.ConvertFieldCodes(headerPart.Header); MergeHelper.MergeFieldsInElement(values, headerPart.Header); headerPart.Header.Save(); } wordDocument = (WordprocessingDocument)ownerDocument.Clone(documentStream); ownerDocument.Close(); ownerDocument.Dispose(); } else { // DELETE document header from owner document ownerDocument.MainDocumentPart.DeleteParts(ownerDocument.MainDocumentPart.HeaderParts); List <HeaderReference> headers = ownerDocument.MainDocumentPart.Document.Descendants <HeaderReference>().ToList(); foreach (HeaderReference header in headers) { header.Remove(); } // DELETE document footers from owner document ownerDocument.MainDocumentPart.DeleteParts(ownerDocument.MainDocumentPart.FooterParts); List <FooterReference> footers = ownerDocument.MainDocumentPart.Document.Descendants <FooterReference>().ToList(); foreach (FooterReference footer in footers) { footer.Remove(); } // DELETE section properties from owner document List <SectionProperties> properties = ownerDocument.MainDocumentPart.Document.Descendants <SectionProperties>().ToList(); foreach (SectionProperties property in properties) { property.Remove(); } ownerDocument.Save(); // insert section break in master MainDocumentPart mainPart = wordDocument.MainDocumentPart; Paragraph para = new Paragraph(); SectionProperties sectProp = new SectionProperties(); SectionType secSbType = new SectionType() { Val = SectionMarkValues.OddPage }; PageSize pageSize = new PageSize() { Width = 11900U, Height = 16840U, Orient = PageOrientationValues.Portrait }; PageMargin pageMargin = new PageMargin() { Top = 2642, Right = 23U, Bottom = 278, Left = 23U, Header = 714, Footer = 0, Gutter = 0 }; // page numbering throws out the "odd page" section breaks //PageNumberType pageNum = new PageNumberType() {Start = 1}; sectProp.AppendChild(secSbType); sectProp.AppendChild(pageSize); sectProp.AppendChild(pageMargin); //sectProp.AppendChild(pageNum); ParagraphProperties paragraphProperties = new ParagraphProperties(sectProp); para.AppendChild(paragraphProperties); mainPart.Document.Body.InsertAfter(para, mainPart.Document.Body.LastChild); mainPart.Document.Save(); // append document body string altChunkId = $"AltChunkId{ownerCount}"; AlternativeFormatImportPart chunk = mainPart.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.WordprocessingML, altChunkId); ownerDocument.Close(); ownerDocument.Dispose(); ownerStream.Seek(0, SeekOrigin.Begin); chunk.FeedData(ownerStream); AltChunk altChunk = new AltChunk { Id = altChunkId }; Paragraph para3 = new Paragraph(); Run run3 = para3.InsertAfter(new Run(), para3.LastChild); run3.AppendChild(altChunk); mainPart.Document.Body.InsertAfter(para3, mainPart.Document.Body.LastChild); mainPart.Document.Save(); } } } wordTemplate.Close(); wordTemplate.Dispose(); templateStream.Close(); } // ****************************************************** // secure & return completed document // ****************************************************** wordDocument.CompressionOption = CompressionOption.Maximum; SecurityHelper.PasswordProtect(wordDocument); wordDocument.Close(); wordDocument.Dispose(); documentStream.Seek(0, SeekOrigin.Begin); byteArray = documentStream.ToArray(); } return(byteArray); } catch (Exception e) { Console.WriteLine(e); throw; } }
public async Task <IActionResult> Test() { string pathLocal = Path.Combine(hostingEnvironment.WebRootPath, "Templates/Lease"); string destinationFile = Path.Combine(pathLocal, "SampleDocument.docx"); string sourceFile = Path.Combine(pathLocal, "AcceptanceCertificate.docx"); var carQuery = _context.Cars .Include(c => c.CarModel).ThenInclude(c => c.Manufacturer) .Include(c => c.CarUsers).ThenInclude(c => c.Employee);//.Find((long)2097); var car = carQuery.Where(c => c.Id == (long)2097).FirstOrDefault(); try { // Create a copy of the template file and open the copy //File System.IO.File.Copy(sourceFile, destinationFile, true); using (WordprocessingDocument document = WordprocessingDocument.Open(destinationFile, true)) { // Change the document type to Document //document.ChangeDocumentType(DocumentFormat.OpenXml.WordprocessingDocumentType.Document); // Find all structured document tags IEnumerable <Text> placeHolders = document.MainDocumentPart.RootElement.Descendants <Text>(); foreach (var item in placeHolders) { switch (item.Text) { case "CarOwner": item.Text = car.CarUserForView; break; case "RegistrationNumber": item.Text = car.RegistrationNumber; break; case "FirstRegistrationYear": item.Text = car.FirstRegistrationYear.ToString(); break; case "VinNumber": item.Text = car.VinNumber; break; case "Manufacturer": item.Text = car.CarModel.Manufacturer.Name; break; case "Model": item.Text = car.CarModel.Model; break; default: break; } //item.InsertAt(new Text("Hello!"), 0); //item.RemoveAllChildren(); //Text txt = new Text("Hello, Word!"); //item.AppendChild<Text>(new Text("Hell0, world")); // .Descendants<Text>(). .First().Text = "Hello, world!"; } List <SdtBlock> sdtList = document.MainDocumentPart.RootElement.Descendants <SdtBlock>().ToList(); //sdtList[0].InnerText = "Changed By Code"; // Get the MainPart of the document MainDocumentPart mainPart = document.MainDocumentPart; // Get the Document Settings Part //DocumentSettingsPart documentSettingPart1 = mainPart.DocumentSettingsPart; // Create a new attachedTemplate and specify a relationship ID // AttachedTemplate attachedTemplate1 = new AttachedTemplate() { Id = "relationId1" }; // Append the attached template to the DocumentSettingsPart //documentSettingPart1.Settings.Append(attachedTemplate1); // Add an ExternalRelationShip of type AttachedTemplate. // Specify the path of template and the relationship ID //documentSettingPart1.AddExternalRelationship("http://schemas.openxmlformats.org/officeDocument/2006/relationships/attachedTemplate", new Uri(sourceFile, UriKind.Absolute), "relationId1"); // Save the document mainPart.Document.Save(); Console.WriteLine("Document generated at " + destinationFile); } } catch (Exception ex) { //Console.WriteLine(ex.Message); } finally { //Console.WriteLine("\nPress Enter to continue…"); //Console.ReadLine(); } 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 = "The OpenXML SDK rocks!" }; // 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(); Text text2 = new Text(); text2.Text = "Teste aqui"; run2.AppendChild(new Break()); run2.AppendChild(new Text("Hello")); run2.AppendChild(new Break()); run2.AppendChild(new Text("world")); 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")); } }
private static TableCell SetupHeaderCell(string text, string width, bool center = false) { try { TableCell tableCell = new TableCell(); TableCellProperties tableCellProperties = new TableCellProperties(); TableCellWidth tableCellWidth = new TableCellWidth() { Width = width, Type = TableWidthUnitValues.Dxa }; Shading shading = new Shading() { Val = ShadingPatternValues.Clear, Fill = "FFFFFF", Color = "auto" }; // border & padding TableCellBorders borders = new TableCellBorders(); TopBorder topBorder = new TopBorder { Val = new EnumValue <BorderValues>(BorderValues.Thick), Color = "A1A2A3" }; borders.AppendChild(topBorder); BottomBorder bottomBorder = new BottomBorder { Val = new EnumValue <BorderValues>(BorderValues.Thick), Color = "A1A2A3" }; borders.AppendChild(bottomBorder); RightBorder rightBorder = new RightBorder { Val = new EnumValue <BorderValues>(BorderValues.Nil) }; borders.AppendChild(rightBorder); LeftBorder leftBorder = new LeftBorder { Val = new EnumValue <BorderValues>(BorderValues.Nil) }; borders.AppendChild(leftBorder); TableCellMargin margin = new TableCellMargin(); TopMargin topMargin = new TopMargin() { Width = "40" }; BottomMargin bottomMargin = new BottomMargin() { Width = "40" }; margin.AppendChild(topMargin); margin.AppendChild(bottomMargin); tableCellProperties.AppendChild(tableCellWidth); tableCellProperties.AppendChild(shading); tableCellProperties.AppendChild(borders); tableCellProperties.AppendChild(margin); tableCell.AppendChild(tableCellProperties); // add text (with specific formatting) Paragraph paragraph = new Paragraph() { RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "6ED85602", TextId = "77777777" }; ParagraphProperties paragraphProperties = new ParagraphProperties(); ParagraphMarkRunProperties paragraphMarkRunProperties = new ParagraphMarkRunProperties(); paragraphMarkRunProperties.AppendChild(new Color { Val = "000000" }); paragraphMarkRunProperties.AppendChild(new RunFonts { Ascii = "Arial" }); paragraphMarkRunProperties.AppendChild(new FontSize() { Val = "7pt" }); paragraphMarkRunProperties.AppendChild(new Bold()); Justification justification = new Justification() { Val = JustificationValues.Left }; if (center) { justification.Val = JustificationValues.Center; } paragraphProperties.AppendChild(paragraphMarkRunProperties); paragraphProperties.AppendChild(justification); paragraph.AppendChild(paragraphProperties); paragraph.AppendChild(new Text(text)); // add to table cell tableCell.AppendChild(paragraph); return(tableCell); } catch (Exception e) { Console.WriteLine(e); throw; } }
public void DoubleOL() { using (MemoryStream mem = new MemoryStream()) { WordDocument doc = new WordDocument(mem); doc.Process(new HtmlParser("<ol><li>one</li></ol><ol><li>two</li></ol>")); Assert.IsNotNull(doc.Document.Body); Assert.AreEqual(2, 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(1, numberingId.Val.Value); Run run = para.ChildElements[1] as Run; Assert.IsNotNull(run); Assert.AreEqual(1, run.ChildElements.Count); Word.Text text = run.ChildElements[0] as Word.Text; Assert.IsNotNull(text); Assert.AreEqual("one", text.InnerText); para = doc.Document.Body.ChildElements[1] as Paragraph; Assert.IsNotNull(para); Assert.AreEqual(2, para.ChildElements.Count); properties = para.ChildElements[0] as ParagraphProperties; Assert.IsNotNull(properties); Assert.AreEqual(2, properties.ChildElements.Count); paragraphStyleId = properties.ChildElements[0] as ParagraphStyleId; Assert.IsNotNull(paragraphStyleId); Assert.AreEqual("ListParagraph", paragraphStyleId.Val.Value); numberingProperties = properties.ChildElements[1] as NumberingProperties; Assert.IsNotNull(numberingProperties); Assert.AreEqual(2, numberingProperties.ChildElements.Count); numberingLevelReference = numberingProperties.ChildElements[0] as NumberingLevelReference; Assert.IsNotNull(numberingLevelReference); Assert.AreEqual(0, numberingLevelReference.Val.Value); numberingId = numberingProperties.ChildElements[1] as NumberingId; Assert.IsNotNull(numberingId); Assert.AreEqual(2, numberingId.Val.Value); run = para.ChildElements[1] as Run; Assert.IsNotNull(run); Assert.AreEqual(1, run.ChildElements.Count); text = run.ChildElements[0] as Word.Text; Assert.IsNotNull(text); Assert.AreEqual("two", text.InnerText); OpenXmlValidator validator = new OpenXmlValidator(); var errors = validator.Validate(doc.WordprocessingDocument); Assert.AreEqual(0, errors.Count()); } }
public void SendEmail() { DataTable zamok = Zamowienia_DoWyslaniaOK().Result; foreach (DataRow r in zamok.Rows) { #region Pobieranie danych i tworzenie ciała maila. rec1.CreateNewDocument(); rec1.LoadDocument("Zamowienie_OK.docx"); string Status_Zam = ""; string Producent; string PH_Producent; string Numer_Zam; string FileDate; string ZamDate; string Uwagi; string Rodzaj_zam; string XL_Akronim; string Prod_Akronim; string Prod_Adres; if (bool.TryParse(r["Zpn_Alert"].ToString(), out bool al)) { if (al) { Status_Zam = "Błędy mapowania towarów. Obsługa CallCenter"; } else { Status_Zam = "OK. Wysłane do Mobiusa."; } } else { Status_Zam = "OK. Wysłane do Mobiusa."; } if (r["Zpn_Producent"].ToString().Length > 1) { Producent = r["Zpn_Producent"].ToString(); } else { Producent = "BŁĄD"; } if (r["Zpn_NAZWISKO"].ToString().Length > 1) { PH_Producent = r["Zpn_NAZWISKO"].ToString() + " " + r["Zpn_IMIE"].ToString(); } else { PH_Producent = "BŁĄD"; } if (r["Zpn_NR_ZAM"].ToString().Length > 1) { Numer_Zam = r["Zpn_NR_ZAM"].ToString(); } else { Numer_Zam = "BŁĄD"; } if (DateTime.TryParse(r["Zpn_DataPliku"].ToString(), out DateTime Data_Otrz)) { FileDate = Data_Otrz.ToShortDateString() + " " + Data_Otrz.ToShortTimeString(); } else { FileDate = "BŁĄD"; } if (DateTime.TryParse(r["Zpn_DATA_ZAM"].ToString(), out DateTime Data_Zam)) { ZamDate = Data_Zam.ToShortDateString() + " " + Data_Zam.ToShortTimeString(); } else { ZamDate = "BŁĄD"; } if (r["Zpn_UWAGI"].ToString().Length > 1) { Uwagi = r["Zpn_UWAGI"].ToString(); } else { Uwagi = "BŁĄD"; } if (r["Zpn_TYP_ZAM"].ToString().Length > 1) { if (r["Zpn_TYP_ZAM"].ToString() == "ZG") { Rodzaj_zam = "Gratisowe"; } else { Rodzaj_zam = "Standard"; } } else { Rodzaj_zam = "BŁĄD"; } if (r["Knt_Akronim"].ToString().Length > 1) { XL_Akronim = r["Knt_Akronim"].ToString(); } else { XL_Akronim = "BŁĄD"; } if (r["Zpn_NAZWA"].ToString().Length > 1) { Prod_Akronim = r["Zpn_NAZWA"].ToString(); } else { Prod_Akronim = "BŁĄD"; } if ((r["Zpn_MIASTO"].ToString() + r["Zpn_ULICA"].ToString()).Length > 1) { Prod_Adres = r["Zpn_MIASTO"].ToString() + ", " + r["Zpn_ULICA"].ToString(); } else { Prod_Adres = "BŁĄD"; } if (Int32.TryParse(r["Zpn_Id"].ToString(), out int Zpn_id)) { } else { Zpn_id = 0; } rec1.Document.ReplaceAll("<@Status_Zam>", Status_Zam, SearchOptions.None); rec1.Document.ReplaceAll("<@Producent>", Producent, SearchOptions.None); rec1.Document.ReplaceAll("<@PH_Producent>", PH_Producent, SearchOptions.None); rec1.Document.ReplaceAll("<@Numer_Zam>", Numer_Zam, SearchOptions.None); rec1.Document.ReplaceAll("<@Data_Otrz>", FileDate, SearchOptions.None); rec1.Document.ReplaceAll("<@Data_Zam>", ZamDate, SearchOptions.None); rec1.Document.ReplaceAll("<@Uwagi>", Uwagi, SearchOptions.None); rec1.Document.ReplaceAll("<@Rodzaj_Zam>", Rodzaj_zam, SearchOptions.None); rec1.Document.ReplaceAll("<@Knt_XLAkr>", XL_Akronim, SearchOptions.None); rec1.Document.ReplaceAll("<@Knt_ZamProd>", Prod_Akronim, SearchOptions.None); rec1.Document.ReplaceAll("<@Knt_Adres>", Prod_Adres, SearchOptions.None); DocumentRange[] wyniki = rec1.Document.FindAll("<@TABELA>", SearchOptions.None); if (wyniki.Length > 0) { // Paragraph par = rec1.Document.Paragraphs.Get(wyniki[0].Start); DocumentPosition pos = wyniki[0].Start; SubDocument doc = pos.BeginUpdateDocument(); // Add the table rec1.Document.Tables.Create(pos, 1, 9, AutoFitBehaviorType.AutoFitToContents); // Format the table Table tbl = rec1.Document.Tables[0]; pos.EndUpdateDocument(doc); try { tbl.BeginUpdate(); CharacterProperties cp_Tbl = doc.BeginUpdateCharacters(tbl.Range); cp_Tbl.FontSize = 10; cp_Tbl.FontName = "Calibri"; doc.EndUpdateCharacters(cp_Tbl); //tbl.BeginUpdate(); // Insert header caption and format the columns tbl.Rows[0].HeightType = HeightType.Exact; tbl.Rows[0].Height = 80f; doc.InsertSingleLineText(tbl[0, 0].Range.Start, "Lp."); doc.InsertSingleLineText(tbl[0, 1].Range.Start, "Alert"); doc.InsertSingleLineText(tbl[0, 2].Range.Start, "Kod"); doc.InsertSingleLineText(tbl[0, 3].Range.Start, "Towar"); doc.InsertSingleLineText(tbl[0, 4].Range.Start, "il. szt."); doc.InsertSingleLineText(tbl[0, 5].Range.Start, "Ilość"); doc.InsertSingleLineText(tbl[0, 6].Range.Start, "JM"); doc.InsertSingleLineText(tbl[0, 7].Range.Start, "Cena"); doc.InsertSingleLineText(tbl[0, 8].Range.Start, "Gratis"); tbl[0, 0].PreferredWidthType = WidthType.Fixed; tbl[0, 0].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.2f); tbl[0, 0].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 1].PreferredWidthType = WidthType.Fixed; tbl[0, 1].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.4f); tbl[0, 1].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 2].PreferredWidthType = WidthType.Fixed; tbl[0, 2].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.8f); tbl[0, 2].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 3].PreferredWidthType = WidthType.Fixed; tbl[0, 3].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(2.6f); tbl[0, 3].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 4].PreferredWidthType = WidthType.Fixed; tbl[0, 4].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.5f); tbl[0, 4].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 5].PreferredWidthType = WidthType.Fixed; tbl[0, 5].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.6f); tbl[0, 5].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 6].PreferredWidthType = WidthType.Fixed; tbl[0, 6].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.3f); tbl[0, 6].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 7].PreferredWidthType = WidthType.Fixed; tbl[0, 7].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.6f); tbl[0, 7].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 8].PreferredWidthType = WidthType.Fixed; tbl[0, 8].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.4f); tbl[0, 8].VerticalAlignment = TableCellVerticalAlignment.Center; /* * //Apply formatting to the "Active Customers" cell * CharacterProperties properties = rec1.Document.BeginUpdateCharacters(tbl[0, 1].ContentRange); * properties.FontName = "Segoe UI"; * properties.FontSize = 16; * document.EndUpdateCharacters(properties); * ParagraphProperties alignment = document.BeginUpdateParagraphs(table[0, 1].ContentRange); * alignment.Alignment = ParagraphAlignment.Center; * document.EndUpdateParagraphs(alignment); * table[0, 1].VerticalAlignment = TableCellVerticalAlignment.Center; */ int wiersz = 0; DataTable dt_poz = ZamowieniaPozycje_DoWyslaniaOK(Zpn_id).Result; foreach (DataRow r_poz in dt_poz.Rows) { wiersz++; tbl.Rows.InsertAfter(wiersz - 1); tbl.Rows[wiersz].HeightType = HeightType.Auto; if (bool.TryParse(r_poz["Alert"].ToString(), out bool ale)) { if (ale) { doc.Images.Insert(tbl[wiersz, 1].Range.Start, DocumentImageSource.FromFile("alert.png")); } } else { ale = false; } doc.InsertSingleLineText(tbl[wiersz, 0].Range.Start, r_poz["Poz"].ToString()); doc.InsertSingleLineText(tbl[wiersz, 2].Range.Start, r_poz["Kod"].ToString()); doc.InsertSingleLineText(tbl[wiersz, 3].Range.Start, r_poz["Towar_MAG"].ToString()); doc.InsertSingleLineText(tbl[wiersz, 4].Range.Start, r_poz["Ilosc_szt"].ToString()); doc.InsertSingleLineText(tbl[wiersz, 5].Range.Start, r_poz["Ilosc_JM"].ToString()); doc.InsertSingleLineText(tbl[wiersz, 6].Range.Start, r_poz["JM"].ToString().ToUpper()); doc.InsertSingleLineText(tbl[wiersz, 7].Range.Start, r_poz["Cena_Netto"].ToString()); if (bool.TryParse(r_poz["Gratis"].ToString(), out bool gratt)) { } else { gratt = false; } if (bool.TryParse(r_poz["Promocja"].ToString(), out bool dol)) { } else { ale = false; } if (gratt || dol || r["Zpn_TYP_ZAM"].ToString() == "ZG") { doc.Images.Insert(tbl[wiersz, 8].Range.Start, DocumentImageSource.FromFile("gift.png")); } } //Apply formatting to the header cells CharacterProperties headerRowProperties = rec1.Document.BeginUpdateCharacters(tbl.Rows[0].Range); headerRowProperties.FontName = "Calibri"; headerRowProperties.FontSize = 10; headerRowProperties.Bold = true; //headerRowProperties.ForeColor = Color.FromArgb(212, 236, 183); rec1.Document.EndUpdateCharacters(headerRowProperties); ParagraphProperties headerRowParagraphProperties = rec1.Document.BeginUpdateParagraphs(tbl.Rows[0].Range); headerRowParagraphProperties.Alignment = ParagraphAlignment.Center; float f = 0.4f; headerRowParagraphProperties.LeftIndent = f; headerRowParagraphProperties.SpacingBefore = 2; headerRowParagraphProperties.SpacingAfter = 2; rec1.Document.EndUpdateParagraphs(headerRowParagraphProperties); //Apply formatting to Row cells if (tbl.Rows.Count > 1) { DocumentRange targetRange = rec1.Document.CreateRange(tbl[1, 0].Range.Start, tbl[tbl.Rows.Count - 1, 8].Range.End.ToInt()); ParagraphProperties RowParagraphProperties = rec1.Document.BeginUpdateParagraphs(targetRange); RowParagraphProperties.LeftIndent = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.1f);; RowParagraphProperties.SpacingBefore = 8; RowParagraphProperties.SpacingAfter = 8; rec1.Document.EndUpdateParagraphs(RowParagraphProperties); CharacterProperties infoProperties = rec1.Document.BeginUpdateCharacters(targetRange); infoProperties.FontSize = 10; infoProperties.FontName = "Calibri"; rec1.Document.EndUpdateCharacters(infoProperties); } //Apply formatting to Number cells for (int i = 1; i < tbl.Rows.Count; i++) { ParagraphProperties RrParagraphProperties = rec1.Document.BeginUpdateParagraphs(tbl[i, 4].Range); RrParagraphProperties.Alignment = ParagraphAlignment.Right; rec1.Document.EndUpdateParagraphs(RrParagraphProperties); RrParagraphProperties = rec1.Document.BeginUpdateParagraphs(tbl[i, 5].Range); RrParagraphProperties.Alignment = ParagraphAlignment.Right; rec1.Document.EndUpdateParagraphs(RrParagraphProperties); RrParagraphProperties = rec1.Document.BeginUpdateParagraphs(tbl[i, 7].Range); RrParagraphProperties.Alignment = ParagraphAlignment.Right; rec1.Document.EndUpdateParagraphs(RrParagraphProperties); RrParagraphProperties = rec1.Document.BeginUpdateParagraphs(tbl[i, 0].Range); RrParagraphProperties.Alignment = ParagraphAlignment.Right; rec1.Document.EndUpdateParagraphs(RrParagraphProperties); } } finally { tbl.EndUpdate(); doc.BeginUpdate(); TableStyle tStyleMain = rec1.Document.TableStyles.CreateNew(); //Specify style options tStyleMain.TableBorders.InsideHorizontalBorder.LineStyle = TableBorderLineStyle.Single; tStyleMain.TableBorders.InsideHorizontalBorder.LineColor = Color.White; tStyleMain.TableBorders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.Single; tStyleMain.TableBorders.InsideVerticalBorder.LineColor = Color.White; tStyleMain.CellBackgroundColor = Color.FromArgb(227, 238, 220); tStyleMain.Name = "MyTableStyle"; //Add the style to the document collection rec1.Document.TableStyles.Add(tStyleMain); //Create conditional styles (styles for specific table elements) TableConditionalStyle myNewStyleForOddRows = tStyleMain.ConditionalStyleProperties.CreateConditionalStyle(ConditionalTableStyleFormattingTypes.OddRowBanding); myNewStyleForOddRows.CellBackgroundColor = Color.FromArgb(196, 220, 182); TableConditionalStyle myNewStyleForBottomRightCell = tStyleMain.ConditionalStyleProperties.CreateConditionalStyle(ConditionalTableStyleFormattingTypes.BottomRightCell); myNewStyleForBottomRightCell.CellBackgroundColor = Color.FromArgb(188, 214, 201); doc.EndUpdate(); doc.BeginUpdate(); // Apply a previously defined style to the table tbl.Style = tStyleMain; doc.EndUpdate(); rec1.Document.ReplaceAll("<@TABELA>", "", SearchOptions.None); } } #endregion #region Wysyłanie Maila i update statusów if (r["prc_email"].ToString().Length > 0) { string Temat = "Nowe zamówienie producenckie."; try { MailMessage mailMessage = new MailMessage("*****@*****.**", r["prc_email"].ToString()); mailMessage.Subject = Temat; RichEditMailMessageExporter exporter = new RichEditMailMessageExporter(rec1, mailMessage); exporter.Export(); SmtpClient mailSender = new SmtpClient(); mailSender.Port = 587; mailSender.Host = "mag-ol.home.pl"; mailSender.Timeout = 10000; mailSender.DeliveryMethod = SmtpDeliveryMethod.Network; mailSender.UseDefaultCredentials = false; mailSender.Credentials = new NetworkCredential("*****@*****.**", "!Raporty123"); mailSender.EnableSsl = true; mailMessage.From = new MailAddress("*****@*****.**"); //specify your login/password to log on to the SMTP server, if required //mailSender.Credentials = new NetworkCredential("login", "password"); mailSender.Send(mailMessage); int.TryParse(r["Zpn_ID"].ToString(), out int id); if (id > 0) { SQL.UpdateDocumentMailStatus(id); } } catch (Exception exc) { MessageBox.Show(exc.Message); } } #endregion } }
// 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; }
private static Paragraph TableParagraphStyle(string texto) { /* * <w:p w:rsidR="004F6930" * w:rsidRDefault="00373D15"> * <w:pPr> * <w:pStyle w:val="rotulonovedades"/> * <w:rPr> * <w:rFonts w:cs="Arial"/> * </w:rPr> * </w:pPr> * <w:bookmarkStart w:id="0" * w:name="_GoBack"/> * <w:bookmarkEnd w:id="0"/> * <w:r> * <w:rPr> * <w:rStyle w:val="rotulo1"/> * <w:rFonts w:cs="Arial"/> * </w:rPr> * <w:t>TÍTULO:</w:t> * </w:r> * <w:r> * <w:rPr> * <w:rFonts w:cs="Arial"/> * </w:rPr> * <w:t xml:space="preserve"> </w:t> * </w:r> * </w:p> */ Paragraph p = new Paragraph(); ParagraphProperties pPr = new ParagraphProperties(); ParagraphStyleId pStyle = new ParagraphStyleId() { Val = "rotulonovedades" }; pPr.Append(pStyle); ParagraphMarkRunProperties rPrParagraphProperties = new ParagraphMarkRunProperties(); RunFonts rFontsParagraph = new RunFonts() { ComplexScript = "Arial" }; rPrParagraphProperties.Append(rFontsParagraph); pPr.Append(rPrParagraphProperties); p.Append(pPr); Run r = new Run(); RunProperties rpr = new RunProperties(); RunStyle rStyle = new RunStyle() { Val = "rotulo1" }; RunFonts rPrRun = new RunFonts() { ComplexScript = "Arial" }; rpr.Append(rStyle, rPrRun); r.Append(rpr); Text text = new Text() { Text = texto }; r.Append(text); p.Append(r); Run runEmpty = new Run(); RunProperties rpEmpty = new RunProperties(); RunFonts rfEmpty = new RunFonts() { ComplexScript = "Arial" }; rpEmpty.Append(rfEmpty); runEmpty.Append(rpEmpty); Text textEmpty = new Text() { Space = new EnumValue <SpaceProcessingModeValues>(SpaceProcessingModeValues.Preserve) }; runEmpty.Append(textEmpty); p.Append(runEmpty); return(p); }