c# - Openxml Add another different footer to an existing docx -


i trying add different footer after each altchunk added. code changes footers , on last page there 2 footers. adding section break prior adding new footer different text. (c# , openxml)

    public static void appendfooter(string sfttext, string sfile)     {         using (wordprocessingdocument wddoc = wordprocessingdocument.open(sfile, true))         {             maindocumentpart mypart = wddoc.maindocumentpart;             footerpart newftpart = mypart.addnewpart<footerpart>();             string ft_id = mypart.getidofpart(newftpart);              makefooterpart(sfttext).save(newftpart);             foreach (sectionproperties sectproperties in                     mypart.document.descendants<sectionproperties>())             {                  footerreference newftreference =                   new footerreference() { id = ft_id, type = headerfootervalues.default };                 sectproperties.append(newftreference);             }             //  save changes main document part.             mypart.document.save();         }     } 

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

    private static footer makefooterpart(string footertext)     {         var element =           new footer(             new paragraph(               new paragraphproperties(                 new paragraphstyleid() { val = "footer" }),               new run(                 new text(footertext))             )           );          return element;     } 


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -