public static Footer GenerateFooter() { Footer footer1 = new Footer() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 wp14" } }; footer1.SetAttribute(new OpenXmlAttribute("xmlns", "wpi", "http://www.w3.org/2000/xmlns/", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk")); SdtBlock sdtBlock1 = new SdtBlock(); SdtProperties sdtProperties1 = new SdtProperties(); SdtId sdtId1 = new SdtId() { Val = -2004816677 }; SdtContentDocPartObject sdtContentDocPartObject1 = new SdtContentDocPartObject(); DocPartGallery docPartGallery1 = new DocPartGallery() { Val = "Page Numbers (Bottom of Page)" }; DocPartUnique docPartUnique1 = new DocPartUnique(); sdtContentDocPartObject1.Append(docPartGallery1); sdtContentDocPartObject1.Append(docPartUnique1); sdtProperties1.Append(sdtId1); sdtProperties1.Append(sdtContentDocPartObject1); SdtContentBlock sdtContentBlock1 = new SdtContentBlock(); SdtBlock sdtBlock2 = new SdtBlock(); SdtProperties sdtProperties2 = new SdtProperties(); SdtId sdtId2 = new SdtId() { Val = 262557138 }; SdtContentDocPartObject sdtContentDocPartObject2 = new SdtContentDocPartObject(); DocPartGallery docPartGallery2 = new DocPartGallery() { Val = "Page Numbers (Top of Page)" }; DocPartUnique docPartUnique2 = new DocPartUnique(); sdtContentDocPartObject2.Append(docPartGallery2); sdtContentDocPartObject2.Append(docPartUnique2); sdtProperties2.Append(sdtId2); sdtProperties2.Append(sdtContentDocPartObject2); SdtContentBlock sdtContentBlock2 = new SdtContentBlock(); Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "000A3202", RsidRunAdditionDefault = "000A3202", ParagraphId = "450F18F9", TextId = "3669B4E6" }; ParagraphProperties paragraphProperties1 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId1 = new ParagraphStyleId() { Val = "a6" }; Justification justification1 = new Justification() { Val = JustificationValues.Center }; paragraphProperties1.Append(paragraphStyleId1); paragraphProperties1.Append(justification1); Run run1 = new Run(); Text text1 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text1.Text = "Страница "; run1.Append(text1); Run run2 = new Run(); RunProperties runProperties1 = new RunProperties(); Bold bold1 = new Bold(); FontSize fontSize1 = new FontSize() { Val = "24" }; FontSizeComplexScript fontSizeComplexScript1 = new FontSizeComplexScript() { Val = "24" }; runProperties1.Append(bold1); runProperties1.Append(fontSize1); runProperties1.Append(fontSizeComplexScript1); FieldChar fieldChar1 = new FieldChar() { FieldCharType = FieldCharValues.Begin }; run2.Append(runProperties1); run2.Append(fieldChar1); Run run3 = new Run(); RunProperties runProperties2 = new RunProperties(); Bold bold2 = new Bold(); runProperties2.Append(bold2); FieldCode fieldCode1 = new FieldCode(); fieldCode1.Text = "PAGE"; run3.Append(runProperties2); run3.Append(fieldCode1); Run run4 = new Run(); RunProperties runProperties3 = new RunProperties(); Bold bold3 = new Bold(); FontSize fontSize2 = new FontSize() { Val = "24" }; FontSizeComplexScript fontSizeComplexScript2 = new FontSizeComplexScript() { Val = "24" }; runProperties3.Append(bold3); runProperties3.Append(fontSize2); runProperties3.Append(fontSizeComplexScript2); FieldChar fieldChar2 = new FieldChar() { FieldCharType = FieldCharValues.Separate }; run4.Append(runProperties3); run4.Append(fieldChar2); Run run5 = new Run(); RunProperties runProperties4 = new RunProperties(); Bold bold4 = new Bold(); NoProof noProof1 = new NoProof(); runProperties4.Append(bold4); runProperties4.Append(noProof1); Text text2 = new Text(); text2.Text = "2"; run5.Append(runProperties4); run5.Append(text2); Run run6 = new Run(); RunProperties runProperties5 = new RunProperties(); Bold bold5 = new Bold(); FontSize fontSize3 = new FontSize() { Val = "24" }; FontSizeComplexScript fontSizeComplexScript3 = new FontSizeComplexScript() { Val = "24" }; runProperties5.Append(bold5); runProperties5.Append(fontSize3); runProperties5.Append(fontSizeComplexScript3); FieldChar fieldChar3 = new FieldChar() { FieldCharType = FieldCharValues.End }; run6.Append(runProperties5); run6.Append(fieldChar3); Run run7 = new Run(); Text text3 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text3.Text = " из "; run7.Append(text3); Run run8 = new Run(); RunProperties runProperties6 = new RunProperties(); Bold bold6 = new Bold(); FontSize fontSize4 = new FontSize() { Val = "24" }; FontSizeComplexScript fontSizeComplexScript4 = new FontSizeComplexScript() { Val = "24" }; runProperties6.Append(bold6); runProperties6.Append(fontSize4); runProperties6.Append(fontSizeComplexScript4); FieldChar fieldChar4 = new FieldChar() { FieldCharType = FieldCharValues.Begin }; run8.Append(runProperties6); run8.Append(fieldChar4); Run run9 = new Run(); RunProperties runProperties7 = new RunProperties(); Bold bold7 = new Bold(); runProperties7.Append(bold7); FieldCode fieldCode2 = new FieldCode(); fieldCode2.Text = "NUMPAGES"; run9.Append(runProperties7); run9.Append(fieldCode2); Run run10 = new Run(); RunProperties runProperties8 = new RunProperties(); Bold bold8 = new Bold(); FontSize fontSize5 = new FontSize() { Val = "24" }; FontSizeComplexScript fontSizeComplexScript5 = new FontSizeComplexScript() { Val = "24" }; runProperties8.Append(bold8); runProperties8.Append(fontSize5); runProperties8.Append(fontSizeComplexScript5); FieldChar fieldChar5 = new FieldChar() { FieldCharType = FieldCharValues.Separate }; run10.Append(runProperties8); run10.Append(fieldChar5); Run run11 = new Run(); RunProperties runProperties9 = new RunProperties(); Bold bold9 = new Bold(); NoProof noProof2 = new NoProof(); runProperties9.Append(bold9); runProperties9.Append(noProof2); Text text4 = new Text(); text4.Text = "2"; run11.Append(runProperties9); run11.Append(text4); Run run12 = new Run(); RunProperties runProperties10 = new RunProperties(); Bold bold10 = new Bold(); FontSize fontSize6 = new FontSize() { Val = "24" }; FontSizeComplexScript fontSizeComplexScript6 = new FontSizeComplexScript() { Val = "24" }; runProperties10.Append(bold10); runProperties10.Append(fontSize6); runProperties10.Append(fontSizeComplexScript6); FieldChar fieldChar6 = new FieldChar() { FieldCharType = FieldCharValues.End }; run12.Append(runProperties10); run12.Append(fieldChar6); paragraph1.Append(paragraphProperties1); paragraph1.Append(run1); paragraph1.Append(run2); paragraph1.Append(run3); paragraph1.Append(run4); paragraph1.Append(run5); paragraph1.Append(run6); paragraph1.Append(run7); paragraph1.Append(run8); paragraph1.Append(run9); paragraph1.Append(run10); paragraph1.Append(run11); paragraph1.Append(run12); sdtContentBlock2.Append(paragraph1); sdtBlock2.Append(sdtProperties2); sdtBlock2.Append(sdtContentBlock2); sdtContentBlock1.Append(sdtBlock2); sdtBlock1.Append(sdtProperties1); sdtBlock1.Append(sdtContentBlock1); Paragraph paragraph2 = new Paragraph() { RsidParagraphAddition = "000A3202", RsidRunAdditionDefault = "000A3202", ParagraphId = "7CCB7F19", TextId = "77777777" }; ParagraphProperties paragraphProperties2 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId2 = new ParagraphStyleId() { Val = "a6" }; paragraphProperties2.Append(paragraphStyleId2); paragraph2.Append(paragraphProperties2); footer1.Append(sdtBlock1); footer1.Append(paragraph2); return(footer1); }
// Generates content of footerPart1. private void GenerateFooterPart1Content(FooterPart footerPart1) { Footer footer1 = new Footer() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 w15 w16se wp14" } }; footer1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"); footer1.AddNamespaceDeclaration("cx", "http://schemas.microsoft.com/office/drawing/2014/chartex"); footer1.AddNamespaceDeclaration("cx1", "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex"); footer1.AddNamespaceDeclaration("cx2", "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex"); footer1.AddNamespaceDeclaration("mc", "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("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"); 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("w14", "http://schemas.microsoft.com/office/word/2010/wordml"); footer1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2012/wordml"); footer1.AddNamespaceDeclaration("w16se", "http://schemas.microsoft.com/office/word/2015/wordml/symex"); footer1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"); footer1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk"); footer1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); footer1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); SdtBlock sdtBlock1 = new SdtBlock(); SdtProperties sdtProperties50 = new SdtProperties(); SdtId sdtId50 = new SdtId() { Val = -1161223993 }; SdtContentDocPartObject sdtContentDocPartObject1 = new SdtContentDocPartObject(); DocPartGallery docPartGallery1 = new DocPartGallery() { Val = "Page Numbers (Bottom of Page)" }; DocPartUnique docPartUnique1 = new DocPartUnique(); sdtContentDocPartObject1.Append(docPartGallery1); sdtContentDocPartObject1.Append(docPartUnique1); sdtProperties50.Append(sdtId50); sdtProperties50.Append(sdtContentDocPartObject1); SdtEndCharProperties sdtEndCharProperties50 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock1 = new SdtContentBlock(); Paragraph paragraph369 = new Paragraph() { RsidParagraphAddition = "0094109A", RsidParagraphProperties = "00697199", RsidRunAdditionDefault = "00A563A2", ParagraphId = "3CF2B95B", TextId = "59B2ED64" }; ParagraphProperties paragraphProperties366 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId26 = new ParagraphStyleId() { Val = "Footer" }; paragraphProperties366.Append(paragraphStyleId26); Hyperlink hyperlink1 = new Hyperlink() { History = true, Id = "rId1" }; Run run738 = new Run() { RsidRunProperties = "00697199", RsidRunAddition = "00697199" }; RunProperties runProperties780 = new RunProperties(); FontSize fontSize1048 = new FontSize() { Val = "20" }; FontSizeComplexScript fontSizeComplexScript1034 = new FontSizeComplexScript() { Val = "20" }; runProperties780.Append(fontSize1048); runProperties780.Append(fontSizeComplexScript1034); Text text700 = new Text(); text700.Text = "BJC IS Tech Management Standards"; run738.Append(runProperties780); run738.Append(text700); hyperlink1.Append(run738); Run run739 = new Run() { RsidRunProperties = "00697199", RsidRunAddition = "00697199" }; RunProperties runProperties781 = new RunProperties(); FontSize fontSize1049 = new FontSize() { Val = "20" }; FontSizeComplexScript fontSizeComplexScript1035 = new FontSizeComplexScript() { Val = "20" }; runProperties781.Append(fontSize1049); runProperties781.Append(fontSizeComplexScript1035); Text text701 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text701.Text = " can be found at: "; run739.Append(runProperties781); run739.Append(text701); Hyperlink hyperlink2 = new Hyperlink() { History = true, Id = "rId2" }; Run run740 = new Run() { RsidRunProperties = "00697199", RsidRunAddition = "00697199" }; RunProperties runProperties782 = new RunProperties(); RunStyle runStyle2 = new RunStyle() { Val = "Hyperlink" }; FontSize fontSize1050 = new FontSize() { Val = "20" }; FontSizeComplexScript fontSizeComplexScript1036 = new FontSizeComplexScript() { Val = "20" }; runProperties782.Append(runStyle2); runProperties782.Append(fontSize1050); runProperties782.Append(fontSizeComplexScript1036); Text text702 = new Text(); text702.Text = "http://bjcis/sites/techservices/Informational%20Documents/Forms/AllItems.aspx"; run740.Append(runProperties782); run740.Append(text702); hyperlink2.Append(run740); Run run741 = new Run() { RsidRunProperties = "00697199", RsidRunAddition = "00697199" }; RunProperties runProperties783 = new RunProperties(); FontSize fontSize1051 = new FontSize() { Val = "20" }; FontSizeComplexScript fontSizeComplexScript1037 = new FontSizeComplexScript() { Val = "20" }; runProperties783.Append(fontSize1051); runProperties783.Append(fontSizeComplexScript1037); TabChar tabChar45 = new TabChar(); run741.Append(runProperties783); run741.Append(tabChar45); Run run742 = new Run() { RsidRunAddition = "00697199" }; RunProperties runProperties784 = new RunProperties(); FontSize fontSize1052 = new FontSize() { Val = "20" }; FontSizeComplexScript fontSizeComplexScript1038 = new FontSizeComplexScript() { Val = "20" }; runProperties784.Append(fontSize1052); runProperties784.Append(fontSizeComplexScript1038); Text text703 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text703.Text = " "; run742.Append(runProperties784); run742.Append(text703); SdtRun sdtRun50 = new SdtRun(); SdtProperties sdtProperties51 = new SdtProperties(); RunProperties runProperties785 = new RunProperties(); FontSize fontSize1053 = new FontSize() { Val = "20" }; FontSizeComplexScript fontSizeComplexScript1039 = new FontSizeComplexScript() { Val = "20" }; runProperties785.Append(fontSize1053); runProperties785.Append(fontSizeComplexScript1039); SdtId sdtId51 = new SdtId() { Val = 860082579 }; SdtContentDocPartObject sdtContentDocPartObject2 = new SdtContentDocPartObject(); DocPartGallery docPartGallery2 = new DocPartGallery() { Val = "Page Numbers (Top of Page)" }; DocPartUnique docPartUnique2 = new DocPartUnique(); sdtContentDocPartObject2.Append(docPartGallery2); sdtContentDocPartObject2.Append(docPartUnique2); sdtProperties51.Append(runProperties785); sdtProperties51.Append(sdtId51); sdtProperties51.Append(sdtContentDocPartObject2); SdtEndCharProperties sdtEndCharProperties51 = new SdtEndCharProperties(); RunProperties runProperties786 = new RunProperties(); FontSize fontSize1054 = new FontSize() { Val = "24" }; FontSizeComplexScript fontSizeComplexScript1040 = new FontSizeComplexScript() { Val = "24" }; runProperties786.Append(fontSize1054); runProperties786.Append(fontSizeComplexScript1040); sdtEndCharProperties51.Append(runProperties786); SdtContentRun sdtContentRun50 = new SdtContentRun(); Run run743 = new Run() { RsidRunAddition = "0094109A" }; Text text704 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text704.Text = "Page "; run743.Append(text704); Run run744 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties787 = new RunProperties(); Bold bold109 = new Bold(); BoldComplexScript boldComplexScript4 = new BoldComplexScript(); runProperties787.Append(bold109); runProperties787.Append(boldComplexScript4); FieldChar fieldChar1 = new FieldChar() { FieldCharType = FieldCharValues.Begin }; run744.Append(runProperties787); run744.Append(fieldChar1); Run run745 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties788 = new RunProperties(); Bold bold110 = new Bold(); BoldComplexScript boldComplexScript5 = new BoldComplexScript(); runProperties788.Append(bold110); runProperties788.Append(boldComplexScript5); FieldCode fieldCode1 = new FieldCode() { Space = SpaceProcessingModeValues.Preserve }; fieldCode1.Text = " PAGE "; run745.Append(runProperties788); run745.Append(fieldCode1); Run run746 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties789 = new RunProperties(); Bold bold111 = new Bold(); BoldComplexScript boldComplexScript6 = new BoldComplexScript(); runProperties789.Append(bold111); runProperties789.Append(boldComplexScript6); FieldChar fieldChar2 = new FieldChar() { FieldCharType = FieldCharValues.Separate }; run746.Append(runProperties789); run746.Append(fieldChar2); Run run747 = new Run() { RsidRunAddition = "007F6223" }; RunProperties runProperties790 = new RunProperties(); Bold bold112 = new Bold(); BoldComplexScript boldComplexScript7 = new BoldComplexScript(); NoProof noProof2 = new NoProof(); runProperties790.Append(bold112); runProperties790.Append(boldComplexScript7); runProperties790.Append(noProof2); Text text705 = new Text(); text705.Text = "1"; run747.Append(runProperties790); run747.Append(text705); Run run748 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties791 = new RunProperties(); Bold bold113 = new Bold(); BoldComplexScript boldComplexScript8 = new BoldComplexScript(); runProperties791.Append(bold113); runProperties791.Append(boldComplexScript8); FieldChar fieldChar3 = new FieldChar() { FieldCharType = FieldCharValues.End }; run748.Append(runProperties791); run748.Append(fieldChar3); Run run749 = new Run() { RsidRunAddition = "0094109A" }; Text text706 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text706.Text = " of "; run749.Append(text706); Run run750 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties792 = new RunProperties(); Bold bold114 = new Bold(); BoldComplexScript boldComplexScript9 = new BoldComplexScript(); runProperties792.Append(bold114); runProperties792.Append(boldComplexScript9); FieldChar fieldChar4 = new FieldChar() { FieldCharType = FieldCharValues.Begin }; run750.Append(runProperties792); run750.Append(fieldChar4); Run run751 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties793 = new RunProperties(); Bold bold115 = new Bold(); BoldComplexScript boldComplexScript10 = new BoldComplexScript(); runProperties793.Append(bold115); runProperties793.Append(boldComplexScript10); FieldCode fieldCode2 = new FieldCode() { Space = SpaceProcessingModeValues.Preserve }; fieldCode2.Text = " NUMPAGES "; run751.Append(runProperties793); run751.Append(fieldCode2); Run run752 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties794 = new RunProperties(); Bold bold116 = new Bold(); BoldComplexScript boldComplexScript11 = new BoldComplexScript(); runProperties794.Append(bold116); runProperties794.Append(boldComplexScript11); FieldChar fieldChar5 = new FieldChar() { FieldCharType = FieldCharValues.Separate }; run752.Append(runProperties794); run752.Append(fieldChar5); Run run753 = new Run() { RsidRunAddition = "007F6223" }; RunProperties runProperties795 = new RunProperties(); Bold bold117 = new Bold(); BoldComplexScript boldComplexScript12 = new BoldComplexScript(); NoProof noProof3 = new NoProof(); runProperties795.Append(bold117); runProperties795.Append(boldComplexScript12); runProperties795.Append(noProof3); Text text707 = new Text(); text707.Text = "8"; run753.Append(runProperties795); run753.Append(text707); Run run754 = new Run() { RsidRunAddition = "0094109A" }; RunProperties runProperties796 = new RunProperties(); Bold bold118 = new Bold(); BoldComplexScript boldComplexScript13 = new BoldComplexScript(); runProperties796.Append(bold118); runProperties796.Append(boldComplexScript13); FieldChar fieldChar6 = new FieldChar() { FieldCharType = FieldCharValues.End }; run754.Append(runProperties796); run754.Append(fieldChar6); sdtContentRun50.Append(run743); sdtContentRun50.Append(run744); sdtContentRun50.Append(run745); sdtContentRun50.Append(run746); sdtContentRun50.Append(run747); sdtContentRun50.Append(run748); sdtContentRun50.Append(run749); sdtContentRun50.Append(run750); sdtContentRun50.Append(run751); sdtContentRun50.Append(run752); sdtContentRun50.Append(run753); sdtContentRun50.Append(run754); sdtRun50.Append(sdtProperties51); sdtRun50.Append(sdtEndCharProperties51); sdtRun50.Append(sdtContentRun50); paragraph369.Append(paragraphProperties366); paragraph369.Append(hyperlink1); paragraph369.Append(run739); paragraph369.Append(hyperlink2); paragraph369.Append(run741); paragraph369.Append(run742); paragraph369.Append(sdtRun50); sdtContentBlock1.Append(paragraph369); sdtBlock1.Append(sdtProperties50); sdtBlock1.Append(sdtEndCharProperties50); sdtBlock1.Append(sdtContentBlock1); Paragraph paragraph370 = new Paragraph() { RsidParagraphAddition = "0094109A", RsidParagraphProperties = "000F55C6", RsidRunAdditionDefault = "0094109A", ParagraphId = "0AAC1AD4", TextId = "7EFCA27E" }; ParagraphProperties paragraphProperties367 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId27 = new ParagraphStyleId() { Val = "Footer" }; Justification justification77 = new Justification() { Val = JustificationValues.Center }; paragraphProperties367.Append(paragraphStyleId27); paragraphProperties367.Append(justification77); paragraph370.Append(paragraphProperties367); footer1.Append(sdtBlock1); footer1.Append(paragraph370); footerPart1.Footer = footer1; }
static void AddWatermark(WordprocessingDocument doc, string textWatermark) { if (doc.MainDocumentPart.HeaderParts.Count() == 0) { doc.MainDocumentPart.DeleteParts(doc.MainDocumentPart.HeaderParts); var newHeaderPart = doc.MainDocumentPart.AddNewPart <HeaderPart>(); var rId = doc.MainDocumentPart.GetIdOfPart(newHeaderPart); var headerRef = new HeaderReference(); headerRef.Id = rId; var sectionProps = doc.MainDocumentPart.Document.Body.Elements <SectionProperties>().LastOrDefault(); if (sectionProps == null) { sectionProps = new SectionProperties(); doc.MainDocumentPart.Document.Body.Append(sectionProps); } sectionProps.RemoveAllChildren <HeaderReference>(); sectionProps.Append(headerRef); newHeaderPart.Header = MakeHeader(); newHeaderPart.Header.Save(); } foreach (HeaderPart headerPart in doc.MainDocumentPart.HeaderParts) { var sdtBlock1 = new SdtBlock(); var sdtProperties1 = new SdtProperties(); var sdtId1 = new SdtId() { Val = 87908844 }; var sdtContentDocPartObject1 = new SdtContentDocPartObject(); var docPartGallery1 = new DocPartGallery() { Val = "Watermarks" }; var docPartUnique1 = new DocPartUnique(); sdtContentDocPartObject1.Append(docPartGallery1); sdtContentDocPartObject1.Append(docPartUnique1); sdtProperties1.Append(sdtId1); sdtProperties1.Append(sdtContentDocPartObject1); var sdtContentBlock1 = new SdtContentBlock(); var paragraph2 = new Paragraph() { RsidParagraphAddition = "00656E18", RsidRunAdditionDefault = "00656E18" }; var paragraphProperties2 = new ParagraphProperties(); var paragraphStyleId2 = new ParagraphStyleId() { Val = "Header" }; paragraphProperties2.Append(paragraphStyleId2); var run1 = new Run(); var runProperties1 = new RunProperties(); var noProof1 = new NoProof(); var languages1 = new Languages() { EastAsia = "zh-TW" }; runProperties1.Append(noProof1); runProperties1.Append(languages1); var picture1 = new Picture(); var shapetype1 = new Shapetype() { Id = "_x0000_t136", CoordinateSize = "21600,21600", OptionalNumber = 136, Adjustment = "10800", EdgePath = "m@7,l@8,m@5,21600l@6,21600e" }; var formulas1 = new Formulas(); var formula1 = new Formula() { Equation = "sum #0 0 10800" }; var formula2 = new Formula() { Equation = "prod #0 2 1" }; var formula3 = new Formula() { Equation = "sum 21600 0 @1" }; var formula4 = new Formula() { Equation = "sum 0 0 @2" }; var formula5 = new Formula() { Equation = "sum 21600 0 @3" }; var formula6 = new Formula() { Equation = "if @0 @3 0" }; var formula7 = new Formula() { Equation = "if @0 21600 @1" }; var formula8 = new Formula() { Equation = "if @0 0 @2" }; var formula9 = new Formula() { Equation = "if @0 @4 21600" }; var formula10 = new Formula() { Equation = "mid @5 @6" }; var formula11 = new Formula() { Equation = "mid @8 @5" }; var formula12 = new Formula() { Equation = "mid @7 @8" }; var formula13 = new Formula() { Equation = "mid @6 @7" }; var formula14 = new Formula() { Equation = "sum @6 0 @5" }; formulas1.Append(formula1); formulas1.Append(formula2); formulas1.Append(formula3); formulas1.Append(formula4); formulas1.Append(formula5); formulas1.Append(formula6); formulas1.Append(formula7); formulas1.Append(formula8); formulas1.Append(formula9); formulas1.Append(formula10); formulas1.Append(formula11); formulas1.Append(formula12); formulas1.Append(formula13); formulas1.Append(formula14); var path1 = new Path() { AllowTextPath = TrueFalseValue.FromBoolean(true), ConnectionPointType = ConnectValues.Custom, ConnectionPoints = "@9,0;@10,10800;@11,21600;@12,10800", ConnectAngles = "270,180,90,0" }; var textPath1 = new TextPath() { On = TrueFalseValue.FromBoolean(true), FitShape = TrueFalseValue.FromBoolean(true) }; var shapeHandles1 = new ShapeHandles(); var shapeHandle1 = new ShapeHandle() { Position = "#0,bottomRight", XRange = "6629,14971" }; shapeHandles1.Append(shapeHandle1); var lock1 = new Lock { Extension = ExtensionHandlingBehaviorValues.Edit, TextLock = TrueFalseValue.FromBoolean(true), ShapeType = TrueFalseValue.FromBoolean(true) }; shapetype1.Append(formulas1); shapetype1.Append(path1); shapetype1.Append(textPath1); shapetype1.Append(shapeHandles1); shapetype1.Append(lock1); var shape1 = new Shape() { Id = "PowerPlusWaterMarkObject357922611", Style = "position:absolute;left:0;text-align:left;margin-left:0;margin-top:0;width:527.85pt;height:131.95pt;rotation:315;z-index:-251656192;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin", OptionalString = "_x0000_s2049", AllowInCell = TrueFalseValue.FromBoolean(true), FillColor = "silver", Stroked = TrueFalseValue.FromBoolean(false), Type = "#_x0000_t136" }; var fill1 = new Fill() { Opacity = ".5" }; TextPath textPath2 = new TextPath() { Style = "font-family:\"Calibri\";font-size:1pt", String = textWatermark }; var textWrap1 = new TextWrap() { AnchorX = HorizontalAnchorValues.Margin, AnchorY = VerticalAnchorValues.Margin }; shape1.Append(fill1); shape1.Append(textPath2); shape1.Append(textWrap1); picture1.Append(shapetype1); picture1.Append(shape1); run1.Append(runProperties1); run1.Append(picture1); paragraph2.Append(paragraphProperties2); paragraph2.Append(run1); sdtContentBlock1.Append(paragraph2); sdtBlock1.Append(sdtProperties1); sdtBlock1.Append(sdtContentBlock1); headerPart.Header.Append(sdtBlock1); headerPart.Header.Save(); //break; } }
// Generates content of footerPart2. private void GenerateFooterPart2Content(FooterPart footerPart2) { Footer footer2 = new Footer() {MCAttributes = new MarkupCompatibilityAttributes() {Ignorable = "w14 wp14"}}; footer2.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"); footer2.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); footer2.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office"); footer2.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); footer2.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); footer2.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml"); footer2.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"); footer2.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); footer2.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word"); footer2.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); footer2.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml"); footer2.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"); footer2.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk"); footer2.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); footer2.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); SdtBlock sdtBlock1 = new SdtBlock(); SdtProperties sdtProperties1 = new SdtProperties(); SdtId sdtId1 = new SdtId() {Val = -1382393284}; SdtContentDocPartObject sdtContentDocPartObject1 = new SdtContentDocPartObject(); DocPartGallery docPartGallery1 = new DocPartGallery() {Val = "Page Numbers (Bottom of Page)"}; DocPartUnique docPartUnique1 = new DocPartUnique(); sdtContentDocPartObject1.Append(docPartGallery1); sdtContentDocPartObject1.Append(docPartUnique1); sdtProperties1.Append(sdtId1); sdtProperties1.Append(sdtContentDocPartObject1); SdtEndCharProperties sdtEndCharProperties1 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock1 = new SdtContentBlock(); SdtBlock sdtBlock2 = new SdtBlock(); SdtProperties sdtProperties2 = new SdtProperties(); SdtId sdtId2 = new SdtId() {Val = 98381352}; SdtContentDocPartObject sdtContentDocPartObject2 = new SdtContentDocPartObject(); DocPartGallery docPartGallery2 = new DocPartGallery() {Val = "Page Numbers (Top of Page)"}; DocPartUnique docPartUnique2 = new DocPartUnique(); sdtContentDocPartObject2.Append(docPartGallery2); sdtContentDocPartObject2.Append(docPartUnique2); sdtProperties2.Append(sdtId2); sdtProperties2.Append(sdtContentDocPartObject2); SdtEndCharProperties sdtEndCharProperties2 = new SdtEndCharProperties(); SdtContentBlock sdtContentBlock2 = new SdtContentBlock(); Paragraph paragraph28 = new Paragraph() {RsidParagraphAddition = "0005059E", RsidRunAdditionDefault = "0005059E"}; ParagraphProperties paragraphProperties9 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId3 = new ParagraphStyleId() {Val = "Footer"}; paragraphProperties9.Append(paragraphStyleId3); Run run44 = new Run(); Text text29 = new Text() {Space = SpaceProcessingModeValues.Preserve}; text29.Text = "Page "; run44.Append(text29); Run run45 = new Run(); RunProperties runProperties23 = new RunProperties(); Bold bold16 = new Bold(); BoldComplexScript boldComplexScript16 = new BoldComplexScript(); FontSize fontSize15 = new FontSize() {Val = "24"}; FontSizeComplexScript fontSizeComplexScript15 = new FontSizeComplexScript() {Val = "24"}; runProperties23.Append(bold16); runProperties23.Append(boldComplexScript16); runProperties23.Append(fontSize15); runProperties23.Append(fontSizeComplexScript15); FieldChar fieldChar7 = new FieldChar() {FieldCharType = FieldCharValues.Begin}; run45.Append(runProperties23); run45.Append(fieldChar7); Run run46 = new Run(); RunProperties runProperties24 = new RunProperties(); Bold bold17 = new Bold(); BoldComplexScript boldComplexScript17 = new BoldComplexScript(); runProperties24.Append(bold17); runProperties24.Append(boldComplexScript17); FieldCode fieldCode3 = new FieldCode() {Space = SpaceProcessingModeValues.Preserve}; fieldCode3.Text = " PAGE "; run46.Append(runProperties24); run46.Append(fieldCode3); Run run47 = new Run(); RunProperties runProperties25 = new RunProperties(); Bold bold18 = new Bold(); BoldComplexScript boldComplexScript18 = new BoldComplexScript(); FontSize fontSize16 = new FontSize() {Val = "24"}; FontSizeComplexScript fontSizeComplexScript16 = new FontSizeComplexScript() {Val = "24"}; runProperties25.Append(bold18); runProperties25.Append(boldComplexScript18); runProperties25.Append(fontSize16); runProperties25.Append(fontSizeComplexScript16); FieldChar fieldChar8 = new FieldChar() {FieldCharType = FieldCharValues.Separate}; run47.Append(runProperties25); run47.Append(fieldChar8); Run run48 = new Run() {RsidRunAddition = "00FB1F22"}; RunProperties runProperties26 = new RunProperties(); Bold bold19 = new Bold(); BoldComplexScript boldComplexScript19 = new BoldComplexScript(); NoProof noProof23 = new NoProof(); runProperties26.Append(bold19); runProperties26.Append(boldComplexScript19); runProperties26.Append(noProof23); Text text30 = new Text(); text30.Text = "2"; run48.Append(runProperties26); run48.Append(text30); Run run49 = new Run(); RunProperties runProperties27 = new RunProperties(); Bold bold20 = new Bold(); BoldComplexScript boldComplexScript20 = new BoldComplexScript(); FontSize fontSize17 = new FontSize() {Val = "24"}; FontSizeComplexScript fontSizeComplexScript17 = new FontSizeComplexScript() {Val = "24"}; runProperties27.Append(bold20); runProperties27.Append(boldComplexScript20); runProperties27.Append(fontSize17); runProperties27.Append(fontSizeComplexScript17); FieldChar fieldChar9 = new FieldChar() {FieldCharType = FieldCharValues.End}; run49.Append(runProperties27); run49.Append(fieldChar9); Run run50 = new Run(); Text text31 = new Text() {Space = SpaceProcessingModeValues.Preserve}; text31.Text = " of "; run50.Append(text31); Run run51 = new Run(); RunProperties runProperties28 = new RunProperties(); Bold bold21 = new Bold(); BoldComplexScript boldComplexScript21 = new BoldComplexScript(); FontSize fontSize18 = new FontSize() {Val = "24"}; FontSizeComplexScript fontSizeComplexScript18 = new FontSizeComplexScript() {Val = "24"}; runProperties28.Append(bold21); runProperties28.Append(boldComplexScript21); runProperties28.Append(fontSize18); runProperties28.Append(fontSizeComplexScript18); FieldChar fieldChar10 = new FieldChar() {FieldCharType = FieldCharValues.Begin}; run51.Append(runProperties28); run51.Append(fieldChar10); Run run52 = new Run(); RunProperties runProperties29 = new RunProperties(); Bold bold22 = new Bold(); BoldComplexScript boldComplexScript22 = new BoldComplexScript(); runProperties29.Append(bold22); runProperties29.Append(boldComplexScript22); FieldCode fieldCode4 = new FieldCode() {Space = SpaceProcessingModeValues.Preserve}; fieldCode4.Text = " NUMPAGES "; run52.Append(runProperties29); run52.Append(fieldCode4); Run run53 = new Run(); RunProperties runProperties30 = new RunProperties(); Bold bold23 = new Bold(); BoldComplexScript boldComplexScript23 = new BoldComplexScript(); FontSize fontSize19 = new FontSize() {Val = "24"}; FontSizeComplexScript fontSizeComplexScript19 = new FontSizeComplexScript() {Val = "24"}; runProperties30.Append(bold23); runProperties30.Append(boldComplexScript23); runProperties30.Append(fontSize19); runProperties30.Append(fontSizeComplexScript19); FieldChar fieldChar11 = new FieldChar() {FieldCharType = FieldCharValues.Separate}; run53.Append(runProperties30); run53.Append(fieldChar11); Run run54 = new Run() {RsidRunAddition = "00FB1F22"}; RunProperties runProperties31 = new RunProperties(); Bold bold24 = new Bold(); BoldComplexScript boldComplexScript24 = new BoldComplexScript(); NoProof noProof24 = new NoProof(); runProperties31.Append(bold24); runProperties31.Append(boldComplexScript24); runProperties31.Append(noProof24); Text text32 = new Text(); text32.Text = "37"; run54.Append(runProperties31); run54.Append(text32); Run run55 = new Run(); RunProperties runProperties32 = new RunProperties(); Bold bold25 = new Bold(); BoldComplexScript boldComplexScript25 = new BoldComplexScript(); FontSize fontSize20 = new FontSize() {Val = "24"}; FontSizeComplexScript fontSizeComplexScript20 = new FontSizeComplexScript() {Val = "24"}; runProperties32.Append(bold25); runProperties32.Append(boldComplexScript25); runProperties32.Append(fontSize20); runProperties32.Append(fontSizeComplexScript20); FieldChar fieldChar12 = new FieldChar() {FieldCharType = FieldCharValues.End}; run55.Append(runProperties32); run55.Append(fieldChar12); paragraph28.Append(paragraphProperties9); paragraph28.Append(run44); paragraph28.Append(run45); paragraph28.Append(run46); paragraph28.Append(run47); paragraph28.Append(run48); paragraph28.Append(run49); paragraph28.Append(run50); paragraph28.Append(run51); paragraph28.Append(run52); paragraph28.Append(run53); paragraph28.Append(run54); paragraph28.Append(run55); sdtContentBlock2.Append(paragraph28); sdtBlock2.Append(sdtProperties2); sdtBlock2.Append(sdtEndCharProperties2); sdtBlock2.Append(sdtContentBlock2); sdtContentBlock1.Append(sdtBlock2); sdtBlock1.Append(sdtProperties1); sdtBlock1.Append(sdtEndCharProperties1); sdtBlock1.Append(sdtContentBlock1); Paragraph paragraph29 = new Paragraph() {RsidParagraphAddition = "0005059E", RsidRunAdditionDefault = "0005059E"}; ParagraphProperties paragraphProperties10 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId4 = new ParagraphStyleId() {Val = "Footer"}; paragraphProperties10.Append(paragraphStyleId4); paragraph29.Append(paragraphProperties10); footer2.Append(sdtBlock1); footer2.Append(paragraph29); footerPart2.Footer = footer2; }
private void GenerateFooterPartContent(FooterPart footerPart1) { Footer footer1 = new Footer(); SdtBlock sdtBlock1 = new SdtBlock(); SdtProperties sdtProperties1 = new SdtProperties(); SdtId sdtId1 = new SdtId() { Val = 712706661 }; SdtContentDocPartObject sdtContentDocPartObject1 = new SdtContentDocPartObject(); DocPartGallery docPartGallery1 = new DocPartGallery() { Val = "Page Numbers (Bottom of Page)" }; DocPartUnique docPartUnique1 = new DocPartUnique(); sdtContentDocPartObject1.Append(docPartGallery1); sdtContentDocPartObject1.Append(docPartUnique1); sdtProperties1.Append(sdtId1); sdtProperties1.Append(sdtContentDocPartObject1); SdtEndCharProperties sdtEndCharProperties1 = new SdtEndCharProperties(); RunProperties runProperties1 = new RunProperties(); NoProof noProof1 = new NoProof(); runProperties1.Append(noProof1); sdtEndCharProperties1.Append(runProperties1); SdtContentBlock sdtContentBlock1 = new SdtContentBlock(); Paragraph paragraph1 = new Paragraph(); ParagraphProperties paragraphProperties1 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId1 = new ParagraphStyleId() { Val = "Footer" }; Justification justification1 = new Justification() { Val = JustificationValues.Center }; paragraphProperties1.Append(paragraphStyleId1); paragraphProperties1.Append(justification1); Run run1 = new Run(); FieldChar fieldChar1 = new FieldChar() { FieldCharType = FieldCharValues.Begin }; run1.Append(fieldChar1); Run run2 = new Run(); FieldCode fieldCode1 = new FieldCode() { Space = SpaceProcessingModeValues.Preserve }; fieldCode1.Text = " PAGE \\* MERGEFORMAT "; run2.Append(fieldCode1); Run run3 = new Run(); FieldChar fieldChar2 = new FieldChar() { FieldCharType = FieldCharValues.Separate }; run3.Append(fieldChar2); Run run4 = new Run(); RunProperties runProperties2 = new RunProperties(); NoProof noProof2 = new NoProof(); runProperties2.Append(noProof2); Text text1 = new Text(); text1.Text = "1"; run4.Append(runProperties2); run4.Append(text1); Run run5 = new Run(); RunProperties runProperties3 = new RunProperties(); NoProof noProof3 = new NoProof(); runProperties3.Append(noProof3); FieldChar fieldChar3 = new FieldChar() { FieldCharType = FieldCharValues.End }; run5.Append(runProperties3); run5.Append(fieldChar3); paragraph1.Append(paragraphProperties1); paragraph1.Append(run1); paragraph1.Append(run2); paragraph1.Append(run3); paragraph1.Append(run4); paragraph1.Append(run5); sdtContentBlock1.Append(paragraph1); sdtBlock1.Append(sdtProperties1); sdtBlock1.Append(sdtEndCharProperties1); sdtBlock1.Append(sdtContentBlock1); Paragraph paragraph2 = new Paragraph(); ParagraphProperties paragraphProperties2 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId2 = new ParagraphStyleId() { Val = "Footer" }; paragraphProperties2.Append(paragraphStyleId2); paragraph2.Append(paragraphProperties2); footer1.Append(sdtBlock1); footer1.Append(paragraph2); footerPart1.Footer = footer1; }