Footnote copy from word document into another

Here is scenario:

  1. Word document gets created using word template. User will enter required data , add footnotes and save document.
  2. This document gets saved at server.
  3. Now from this document contents (data from content variables), user wants to create new document.
  4. Here no clone of word document is involved.
  5. Need to copy contents only along with footnotes.

Kindly let me know how we can achieve this.

Thanks
Snehal

@snehalghute can you please attach an example of input and the expected output for reference.

Input.docx (23.9 KB)
output.docx (24.8 KB)

@snehalghute Thank you for provide additional information. We are checking the attached files and working on the issue and will get back to you as soon as possible.

@snehalghute sorry is still not clear for me from where the data comes, the output document that you provided contains the footnotes of the first document, but also contains additional paragraphs that I don’t know from where they come. Can you please provide more details about you process?
If you want to extract the footnotes from a document you can use the following code:

Document baseDoc = new Document("C:\\Temp\\input.docx");
Document doc = (Document)baseDoc.Clone(false);
DocumentBuilder builder = new DocumentBuilder(doc);

NodeImporter importer = new NodeImporter(baseDoc, doc, ImportFormatMode.KeepSourceFormatting);
            
var footNotes = baseDoc.GetChildNodes(NodeType.Footnote, true);
foreach (Footnote footnote in footNotes)
{
    if(footnote.FootnoteType == FootnoteType.Footnote)
    {
        var footnoteText = footnote.PreviousSibling;
        if(footnoteText != null)
        {
            Node textNode = importer.ImportNode(footnoteText, true);
            builder.InsertNode(textNode);
        }
    }
    Node importNode = importer.ImportNode(footnote, true);
    builder.InsertNode(importNode);
}

doc.Save("C:\\Temp\\output.docx");

input.docx (22.9 KB)
output.docx (18.7 KB)

Input.docx (24.0 KB)

I want to populate data for content controls present in output.docx file only by keeping output.docx remaining contents and formatting as it is.

Above conde snippet just goes by inserting data but not keeping format and position of content controls.

@snehalghute can you please elaborate more:

  1. From where comes the data, that you will use to populate the Content Controls?
  2. Where are the Content Controls in your sample documents?
  3. The output file that you attached is actually one of the inputs? In that case can you please post a sample of your expected output?

In order to provide an accurate solution I need to be 100% sure about what you want to get.

Issue is resolved now. Thank you your pointers.

1 Like