Wednesday, 15 July 2015

c# - How to copy docx footers from one file to existing file -


Here I need to:

Let me remove any footer from a word document (doc) the wanted. Then add a new footer with page numbers. I have been able to achieve these solutions.

Here is the catch: 1) I need to leave the "N" pages, thus the number starts only on "number". 2) Strange numbers are on the right side, even numbers are on the left.

Background: This is part of a huge parsing, which is a document of editing and organizes documents. I have chosen OpenXML on Interop because it is easy to meet my needs so far and in most cases.

Here's my idea:

I am a "template doctor" through which I manually created footnotes as per the requirement. I want to open the source doctor, remove the footers and then copy the footers from "template doctor" and then continue to parse the doctor.

After removing "Template doctor", I have found that in it there are 3 footers, I'm guessing: for a "no / wagon footer", on the left hand side, a right hand

I have examined many other links, but my problem seems uniquely. / P>

This is my fax code:

  Private zero paging123 (string destination dock, string source doc) {{WordprocessingDocument sourceTemplate = WordprocessingDocument.Open (sourceDoc, true)) {using (WordprocessingDocument wordDoc = WordprocessingDocument.Open (destinationDoc, true)) {// Delete all existing footers wordDoc.MainDocumentPart.DeleteParts (wordDoc.MainDocumentPart.FooterParts); IEnumerable & LT; FooterPart & gt; FooterPartSource = sourceTemplate.MainDocumentPart.FooterParts; & Lt; String & gt; DestIds = New list & lt; String & gt; (); & Lt; FooterPart & gt; DestFoots = new list & lt; FooterPart & gt; (); // Copy the novel footer, the new source doc foreach (var fp in footerPartSource) into the source {// Create a new footer part, FooterPart footerPart = wordDoc.MainDocumentPart.AddNewPart & lt; FooterPart & gt; (); // Get Pastor Parts String Footer ID Source id = sourceTemplate.MainDocumentPart.GetIdOfPart (footer); DestIds.Add (footerPartId); DestFoots.Add (footerPart); } IEnumerable & lt; Section Properties & gt; Section = word doc.mandocumentpart.dext.bode.alments & lt; Section Properties & gt; (); Forehack (different sections in sections) {// Remove existing references in the footer section. Remove all children & lt; FooterReference & gt; (); {Section.PrependChild & lt; for Intuit = 0; I & lt; 3; i ++) FooterReference & gt; (New footerReference () {id = destIds [i]}); }}}}}  

My work code for adding a single footer to this document is:

  Private Zero PagingWorking {string document} {using ( WordProogging Document Word Doc = Word Processing Document. Open (Document, True)) // current footer Word Doc. Main Document Format Deliverparts (word dock.mandocumentpart.footerparts); // Create a new footer section FooterPart footerPart = wordDoc.MainDocumentPart.AddNewPart & lt; FooterPart & gt; (); // Find footer ID of the footer's footsteps. Advertising id = words Main document page GetIdOfPart (footer); FooterPart.Footer = MyFooter (); // method gives a footer object // get the section property and FooterRefernce is new ID IEnumerable & lt; SectionProperties & gt; Section = word doc.mandocumentpart.dext.bode.alments & lt; Section Properties & gt; (); Forehack (different sections in sections) {// Remove existing references in the footer section. Remove all children & lt; FooterReference & gt; (); // Create a new footer reference node section. Piped child & lt; Footnote line & gt; (New footreference () {id = footer}}; If you have removed it, thank you for your time. 

no solution, only one two indicators

in each section of the document, the primary Can be the first page, even the weird page footer and header can be.

For manipulation page ranking, you must use the field code. Those fields will be updated if the document is open in the Microsoft Word

Regards,

Michael


No comments:

Post a Comment