Answered foreach Page?

  • Sunday, June 24, 2012 3:43 AM
     
     

    Hi, My applications needs to print a DataMatrix barcode on every facing page of a multipage duplex printed docx.   How can I setup a foreach for each Page using Open XML?  

    Thanks, Mark

All Replies

  • Tuesday, June 26, 2012 2:50 AM
    Moderator
     
     Answered

    Hi Mark,

    You may insert the barcode to document header or footer, and set "Different Odd/Even Pages".  Have you tried this scenario manually? It would be helpful to do manually before automating.

    thanks,


    Forrest Guo | MSDN Community Support | Feedback to manager

  • Friday, July 06, 2012 12:49 PM
     
     
    Can you please send me your code as a sample, I am trying to do that too but I have no idea where to start. I will be really thankful!
  • Monday, July 09, 2012 3:05 AM
    Moderator
     
      Has Code

    Hi,

    I created a document with an image in footer, enable Different Odd/Event Pages, see document here.  Reflected relative code below.

    // Adds child parts and generates content of the specified part.
            private void CreateParts(WordprocessingDocument document)
            {
                ExtendedFilePropertiesPart extendedFilePropertiesPart1 = document.AddNewPart<ExtendedFilePropertiesPart>("rId3");
                GenerateExtendedFilePropertiesPart1Content(extendedFilePropertiesPart1);
    
                MainDocumentPart mainDocumentPart1 = document.AddMainDocumentPart();
                GenerateMainDocumentPart1Content(mainDocumentPart1);
    
                FooterPart footerPart1 = mainDocumentPart1.AddNewPart<FooterPart>("rId8");
                GenerateFooterPart1Content(footerPart1);
    
                ImagePart imagePart1 = footerPart1.AddNewPart<ImagePart>("image/jpeg", "rId1");
                GenerateImagePart1Content(imagePart1);
    
                DocumentSettingsPart documentSettingsPart1 = mainDocumentPart1.AddNewPart<DocumentSettingsPart>("rId3");
                GenerateDocumentSettingsPart1Content(documentSettingsPart1);
    
                FooterPart footerPart2 = mainDocumentPart1.AddNewPart<FooterPart>("rId7");
                GenerateFooterPart2Content(footerPart2);
    
                StylesWithEffectsPart stylesWithEffectsPart1 = mainDocumentPart1.AddNewPart<StylesWithEffectsPart>("rId2");
                GenerateStylesWithEffectsPart1Content(stylesWithEffectsPart1);
    
                StyleDefinitionsPart styleDefinitionsPart1 = mainDocumentPart1.AddNewPart<StyleDefinitionsPart>("rId1");
                GenerateStyleDefinitionsPart1Content(styleDefinitionsPart1);
    
                EndnotesPart endnotesPart1 = mainDocumentPart1.AddNewPart<EndnotesPart>("rId6");
                GenerateEndnotesPart1Content(endnotesPart1);
    
                FootnotesPart footnotesPart1 = mainDocumentPart1.AddNewPart<FootnotesPart>("rId5");
                GenerateFootnotesPart1Content(footnotesPart1);
    
                ThemePart themePart1 = mainDocumentPart1.AddNewPart<ThemePart>("rId10");
                GenerateThemePart1Content(themePart1);
    
                WebSettingsPart webSettingsPart1 = mainDocumentPart1.AddNewPart<WebSettingsPart>("rId4");
                GenerateWebSettingsPart1Content(webSettingsPart1);
    
                FontTablePart fontTablePart1 = mainDocumentPart1.AddNewPart<FontTablePart>("rId9");
                GenerateFontTablePart1Content(fontTablePart1);
    
                SetPackageProperties(document);
            }
    
    ...
    ...
    ...
     // Generates content of footerPart1.
            private void GenerateFooterPart1Content(FooterPart footerPart1)
            {
                Footer footer1 = new Footer() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 wp14" } };
                footer1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
                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("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");
    
                Paragraph paragraph17 = new Paragraph() { RsidParagraphAddition = "005D1BFB", RsidRunAdditionDefault = "005D1BFB" };
    
                ParagraphProperties paragraphProperties7 = new ParagraphProperties();
                ParagraphStyleId paragraphStyleId1 = new ParagraphStyleId() { Val = "Footer" };
    
                paragraphProperties7.Append(paragraphStyleId1);
    
                Run run10 = new Run();
                PositionalTab positionalTab1 = new PositionalTab() { Alignment = AbsolutePositionTabAlignmentValues.Right, RelativeTo = AbsolutePositionTabPositioningBaseValues.Margin, Leader = AbsolutePositionTabLeaderCharValues.None };
    
                run10.Append(positionalTab1);
    
                Run run11 = new Run();
    
                RunProperties runProperties6 = new RunProperties();
                NoProof noProof1 = new NoProof();
    
                runProperties6.Append(noProof1);
    
                Drawing drawing1 = new Drawing();
    
                Wp.Inline inline1 = new Wp.Inline() { DistanceFromTop = (UInt32Value)0U, DistanceFromBottom = (UInt32Value)0U, DistanceFromLeft = (UInt32Value)0U, DistanceFromRight = (UInt32Value)0U, AnchorId = "0BFEB677", EditId = "45AAB0F9" };
                Wp.Extent extent1 = new Wp.Extent() { Cx = 1752600L, Cy = 1752600L };
                Wp.EffectExtent effectExtent1 = new Wp.EffectExtent() { LeftEdge = 0L, TopEdge = 0L, RightEdge = 0L, BottomEdge = 0L };
                Wp.DocProperties docProperties1 = new Wp.DocProperties() { Id = (UInt32Value)1U, Name = "Picture 1" };
    
                Wp.NonVisualGraphicFrameDrawingProperties nonVisualGraphicFrameDrawingProperties1 = new Wp.NonVisualGraphicFrameDrawingProperties();
    
                A.GraphicFrameLocks graphicFrameLocks1 = new A.GraphicFrameLocks() { NoChangeAspect = true };
                graphicFrameLocks1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");
    
                nonVisualGraphicFrameDrawingProperties1.Append(graphicFrameLocks1);
    
                A.Graphic graphic1 = new A.Graphic();
                graphic1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");
    
                A.GraphicData graphicData1 = new A.GraphicData() { Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" };
    
                Pic.Picture picture1 = new Pic.Picture();
                picture1.AddNamespaceDeclaration("pic", "http://schemas.openxmlformats.org/drawingml/2006/picture");
    
                Pic.NonVisualPictureProperties nonVisualPictureProperties1 = new Pic.NonVisualPictureProperties();
                Pic.NonVisualDrawingProperties nonVisualDrawingProperties1 = new Pic.NonVisualDrawingProperties() { Id = (UInt32Value)0U, Name = "QRBarcode.jpg" };
                Pic.NonVisualPictureDrawingProperties nonVisualPictureDrawingProperties1 = new Pic.NonVisualPictureDrawingProperties();
    
                nonVisualPictureProperties1.Append(nonVisualDrawingProperties1);
                nonVisualPictureProperties1.Append(nonVisualPictureDrawingProperties1);
    
                Pic.BlipFill blipFill1 = new Pic.BlipFill();
    
                A.Blip blip1 = new A.Blip() { Embed = "rId1" };
    
                A.BlipExtensionList blipExtensionList1 = new A.BlipExtensionList();
    
                A.BlipExtension blipExtension1 = new A.BlipExtension() { Uri = "{28A0092B-C50C-407E-A947-70E740481C1C}" };
    
                A14.UseLocalDpi useLocalDpi1 = new A14.UseLocalDpi() { Val = false };
                useLocalDpi1.AddNamespaceDeclaration("a14", "http://schemas.microsoft.com/office/drawing/2010/main");
    
                blipExtension1.Append(useLocalDpi1);
    
                blipExtensionList1.Append(blipExtension1);
    
                blip1.Append(blipExtensionList1);
    
                A.Stretch stretch1 = new A.Stretch();
                A.FillRectangle fillRectangle1 = new A.FillRectangle();
    
                stretch1.Append(fillRectangle1);
    
                blipFill1.Append(blip1);
                blipFill1.Append(stretch1);
    
                Pic.ShapeProperties shapeProperties1 = new Pic.ShapeProperties();
    
                A.Transform2D transform2D1 = new A.Transform2D();
                A.Offset offset1 = new A.Offset() { X = 0L, Y = 0L };
                A.Extents extents1 = new A.Extents() { Cx = 1752600L, Cy = 1752600L };
    
                transform2D1.Append(offset1);
                transform2D1.Append(extents1);
    
                A.PresetGeometry presetGeometry1 = new A.PresetGeometry() { Preset = A.ShapeTypeValues.Rectangle };
                A.AdjustValueList adjustValueList1 = new A.AdjustValueList();
    
                presetGeometry1.Append(adjustValueList1);
    
                shapeProperties1.Append(transform2D1);
                shapeProperties1.Append(presetGeometry1);
    
                picture1.Append(nonVisualPictureProperties1);
                picture1.Append(blipFill1);
                picture1.Append(shapeProperties1);
    
                graphicData1.Append(picture1);
    
                graphic1.Append(graphicData1);
    
                inline1.Append(extent1);
                inline1.Append(effectExtent1);
                inline1.Append(docProperties1);
                inline1.Append(nonVisualGraphicFrameDrawingProperties1);
                inline1.Append(graphic1);
    
                drawing1.Append(inline1);
    
                run11.Append(runProperties6);
                run11.Append(drawing1);
    
                paragraph17.Append(paragraphProperties7);
                paragraph17.Append(run10);
                paragraph17.Append(run11);
    
                footer1.Append(paragraph17);
    
                footerPart1.Footer = footer1;
            }
    
            // Generates content of imagePart1.
            private void GenerateImagePart1Content(ImagePart imagePart1)
            {
                System.IO.Stream data = GetBinaryDataStream(imagePart1Data);
                imagePart1.FeedData(data);
                data.Close();
            }
    
     // Generates content of documentSettingsPart1.
            private void GenerateDocumentSettingsPart1Content(DocumentSettingsPart documentSettingsPart1)
            {
                Settings settings1 = new Settings() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14" } };
                settings1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
                settings1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
                settings1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
                settings1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
                settings1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
                settings1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
                settings1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
                settings1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml");
                settings1.AddNamespaceDeclaration("sl", "http://schemas.openxmlformats.org/schemaLibrary/2006/main");
                Zoom zoom1 = new Zoom() { Percent = "100" };
                DocumentProtection documentProtection1 = new DocumentProtection() { Edit = DocumentProtectionValues.ReadOnly, Enforcement = false };
                DefaultTabStop defaultTabStop1 = new DefaultTabStop() { Val = 720 };
                EvenAndOddHeaders evenAndOddHeaders1 = new EvenAndOddHeaders();
                CharacterSpacingControl characterSpacingControl1 = new CharacterSpacingControl() { Val = CharacterSpacingValues.DoNotCompress };
    
                HeaderShapeDefaults headerShapeDefaults1 = new HeaderShapeDefaults();
                Ovml.ShapeDefaults shapeDefaults1 = new Ovml.ShapeDefaults() { Extension = V.ExtensionHandlingBehaviorValues.Edit, MaxShapeId = 2049 };
    
                headerShapeDefaults1.Append(shapeDefaults1);
    
                FootnoteDocumentWideProperties footnoteDocumentWideProperties1 = new FootnoteDocumentWideProperties();
                FootnoteSpecialReference footnoteSpecialReference1 = new FootnoteSpecialReference() { Id = -1 };
                FootnoteSpecialReference footnoteSpecialReference2 = new FootnoteSpecialReference() { Id = 0 };
    
                footnoteDocumentWideProperties1.Append(footnoteSpecialReference1);
                footnoteDocumentWideProperties1.Append(footnoteSpecialReference2);
    
                EndnoteDocumentWideProperties endnoteDocumentWideProperties1 = new EndnoteDocumentWideProperties();
                EndnoteSpecialReference endnoteSpecialReference1 = new EndnoteSpecialReference() { Id = -1 };
                EndnoteSpecialReference endnoteSpecialReference2 = new EndnoteSpecialReference() { Id = 0 };
    
                endnoteDocumentWideProperties1.Append(endnoteSpecialReference1);
                endnoteDocumentWideProperties1.Append(endnoteSpecialReference2);
    
                Compatibility compatibility1 = new Compatibility();
                UseFarEastLayout useFarEastLayout1 = new UseFarEastLayout();
                CompatibilitySetting compatibilitySetting1 = new CompatibilitySetting() { Name = CompatSettingNameValues.CompatibilityMode, Uri = "http://schemas.microsoft.com/office/word", Val = "14" };
                CompatibilitySetting compatibilitySetting2 = new CompatibilitySetting() { Name = CompatSettingNameValues.OverrideTableStyleFontSizeAndJustification, Uri = "http://schemas.microsoft.com/office/word", Val = "1" };
                CompatibilitySetting compatibilitySetting3 = new CompatibilitySetting() { Name = CompatSettingNameValues.EnableOpenTypeFeatures, Uri = "http://schemas.microsoft.com/office/word", Val = "1" };
                CompatibilitySetting compatibilitySetting4 = new CompatibilitySetting() { Name = CompatSettingNameValues.DoNotFlipMirrorIndents, Uri = "http://schemas.microsoft.com/office/word", Val = "1" };
    
                compatibility1.Append(useFarEastLayout1);
                compatibility1.Append(compatibilitySetting1);
                compatibility1.Append(compatibilitySetting2);
                compatibility1.Append(compatibilitySetting3);
                compatibility1.Append(compatibilitySetting4);
    
                Rsids rsids1 = new Rsids();
                RsidRoot rsidRoot1 = new RsidRoot() { Val = "0017011D" };
                Rsid rsid1 = new Rsid() { Val = "0017011D" };
                Rsid rsid2 = new Rsid() { Val = "001C1E78" };
                Rsid rsid3 = new Rsid() { Val = "00235E09" };
                Rsid rsid4 = new Rsid() { Val = "00357392" };
                Rsid rsid5 = new Rsid() { Val = "004A7CF9" };
                Rsid rsid6 = new Rsid() { Val = "005D1BFB" };
                Rsid rsid7 = new Rsid() { Val = "005E5FDA" };
                Rsid rsid8 = new Rsid() { Val = "0063306F" };
                Rsid rsid9 = new Rsid() { Val = "00680B7B" };
                Rsid rsid10 = new Rsid() { Val = "00743757" };
                Rsid rsid11 = new Rsid() { Val = "008C3A64" };
                Rsid rsid12 = new Rsid() { Val = "009328F8" };
                Rsid rsid13 = new Rsid() { Val = "00957FC0" };
                Rsid rsid14 = new Rsid() { Val = "00967160" };
                Rsid rsid15 = new Rsid() { Val = "009F27AE" };
                Rsid rsid16 = new Rsid() { Val = "00A91DE6" };
                Rsid rsid17 = new Rsid() { Val = "00B07020" };
                Rsid rsid18 = new Rsid() { Val = "00B77EF6" };
                Rsid rsid19 = new Rsid() { Val = "00D84476" };
                Rsid rsid20 = new Rsid() { Val = "00E03AE4" };
                Rsid rsid21 = new Rsid() { Val = "00EB0535" };
                Rsid rsid22 = new Rsid() { Val = "00ED2A85" };
                Rsid rsid23 = new Rsid() { Val = "00F75482" };
                Rsid rsid24 = new Rsid() { Val = "00F769DC" };
                Rsid rsid25 = new Rsid() { Val = "00FA6D2A" };
                Rsid rsid26 = new Rsid() { Val = "00FF436D" };
    
                rsids1.Append(rsidRoot1);
                rsids1.Append(rsid1);
                rsids1.Append(rsid2);
                rsids1.Append(rsid3);
                rsids1.Append(rsid4);
                rsids1.Append(rsid5);
                rsids1.Append(rsid6);
                rsids1.Append(rsid7);
                rsids1.Append(rsid8);
                rsids1.Append(rsid9);
                rsids1.Append(rsid10);
                rsids1.Append(rsid11);
                rsids1.Append(rsid12);
                rsids1.Append(rsid13);
                rsids1.Append(rsid14);
                rsids1.Append(rsid15);
                rsids1.Append(rsid16);
                rsids1.Append(rsid17);
                rsids1.Append(rsid18);
                rsids1.Append(rsid19);
                rsids1.Append(rsid20);
                rsids1.Append(rsid21);
                rsids1.Append(rsid22);
                rsids1.Append(rsid23);
                rsids1.Append(rsid24);
                rsids1.Append(rsid25);
                rsids1.Append(rsid26);
    
                M.MathProperties mathProperties1 = new M.MathProperties();
                M.MathFont mathFont1 = new M.MathFont() { Val = "Cambria Math" };
                M.BreakBinary breakBinary1 = new M.BreakBinary() { Val = M.BreakBinaryOperatorValues.Before };
                M.BreakBinarySubtraction breakBinarySubtraction1 = new M.BreakBinarySubtraction() { Val = M.BreakBinarySubtractionValues.MinusMinus };
                M.SmallFraction smallFraction1 = new M.SmallFraction() { Val = M.BooleanValues.Zero };
                M.DisplayDefaults displayDefaults1 = new M.DisplayDefaults();
                M.LeftMargin leftMargin1 = new M.LeftMargin() { Val = (UInt32Value)0U };
                M.RightMargin rightMargin1 = new M.RightMargin() { Val = (UInt32Value)0U };
                M.DefaultJustification defaultJustification1 = new M.DefaultJustification() { Val = M.JustificationValues.CenterGroup };
                M.WrapIndent wrapIndent1 = new M.WrapIndent() { Val = (UInt32Value)1440U };
                M.IntegralLimitLocation integralLimitLocation1 = new M.IntegralLimitLocation() { Val = M.LimitLocationValues.SubscriptSuperscript };
                M.NaryLimitLocation naryLimitLocation1 = new M.NaryLimitLocation() { Val = M.LimitLocationValues.UnderOver };
    
                mathProperties1.Append(mathFont1);
                mathProperties1.Append(breakBinary1);
                mathProperties1.Append(breakBinarySubtraction1);
                mathProperties1.Append(smallFraction1);
                mathProperties1.Append(displayDefaults1);
                mathProperties1.Append(leftMargin1);
                mathProperties1.Append(rightMargin1);
                mathProperties1.Append(defaultJustification1);
                mathProperties1.Append(wrapIndent1);
                mathProperties1.Append(integralLimitLocation1);
                mathProperties1.Append(naryLimitLocation1);
                ThemeFontLanguages themeFontLanguages1 = new ThemeFontLanguages() { Val = "en-US", EastAsia = "zh-CN" };
                ColorSchemeMapping colorSchemeMapping1 = new ColorSchemeMapping() { Background1 = ColorSchemeIndexValues.Light1, Text1 = ColorSchemeIndexValues.Dark1, Background2 = ColorSchemeIndexValues.Light2, Text2 = ColorSchemeIndexValues.Dark2, Accent1 = ColorSchemeIndexValues.Accent1, Accent2 = ColorSchemeIndexValues.Accent2, Accent3 = ColorSchemeIndexValues.Accent3, Accent4 = ColorSchemeIndexValues.Accent4, Accent5 = ColorSchemeIndexValues.Accent5, Accent6 = ColorSchemeIndexValues.Accent6, Hyperlink = ColorSchemeIndexValues.Hyperlink, FollowedHyperlink = ColorSchemeIndexValues.FollowedHyperlink };
    
                ShapeDefaults shapeDefaults2 = new ShapeDefaults();
                Ovml.ShapeDefaults shapeDefaults3 = new Ovml.ShapeDefaults() { Extension = V.ExtensionHandlingBehaviorValues.Edit, MaxShapeId = 2049 };
    
                Ovml.ShapeLayout shapeLayout1 = new Ovml.ShapeLayout() { Extension = V.ExtensionHandlingBehaviorValues.Edit };
                Ovml.ShapeIdMap shapeIdMap1 = new Ovml.ShapeIdMap() { Extension = V.ExtensionHandlingBehaviorValues.Edit, Data = "1" };
    
                shapeLayout1.Append(shapeIdMap1);
    
                shapeDefaults2.Append(shapeDefaults3);
                shapeDefaults2.Append(shapeLayout1);
                DecimalSymbol decimalSymbol1 = new DecimalSymbol() { Val = "." };
                ListSeparator listSeparator1 = new ListSeparator() { Val = "," };
    
                settings1.Append(zoom1);
                settings1.Append(documentProtection1);
                settings1.Append(defaultTabStop1);
                settings1.Append(evenAndOddHeaders1);
                settings1.Append(characterSpacingControl1);
                settings1.Append(headerShapeDefaults1);
                settings1.Append(footnoteDocumentWideProperties1);
                settings1.Append(endnoteDocumentWideProperties1);
                settings1.Append(compatibility1);
                settings1.Append(rsids1);
                settings1.Append(mathProperties1);
                settings1.Append(themeFontLanguages1);
                settings1.Append(colorSchemeMapping1);
                settings1.Append(shapeDefaults2);
                settings1.Append(decimalSymbol1);
                settings1.Append(listSeparator1);
    
                documentSettingsPart1.Settings = settings1;
            }
    
    // 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");
    
                Paragraph paragraph18 = new Paragraph() { RsidParagraphAddition = "00680B7B", RsidRunAdditionDefault = "00680B7B" };
    
                ParagraphProperties paragraphProperties8 = new ParagraphProperties();
                ParagraphStyleId paragraphStyleId2 = new ParagraphStyleId() { Val = "Footer" };
    
                paragraphProperties8.Append(paragraphStyleId2);
    
                Run run12 = new Run();
                PositionalTab positionalTab2 = new PositionalTab() { Alignment = AbsolutePositionTabAlignmentValues.Right, RelativeTo = AbsolutePositionTabPositioningBaseValues.Margin, Leader = AbsolutePositionTabLeaderCharValues.None };
    
                run12.Append(positionalTab2);
    
                paragraph18.Append(paragraphProperties8);
                paragraph18.Append(run12);
    
                footer2.Append(paragraph18);
    
                footerPart2.Footer = footer2;
            }


    Forrest Guo | MSDN Community Support | Feedback to manager