void PutSlime(Vector3 _position) { GameObject go = Instantiate(Game.instance.slimeSpr); go.name = "slime"; go.transform.position = _position; go.AddComponent <Appear>(); Vanish vanish = go.AddComponent <Vanish>(); vanish.OnVanishDone = (x) => { m_Slimes.Remove(x); Destroy(x); }; m_Slimes.Add(go); SetEyeState(EyeState.Angry); }
public void Drop() { if (null == m_Wall) { return; } hasWall = false; m_Wall.transform.SetParent(null, true); Vanish vanish = m_Wall.AddComponent <Vanish>(); vanish.delay = 1; vanish.OnVanishDone = (x) => { Destroy(x); }; m_Wall = null; }
// Generates content of mainDocumentPart1. private void GenerateMainDocumentPart1Content(MainDocumentPart mainDocumentPart1) { Document document1 = new Document() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 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("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(); 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); TableLayout tableLayout1 = new TableLayout() { Type = TableLayoutValues.Fixed }; TableCellMarginDefault tableCellMarginDefault1 = new TableCellMarginDefault(); TableCellLeftMargin tableCellLeftMargin1 = new TableCellLeftMargin() { Width = 15, Type = TableWidthValues.Dxa }; TableCellRightMargin tableCellRightMargin1 = new TableCellRightMargin() { Width = 15, Type = TableWidthValues.Dxa }; tableCellMarginDefault1.Append(tableCellLeftMargin1); tableCellMarginDefault1.Append(tableCellRightMargin1); TableLook tableLook1 = new TableLook() { Val = "0000", FirstRow = false, LastRow = false, FirstColumn = false, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = false }; tableProperties1.Append(tableStyle1); tableProperties1.Append(tableWidth1); tableProperties1.Append(tableBorders1); tableProperties1.Append(tableLayout1); tableProperties1.Append(tableCellMarginDefault1); tableProperties1.Append(tableLook1); TableGrid tableGrid1 = new TableGrid(); GridColumn gridColumn1 = new GridColumn() { Width = "3787" }; GridColumn gridColumn2 = new GridColumn() { Width = "173" }; GridColumn gridColumn3 = new GridColumn() { Width = "3787" }; GridColumn gridColumn4 = new GridColumn() { Width = "173" }; GridColumn gridColumn5 = new GridColumn() { Width = "3787" }; tableGrid1.Append(gridColumn1); tableGrid1.Append(gridColumn2); tableGrid1.Append(gridColumn3); tableGrid1.Append(gridColumn4); tableGrid1.Append(gridColumn5); table1.Append(tableProperties1); table1.Append(tableGrid1); var n = 0; TableRow row = null; foreach(var p in q) { if (n % 3 == 0) { if (row != null) table1.Append(row); row = EmployerAddressRow.AddPersonsRow(); } row.AddPersonCell(p, addEmployer); if (n % 3 < 2) row.AddSpacerCell(); n++; } if (n % 3 != 0 && row != null) table1.Append(row); Paragraph paragraph54 = new Paragraph() { RsidParagraphMarkRevision = "005A43FA", RsidParagraphAddition = "005A43FA", RsidParagraphProperties = "005A43FA", RsidRunAdditionDefault = "005A43FA" }; ParagraphProperties paragraphProperties54 = new ParagraphProperties(); Indentation indentation54 = new Indentation() { Left = "95", Right = "95" }; ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties(); Vanish vanish1 = new Vanish(); paragraphMarkRunProperties1.Append(vanish1); paragraphProperties54.Append(indentation54); paragraphProperties54.Append(paragraphMarkRunProperties1); paragraph54.Append(paragraphProperties54); SectionProperties sectionProperties1 = new SectionProperties() { RsidRPr = "005A43FA", RsidR = "005A43FA", RsidSect = "005A43FA" }; SectionType sectionType1 = new SectionType() { Val = SectionMarkValues.Continuous }; PageSize pageSize1 = new PageSize() { Width = (UInt32Value)12240U, Height = (UInt32Value)15840U }; PageMargin pageMargin1 = new PageMargin() { Top = 720, Right = (UInt32Value)270U, Bottom = 0, Left = (UInt32Value)270U, Header = (UInt32Value)720U, Footer = (UInt32Value)720U, Gutter = (UInt32Value)0U }; PaperSource paperSource1 = new PaperSource() { First = (UInt16Value)4U, Other = (UInt16Value)4U }; Columns columns1 = new Columns() { Space = "720" }; sectionProperties1.Append(sectionType1); sectionProperties1.Append(pageSize1); sectionProperties1.Append(pageMargin1); sectionProperties1.Append(paperSource1); sectionProperties1.Append(columns1); body1.Append(table1); body1.Append(paragraph54); body1.Append(sectionProperties1); document1.Append(body1); mainDocumentPart1.Document = document1; }
public void DoParagraphBelowTable2(Paragraph paragraph69) { ParagraphProperties paragraphProperties69 = new ParagraphProperties(); ParagraphMarkRunProperties paragraphMarkRunProperties69 = new ParagraphMarkRunProperties(); Vanish vanish1 = new Vanish(); FontSize fontSize118 = new FontSize() { Val = "20" }; paragraphMarkRunProperties69.Append(vanish1); paragraphMarkRunProperties69.Append(fontSize118); paragraphProperties69.Append(paragraphMarkRunProperties69); Run run63 = new Run() { RsidRunProperties = "00D10A17" }; RunProperties runProperties63 = new RunProperties(); RunFonts runFonts131 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" }; FontSize fontSize119 = new FontSize() { Val = "18" }; FontSizeComplexScript fontSizeComplexScript117 = new FontSizeComplexScript() { Val = "22" }; runProperties63.Append(runFonts131); runProperties63.Append(fontSize119); runProperties63.Append(fontSizeComplexScript117); Text text63 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text63.Text = "RECORDED TEMPERATURE IS ACTUAL READING + CORRECTION "; run63.Append(runProperties63); run63.Append(text63); ProofError proofError45 = new ProofError() { Type = ProofingErrorValues.SpellStart }; Run run64 = new Run() { RsidRunProperties = "00D10A17" }; RunProperties runProperties64 = new RunProperties(); RunFonts runFonts132 = new RunFonts() { Ascii = "Arial", HighAnsi = "Arial", ComplexScript = "Arial" }; FontSize fontSize120 = new FontSize() { Val = "18" }; FontSizeComplexScript fontSizeComplexScript118 = new FontSizeComplexScript() { Val = "22" }; runProperties64.Append(runFonts132); runProperties64.Append(fontSize120); runProperties64.Append(fontSizeComplexScript118); Text text64 = new Text(); text64.Text = "FACTOR"; run64.Append(runProperties64); run64.Append(text64); paragraph69.Append(paragraphProperties69); paragraph69.Append(run63); paragraph69.Append(proofError45); paragraph69.Append(run64); }
// Creates an Numbering instance and adds its children. public static Numbering GenerateNumbering() { Numbering numbering1 = new Numbering() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 w15 w16se w16cid wp14" } }; numbering1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"); numbering1.AddNamespaceDeclaration("cx", "http://schemas.microsoft.com/office/drawing/2014/chartex"); numbering1.AddNamespaceDeclaration("cx1", "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex"); numbering1.AddNamespaceDeclaration("cx2", "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex"); numbering1.AddNamespaceDeclaration("cx3", "http://schemas.microsoft.com/office/drawing/2016/5/9/chartex"); numbering1.AddNamespaceDeclaration("cx4", "http://schemas.microsoft.com/office/drawing/2016/5/10/chartex"); numbering1.AddNamespaceDeclaration("cx5", "http://schemas.microsoft.com/office/drawing/2016/5/11/chartex"); numbering1.AddNamespaceDeclaration("cx6", "http://schemas.microsoft.com/office/drawing/2016/5/12/chartex"); numbering1.AddNamespaceDeclaration("cx7", "http://schemas.microsoft.com/office/drawing/2016/5/13/chartex"); numbering1.AddNamespaceDeclaration("cx8", "http://schemas.microsoft.com/office/drawing/2016/5/14/chartex"); numbering1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); numbering1.AddNamespaceDeclaration("aink", "http://schemas.microsoft.com/office/drawing/2016/ink"); numbering1.AddNamespaceDeclaration("am3d", "http://schemas.microsoft.com/office/drawing/2017/model3d"); numbering1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office"); numbering1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); numbering1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); numbering1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml"); numbering1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"); numbering1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); numbering1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word"); numbering1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); numbering1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml"); numbering1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2012/wordml"); numbering1.AddNamespaceDeclaration("w16cid", "http://schemas.microsoft.com/office/word/2016/wordml/cid"); numbering1.AddNamespaceDeclaration("w16se", "http://schemas.microsoft.com/office/word/2015/wordml/symex"); numbering1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"); numbering1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk"); numbering1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); numbering1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); AbstractNum abstractNum1 = new AbstractNum() { AbstractNumberId = 0 }; abstractNum1.SetAttribute(new OpenXmlAttribute("w15", "restartNumberingAfterBreak", "http://schemas.microsoft.com/office/word/2012/wordml", "0")); Nsid nsid1 = new Nsid() { Val = "02791BC6" }; MultiLevelType multiLevelType1 = new MultiLevelType() { Val = MultiLevelValues.Multilevel }; TemplateCode templateCode1 = new TemplateCode() { Val = "565C7098" }; Level level1 = new Level() { LevelIndex = 0 }; StartNumberingValue startNumberingValue1 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat1 = new NumberingFormat() { Val = NumberFormatValues.Decimal }; ParagraphStyleIdInLevel paragraphStyleIdInLevel1 = new ParagraphStyleIdInLevel() { Val = "Heading1" }; LevelSuffix levelSuffix1 = new LevelSuffix() { Val = LevelSuffixValues.Nothing }; LevelText levelText1 = new LevelText() { Val = "Article %1" }; LevelJustification levelJustification1 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties1 = new PreviousParagraphProperties(); Indentation indentation1 = new Indentation() { Left = "0", FirstLine = "0" }; previousParagraphProperties1.Append(indentation1); NumberingSymbolRunProperties numberingSymbolRunProperties1 = new NumberingSymbolRunProperties(); RunFonts runFonts1 = new RunFonts() { Hint = FontTypeHintValues.Default }; numberingSymbolRunProperties1.Append(runFonts1); level1.Append(startNumberingValue1); level1.Append(numberingFormat1); level1.Append(paragraphStyleIdInLevel1); level1.Append(levelSuffix1); level1.Append(levelText1); level1.Append(levelJustification1); level1.Append(previousParagraphProperties1); level1.Append(numberingSymbolRunProperties1); Level level2 = new Level() { LevelIndex = 1 }; StartNumberingValue startNumberingValue2 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat2 = new NumberingFormat() { Val = NumberFormatValues.Decimal }; ParagraphStyleIdInLevel paragraphStyleIdInLevel2 = new ParagraphStyleIdInLevel() { Val = "Heading2" }; LevelText levelText2 = new LevelText() { Val = "%1.%2" }; LevelJustification levelJustification2 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties2 = new PreviousParagraphProperties(); Tabs tabs1 = new Tabs(); TabStop tabStop1 = new TabStop() { Val = TabStopValues.Number, Position = 720 }; tabs1.Append(tabStop1); Indentation indentation2 = new Indentation() { Left = "0", FirstLine = "0" }; previousParagraphProperties2.Append(tabs1); previousParagraphProperties2.Append(indentation2); NumberingSymbolRunProperties numberingSymbolRunProperties2 = new NumberingSymbolRunProperties(); RunFonts runFonts2 = new RunFonts() { Hint = FontTypeHintValues.Default, ComplexScript = "Times New Roman" }; Bold bold1 = new Bold() { Val = false }; Italic italic1 = new Italic() { Val = false }; ItalicComplexScript italicComplexScript1 = new ItalicComplexScript() { Val = false }; Caps caps1 = new Caps() { Val = false }; SmallCaps smallCaps1 = new SmallCaps() { Val = false }; Strike strike1 = new Strike() { Val = false }; DoubleStrike doubleStrike1 = new DoubleStrike() { Val = false }; NoProof noProof1 = new NoProof() { Val = false }; Vanish vanish1 = new Vanish() { Val = false }; Color color1 = new Color() { Val = "000000" }; Spacing spacing1 = new Spacing() { Val = 0 }; Kern kern1 = new Kern() { Val = 0U }; Position position1 = new Position() { Val = "0" }; Underline underline1 = new Underline() { Val = UnderlineValues.None }; TextEffect textEffect1 = new TextEffect() { Val = TextEffectValues.None }; VerticalTextAlignment verticalTextAlignment1 = new VerticalTextAlignment() { Val = VerticalPositionValues.Baseline }; Emphasis emphasis1 = new Emphasis() { Val = EmphasisMarkValues.None }; SpecVanish specVanish1 = new SpecVanish() { Val = false }; OpenXmlUnknownElement openXmlUnknownElement1 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<w14:shadow w14:blurRad=\"0\" w14:dist=\"0\" w14:dir=\"0\" w14:sx=\"0\" w14:sy=\"0\" w14:kx=\"0\" w14:ky=\"0\" w14:algn=\"none\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\"><w14:srgbClr w14:val=\"000000\" /></w14:shadow>"); OpenXmlUnknownElement openXmlUnknownElement2 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<w14:textOutline w14:w=\"0\" w14:cap=\"rnd\" w14:cmpd=\"sng\" w14:algn=\"ctr\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\"><w14:noFill /><w14:prstDash w14:val=\"solid\" /><w14:bevel /></w14:textOutline>"); numberingSymbolRunProperties2.Append(runFonts2); numberingSymbolRunProperties2.Append(bold1); numberingSymbolRunProperties2.Append(italic1); numberingSymbolRunProperties2.Append(italicComplexScript1); numberingSymbolRunProperties2.Append(caps1); numberingSymbolRunProperties2.Append(smallCaps1); numberingSymbolRunProperties2.Append(strike1); numberingSymbolRunProperties2.Append(doubleStrike1); numberingSymbolRunProperties2.Append(noProof1); numberingSymbolRunProperties2.Append(vanish1); numberingSymbolRunProperties2.Append(color1); numberingSymbolRunProperties2.Append(spacing1); numberingSymbolRunProperties2.Append(kern1); numberingSymbolRunProperties2.Append(position1); numberingSymbolRunProperties2.Append(underline1); numberingSymbolRunProperties2.Append(textEffect1); numberingSymbolRunProperties2.Append(verticalTextAlignment1); numberingSymbolRunProperties2.Append(emphasis1); numberingSymbolRunProperties2.Append(specVanish1); numberingSymbolRunProperties2.Append(openXmlUnknownElement1); numberingSymbolRunProperties2.Append(openXmlUnknownElement2); level2.Append(startNumberingValue2); level2.Append(numberingFormat2); level2.Append(paragraphStyleIdInLevel2); level2.Append(levelText2); level2.Append(levelJustification2); level2.Append(previousParagraphProperties2); level2.Append(numberingSymbolRunProperties2); Level level3 = new Level() { LevelIndex = 2 }; StartNumberingValue startNumberingValue3 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat3 = new NumberingFormat() { Val = NumberFormatValues.LowerLetter }; ParagraphStyleIdInLevel paragraphStyleIdInLevel3 = new ParagraphStyleIdInLevel() { Val = "Heading3" }; LevelText levelText3 = new LevelText() { Val = "(%3)" }; LevelJustification levelJustification3 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties3 = new PreviousParagraphProperties(); Tabs tabs2 = new Tabs(); TabStop tabStop2 = new TabStop() { Val = TabStopValues.Number, Position = 1800 }; tabs2.Append(tabStop2); Indentation indentation3 = new Indentation() { Left = "1800", Hanging = "720" }; previousParagraphProperties3.Append(tabs2); previousParagraphProperties3.Append(indentation3); NumberingSymbolRunProperties numberingSymbolRunProperties3 = new NumberingSymbolRunProperties(); RunFonts runFonts3 = new RunFonts() { Hint = FontTypeHintValues.Default }; numberingSymbolRunProperties3.Append(runFonts3); level3.Append(startNumberingValue3); level3.Append(numberingFormat3); level3.Append(paragraphStyleIdInLevel3); level3.Append(levelText3); level3.Append(levelJustification3); level3.Append(previousParagraphProperties3); level3.Append(numberingSymbolRunProperties3); Level level4 = new Level() { LevelIndex = 3 }; StartNumberingValue startNumberingValue4 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat4 = new NumberingFormat() { Val = NumberFormatValues.LowerRoman }; ParagraphStyleIdInLevel paragraphStyleIdInLevel4 = new ParagraphStyleIdInLevel() { Val = "Heading4" }; LevelText levelText4 = new LevelText() { Val = "(%4)" }; LevelJustification levelJustification4 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties4 = new PreviousParagraphProperties(); Tabs tabs3 = new Tabs(); TabStop tabStop3 = new TabStop() { Val = TabStopValues.Number, Position = 2160 }; tabs3.Append(tabStop3); Indentation indentation4 = new Indentation() { Left = "2160", Hanging = "720" }; previousParagraphProperties4.Append(tabs3); previousParagraphProperties4.Append(indentation4); NumberingSymbolRunProperties numberingSymbolRunProperties4 = new NumberingSymbolRunProperties(); RunFonts runFonts4 = new RunFonts() { Hint = FontTypeHintValues.Default }; Bold bold2 = new Bold() { Val = false }; Italic italic2 = new Italic() { Val = false }; numberingSymbolRunProperties4.Append(runFonts4); numberingSymbolRunProperties4.Append(bold2); numberingSymbolRunProperties4.Append(italic2); level4.Append(startNumberingValue4); level4.Append(numberingFormat4); level4.Append(paragraphStyleIdInLevel4); level4.Append(levelText4); level4.Append(levelJustification4); level4.Append(previousParagraphProperties4); level4.Append(numberingSymbolRunProperties4); Level level5 = new Level() { LevelIndex = 4 }; StartNumberingValue startNumberingValue5 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat5 = new NumberingFormat() { Val = NumberFormatValues.LowerLetter }; ParagraphStyleIdInLevel paragraphStyleIdInLevel5 = new ParagraphStyleIdInLevel() { Val = "Heading5" }; LevelText levelText5 = new LevelText() { Val = "%5)" }; LevelJustification levelJustification5 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties5 = new PreviousParagraphProperties(); Tabs tabs4 = new Tabs(); TabStop tabStop4 = new TabStop() { Val = TabStopValues.Number, Position = 2880 }; tabs4.Append(tabStop4); Indentation indentation5 = new Indentation() { Left = "2880", Hanging = "720" }; previousParagraphProperties5.Append(tabs4); previousParagraphProperties5.Append(indentation5); NumberingSymbolRunProperties numberingSymbolRunProperties5 = new NumberingSymbolRunProperties(); RunFonts runFonts5 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Book Antiqua", HighAnsi = "Book Antiqua" }; Bold bold3 = new Bold() { Val = false }; Italic italic3 = new Italic() { Val = false }; FontSize fontSize1 = new FontSize() { Val = "22" }; numberingSymbolRunProperties5.Append(runFonts5); numberingSymbolRunProperties5.Append(bold3); numberingSymbolRunProperties5.Append(italic3); numberingSymbolRunProperties5.Append(fontSize1); level5.Append(startNumberingValue5); level5.Append(numberingFormat5); level5.Append(paragraphStyleIdInLevel5); level5.Append(levelText5); level5.Append(levelJustification5); level5.Append(previousParagraphProperties5); level5.Append(numberingSymbolRunProperties5); Level level6 = new Level() { LevelIndex = 5 }; StartNumberingValue startNumberingValue6 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat6 = new NumberingFormat() { Val = NumberFormatValues.LowerRoman }; ParagraphStyleIdInLevel paragraphStyleIdInLevel6 = new ParagraphStyleIdInLevel() { Val = "Heading6" }; LevelText levelText6 = new LevelText() { Val = "(%6)" }; LevelJustification levelJustification6 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties6 = new PreviousParagraphProperties(); Tabs tabs5 = new Tabs(); TabStop tabStop5 = new TabStop() { Val = TabStopValues.Number, Position = 1440 }; tabs5.Append(tabStop5); Indentation indentation6 = new Indentation() { Left = "1440", Hanging = "720" }; previousParagraphProperties6.Append(tabs5); previousParagraphProperties6.Append(indentation6); NumberingSymbolRunProperties numberingSymbolRunProperties6 = new NumberingSymbolRunProperties(); RunFonts runFonts6 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Book Antiqua", HighAnsi = "Book Antiqua" }; Bold bold4 = new Bold() { Val = false }; Italic italic4 = new Italic() { Val = false }; FontSize fontSize2 = new FontSize() { Val = "22" }; numberingSymbolRunProperties6.Append(runFonts6); numberingSymbolRunProperties6.Append(bold4); numberingSymbolRunProperties6.Append(italic4); numberingSymbolRunProperties6.Append(fontSize2); level6.Append(startNumberingValue6); level6.Append(numberingFormat6); level6.Append(paragraphStyleIdInLevel6); level6.Append(levelText6); level6.Append(levelJustification6); level6.Append(previousParagraphProperties6); level6.Append(numberingSymbolRunProperties6); Level level7 = new Level() { LevelIndex = 6 }; StartNumberingValue startNumberingValue7 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat7 = new NumberingFormat() { Val = NumberFormatValues.Decimal }; LevelText levelText7 = new LevelText() { Val = "%1.%2.%3.%4.%5.%6.%7." }; LevelJustification levelJustification7 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties7 = new PreviousParagraphProperties(); Tabs tabs6 = new Tabs(); TabStop tabStop6 = new TabStop() { Val = TabStopValues.Number, Position = 5400 }; tabs6.Append(tabStop6); Indentation indentation7 = new Indentation() { Left = "3240", Hanging = "1080" }; previousParagraphProperties7.Append(tabs6); previousParagraphProperties7.Append(indentation7); NumberingSymbolRunProperties numberingSymbolRunProperties7 = new NumberingSymbolRunProperties(); RunFonts runFonts7 = new RunFonts() { Hint = FontTypeHintValues.Default }; numberingSymbolRunProperties7.Append(runFonts7); level7.Append(startNumberingValue7); level7.Append(numberingFormat7); level7.Append(levelText7); level7.Append(levelJustification7); level7.Append(previousParagraphProperties7); level7.Append(numberingSymbolRunProperties7); Level level8 = new Level() { LevelIndex = 7 }; StartNumberingValue startNumberingValue8 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat8 = new NumberingFormat() { Val = NumberFormatValues.Decimal }; LevelText levelText8 = new LevelText() { Val = "%1.%2.%3.%4.%5.%6.%7.%8." }; LevelJustification levelJustification8 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties8 = new PreviousParagraphProperties(); Tabs tabs7 = new Tabs(); TabStop tabStop7 = new TabStop() { Val = TabStopValues.Number, Position = 6120 }; tabs7.Append(tabStop7); Indentation indentation8 = new Indentation() { Left = "3744", Hanging = "1224" }; previousParagraphProperties8.Append(tabs7); previousParagraphProperties8.Append(indentation8); NumberingSymbolRunProperties numberingSymbolRunProperties8 = new NumberingSymbolRunProperties(); RunFonts runFonts8 = new RunFonts() { Hint = FontTypeHintValues.Default }; numberingSymbolRunProperties8.Append(runFonts8); level8.Append(startNumberingValue8); level8.Append(numberingFormat8); level8.Append(levelText8); level8.Append(levelJustification8); level8.Append(previousParagraphProperties8); level8.Append(numberingSymbolRunProperties8); Level level9 = new Level() { LevelIndex = 8 }; StartNumberingValue startNumberingValue9 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat9 = new NumberingFormat() { Val = NumberFormatValues.Decimal }; LevelText levelText9 = new LevelText() { Val = "%1.%2.%3.%4.%5.%6.%7.%8.%9." }; LevelJustification levelJustification9 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties9 = new PreviousParagraphProperties(); Tabs tabs8 = new Tabs(); TabStop tabStop8 = new TabStop() { Val = TabStopValues.Number, Position = 6840 }; tabs8.Append(tabStop8); Indentation indentation9 = new Indentation() { Left = "4320", Hanging = "1440" }; previousParagraphProperties9.Append(tabs8); previousParagraphProperties9.Append(indentation9); NumberingSymbolRunProperties numberingSymbolRunProperties9 = new NumberingSymbolRunProperties(); RunFonts runFonts9 = new RunFonts() { Hint = FontTypeHintValues.Default }; numberingSymbolRunProperties9.Append(runFonts9); level9.Append(startNumberingValue9); level9.Append(numberingFormat9); level9.Append(levelText9); level9.Append(levelJustification9); level9.Append(previousParagraphProperties9); level9.Append(numberingSymbolRunProperties9); abstractNum1.Append(nsid1); abstractNum1.Append(multiLevelType1); abstractNum1.Append(templateCode1); abstractNum1.Append(level1); abstractNum1.Append(level2); abstractNum1.Append(level3); abstractNum1.Append(level4); abstractNum1.Append(level5); abstractNum1.Append(level6); abstractNum1.Append(level7); abstractNum1.Append(level8); abstractNum1.Append(level9); NumberingInstance numberingInstance1 = new NumberingInstance() { NumberID = 1 }; AbstractNumId abstractNumId1 = new AbstractNumId() { Val = 0 }; LevelOverride levelOverride1 = new LevelOverride() { LevelIndex = 0 }; StartOverrideNumberingValue startOverrideNumberingValue1 = new StartOverrideNumberingValue() { Val = 2 }; levelOverride1.Append(startOverrideNumberingValue1); LevelOverride levelOverride2 = new LevelOverride() { LevelIndex = 1 }; StartOverrideNumberingValue startOverrideNumberingValue2 = new StartOverrideNumberingValue() { Val = 1 }; levelOverride2.Append(startOverrideNumberingValue2); LevelOverride levelOverride3 = new LevelOverride() { LevelIndex = 2 }; StartOverrideNumberingValue startOverrideNumberingValue3 = new StartOverrideNumberingValue() { Val = 1 }; levelOverride3.Append(startOverrideNumberingValue3); LevelOverride levelOverride4 = new LevelOverride() { LevelIndex = 3 }; StartOverrideNumberingValue startOverrideNumberingValue4 = new StartOverrideNumberingValue() { Val = 1 }; levelOverride4.Append(startOverrideNumberingValue4); LevelOverride levelOverride5 = new LevelOverride() { LevelIndex = 4 }; StartOverrideNumberingValue startOverrideNumberingValue5 = new StartOverrideNumberingValue() { Val = 1 }; levelOverride5.Append(startOverrideNumberingValue5); LevelOverride levelOverride6 = new LevelOverride() { LevelIndex = 5 }; StartOverrideNumberingValue startOverrideNumberingValue6 = new StartOverrideNumberingValue() { Val = 1 }; levelOverride6.Append(startOverrideNumberingValue6); LevelOverride levelOverride7 = new LevelOverride() { LevelIndex = 6 }; StartOverrideNumberingValue startOverrideNumberingValue7 = new StartOverrideNumberingValue() { Val = 1 }; levelOverride7.Append(startOverrideNumberingValue7); LevelOverride levelOverride8 = new LevelOverride() { LevelIndex = 7 }; StartOverrideNumberingValue startOverrideNumberingValue8 = new StartOverrideNumberingValue() { Val = 1 }; levelOverride8.Append(startOverrideNumberingValue8); LevelOverride levelOverride9 = new LevelOverride() { LevelIndex = 8 }; StartOverrideNumberingValue startOverrideNumberingValue9 = new StartOverrideNumberingValue() { Val = 1 }; levelOverride9.Append(startOverrideNumberingValue9); numberingInstance1.Append(abstractNumId1); numberingInstance1.Append(levelOverride1); numberingInstance1.Append(levelOverride2); numberingInstance1.Append(levelOverride3); numberingInstance1.Append(levelOverride4); numberingInstance1.Append(levelOverride5); numberingInstance1.Append(levelOverride6); numberingInstance1.Append(levelOverride7); numberingInstance1.Append(levelOverride8); numberingInstance1.Append(levelOverride9); NumberingInstance numberingInstance2 = new NumberingInstance() { NumberID = 2 }; AbstractNumId abstractNumId2 = new AbstractNumId() { Val = 0 }; numberingInstance2.Append(abstractNumId2); numbering1.Append(abstractNum1); numbering1.Append(numberingInstance1); numbering1.Append(numberingInstance2); return(numbering1); }
// Creates an Document instance and adds its children. public void GenerateLabelsDocument(string fileName, List<Interview> candidateList) { Document document1 = new Document(){ MCAttributes = new MarkupCompatibilityAttributes(){ Ignorable = "w14 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("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(); DocumentFormat.OpenXml.Wordprocessing.Table table1 = new DocumentFormat.OpenXml.Wordprocessing.Table(); TableProperties tableProperties1 = new TableProperties(); DocumentFormat.OpenXml.Wordprocessing.TableStyle tableStyle1 = new DocumentFormat.OpenXml.Wordprocessing.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); TableLayout tableLayout1 = new TableLayout(){ Type = TableLayoutValues.Fixed }; TableCellMarginDefault tableCellMarginDefault1 = new TableCellMarginDefault(); TableCellLeftMargin tableCellLeftMargin1 = new TableCellLeftMargin(){ Width = 15, Type = TableWidthValues.Dxa }; TableCellRightMargin tableCellRightMargin1 = new TableCellRightMargin(){ Width = 15, Type = TableWidthValues.Dxa }; tableCellMarginDefault1.Append(tableCellLeftMargin1); tableCellMarginDefault1.Append(tableCellRightMargin1); TableLook tableLook1 = new TableLook(){ Val = "0000", FirstRow = false, LastRow = false, FirstColumn = false, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = false }; tableProperties1.Append(tableStyle1); tableProperties1.Append(tableWidth1); tableProperties1.Append(tableBorders1); tableProperties1.Append(tableLayout1); tableProperties1.Append(tableCellMarginDefault1); tableProperties1.Append(tableLook1); table1.Append(tableProperties1); TableGrid tableGrid1 = new TableGrid(); GridColumn gridColumn1 = new GridColumn(){ Width = "5760" }; GridColumn gridColumn2 = new GridColumn(){ Width = "270" }; GridColumn gridColumn3 = new GridColumn(){ Width = "5760" }; tableGrid1.Append(gridColumn1); tableGrid1.Append(gridColumn2); tableGrid1.Append(gridColumn3); table1.Append(tableGrid1); string sex = Sex.M.ToString(); Interview interview1, interview2; BioData bioData1, bioData2; for(int i = 0; i < candidateList.Count(); i=i+2) { interview1 = candidateList.ElementAt(i); bioData1 = interview1.BioData; if ((i + 1) < candidateList.Count()) { interview2 = candidateList.ElementAt(i + 1); bioData2 = interview2.BioData; } else { interview2 = null; bioData2 = null; } DocumentFormat.OpenXml.Wordprocessing.TableRow tableRow1 = new DocumentFormat.OpenXml.Wordprocessing.TableRow() { RsidTableRowAddition = "003D48DC" }; TablePropertyExceptions tablePropertyExceptions1 = new TablePropertyExceptions(); TableCellMarginDefault tableCellMarginDefault2 = new TableCellMarginDefault(); TopMargin topMargin1 = new TopMargin() { Width = "0", Type = TableWidthUnitValues.Dxa }; BottomMargin bottomMargin1 = new BottomMargin() { Width = "0", Type = TableWidthUnitValues.Dxa }; tableCellMarginDefault2.Append(topMargin1); tableCellMarginDefault2.Append(bottomMargin1); tablePropertyExceptions1.Append(tableCellMarginDefault2); TableRowProperties tableRowProperties1 = new TableRowProperties(); CantSplit cantSplit1 = new CantSplit(); TableRowHeight tableRowHeight1 = new TableRowHeight() { Val = (UInt32Value)1440U, HeightType = HeightRuleValues.Exact }; tableRowProperties1.Append(cantSplit1); tableRowProperties1.Append(tableRowHeight1); DocumentFormat.OpenXml.Wordprocessing.TableCell tableCell1 = new DocumentFormat.OpenXml.Wordprocessing.TableCell(); TableCellProperties tableCellProperties1 = new TableCellProperties(); TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = "5760", Type = TableWidthUnitValues.Dxa }; tableCellProperties1.Append(tableCellWidth1); Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "003D48DC", RsidParagraphProperties = "003D48DC", RsidRunAdditionDefault = "003D48DC" }; ParagraphProperties paragraphProperties1 = new ParagraphProperties(); Indentation indentation1 = new Indentation() { Left = "144", Right = "144" }; paragraphProperties1.Append(indentation1); Run run1 = new Run(); Text text1 = new Text(); Text text1_2 = new Text(); text1.Text = bioData1.LName + ", " + bioData1.FName + ", " + bioData1.MName + " " + bioData1.Sources.SourcesValue; text1_2.Text = bioData1.SSN + " " + interview1.Date.Value.ToShortDateString(); run1.Append(text1); run1.Append(new Break()); run1.Append(text1_2); paragraph1.Append(paragraphProperties1); paragraph1.Append(run1); tableCell1.Append(tableCellProperties1); tableCell1.Append(paragraph1); DocumentFormat.OpenXml.Wordprocessing.TableCell tableCell2 = new DocumentFormat.OpenXml.Wordprocessing.TableCell(); TableCellProperties tableCellProperties2 = new TableCellProperties(); TableCellWidth tableCellWidth2 = new TableCellWidth() { Width = "270", Type = TableWidthUnitValues.Dxa }; tableCellProperties2.Append(tableCellWidth2); Paragraph paragraph2 = new Paragraph() { RsidParagraphAddition = "003D48DC", RsidParagraphProperties = "003D48DC", RsidRunAdditionDefault = "003D48DC" }; ParagraphProperties paragraphProperties2 = new ParagraphProperties(); Indentation indentation2 = new Indentation() { Left = "144", Right = "144" }; paragraphProperties2.Append(indentation2); paragraph2.Append(paragraphProperties2); tableCell2.Append(tableCellProperties2); tableCell2.Append(paragraph2); DocumentFormat.OpenXml.Wordprocessing.TableCell tableCell3 = new DocumentFormat.OpenXml.Wordprocessing.TableCell(); TableCellProperties tableCellProperties3 = new TableCellProperties(); TableCellWidth tableCellWidth3 = new TableCellWidth() { Width = "5760", Type = TableWidthUnitValues.Dxa }; tableCellProperties3.Append(tableCellWidth3); Paragraph paragraph3 = new Paragraph() { RsidParagraphAddition = "003D48DC", RsidParagraphProperties = "003D48DC", RsidRunAdditionDefault = "003D48DC" }; ParagraphProperties paragraphProperties3 = new ParagraphProperties(); Indentation indentation3 = new Indentation() { Left = "144", Right = "144" }; paragraphProperties3.Append(indentation3); Run run2 = new Run(); Text text2 = new Text(); Text text2_2 = new Text(); if (bioData2 != null) { text2.Text = bioData2.LName + ", " + bioData2.FName + ", " + bioData2.MName + " " + bioData2.Sources.SourcesValue; text2_2.Text = bioData2.SSN + " " + interview2.Date.Value.ToShortDateString(); } else { text2.Text = ""; text2_2.Text = ""; } run2.Append(text2); run2.Append(new Break()); run2.Append(text2_2); paragraph3.Append(paragraphProperties3); paragraph3.Append(run2); tableCell3.Append(tableCellProperties3); tableCell3.Append(paragraph3); tableRow1.Append(tablePropertyExceptions1); tableRow1.Append(tableRowProperties1); tableRow1.Append(tableCell1); tableRow1.Append(tableCell2); tableRow1.Append(tableCell3); table1.Append(tableRow1); } Paragraph paragraph31 = new Paragraph() { RsidParagraphMarkRevision = "003D48DC", RsidParagraphAddition = "003D48DC", RsidParagraphProperties = "003D48DC", RsidRunAdditionDefault = "003D48DC" }; ParagraphProperties paragraphProperties31 = new ParagraphProperties(); Indentation indentation31 = new Indentation() { Left = "144", Right = "144" }; ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties(); Vanish vanish1 = new Vanish(); paragraphMarkRunProperties1.Append(vanish1); paragraphProperties31.Append(indentation31); paragraphProperties31.Append(paragraphMarkRunProperties1); paragraph31.Append(paragraphProperties31); SectionProperties sectionProperties1 = new SectionProperties() { RsidRPr = "003D48DC", RsidR = "003D48DC", RsidSect = "003D48DC" }; SectionType sectionType1 = new SectionType() { Val = SectionMarkValues.Continuous }; PageSize pageSize1 = new PageSize() { Width = (UInt32Value)12240U, Height = (UInt32Value)15840U }; PageMargin pageMargin1 = new PageMargin() { Top = 720, Right = (UInt32Value)240U, Bottom = 0, Left = (UInt32Value)240U, Header = (UInt32Value)720U, Footer = (UInt32Value)720U, Gutter = (UInt32Value)0U }; Columns columns1 = new Columns() { Space = "720" }; sectionProperties1.Append(sectionType1); sectionProperties1.Append(pageSize1); sectionProperties1.Append(pageMargin1); sectionProperties1.Append(columns1); body1.Append(table1); body1.Append(paragraph31); body1.Append(sectionProperties1); document1.Append(body1); //return document1; string contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; using (MemoryStream generatedDocument = new MemoryStream()) { using (WordprocessingDocument package = WordprocessingDocument.Create(generatedDocument, WordprocessingDocumentType.Document)) { MainDocumentPart mainPart = package.MainDocumentPart; if (mainPart == null) { mainPart = package.AddMainDocumentPart(); document1.Save(mainPart); } Body body = mainPart.Document.Body; //I have no idea why it doesnt work when you try to use pageBreakParagraph... but it doesnt... so redeclare this same string here string lineBreakCharacter = "%$%lineBreak%$%"; List<Paragraph> pageBreakMarkers = new List<Paragraph>(); var lastP = mainPart.Document.Descendants<Paragraph>().LastOrDefault(); foreach (Paragraph P in mainPart.Document.Descendants<Paragraph>()) { foreach (Run R in P.Descendants<Run>()) { if (R.Descendants<Text>() .Where(T => T.Text == lineBreakCharacter).Count() > 0) { if (P != lastP) { P.InsertAfterSelf (new Paragraph( new Run( new Break() { Type = BreakValues.Page }))); } pageBreakMarkers.Add(P); } } } foreach (Paragraph P in pageBreakMarkers) { P.Remove(); } mainPart.Document.Save(); } byte[] bytesInStream = generatedDocument.ToArray(); // simpler way of converting to array generatedDocument.Close(); Response.Clear(); Response.ContentType = contentType; Response.AddHeader("content-disposition", "attachment;filename=" + fileName); //this will generate problems Response.BinaryWrite(bytesInStream); try { Response.End(); } catch (Exception ex) { //Response.End(); generates an exception. if you don't use it, you get some errors when Word opens the file... System.Diagnostics.Debug.WriteLine(ex.Message); } } }