Extra spaces in Footer text

Hi,
In our application we work on many documents.
For source document we add hellopage as start page then copy header footers of source document to destination document.
In one document after adding hellopage and copying headers footers from source to destination, in destination document in footer extra spaces are coming.
I have attatched my input and output and expected document for your reference.
The code which i am using for getting footer text is

foreach (Section se in doc.Sections)
{
    primary = se.HeadersFooters[HeaderFooterType.FooterPrimary];
    if (primary != null)
        x = primary.GetText();
}

the code for setting footer text is

if (footerinfo[footerType] != null)
{
    if (footerType.ToLower() == "primary")
        builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
    Builder.write(x);
}

Kindly help me to solve this issue.

Hi there,

Thanks
for your inquiry. In case you are using an older version of Aspose.Words, I would suggest you please upgrade to the latest version (v14.4.0) from here and let us know how it goes on your side.

Please use the following code example to copy header/footer of one document into another. Hope this helps you.

Document srcDoc = new Document(MyDir + "input.doc");
Document dstDoc = new Document();
MergeHeaderFooter(srcDoc, dstDoc, HeaderFooterType.FooterPrimary);
dstDoc.Save(MyDir + "Out.doc");
public void MergeHeaderFooter(Document srcDoc, Document dstDoc, HeaderFooterType headerType)
{
    foreach (Section section in dstDoc.Sections)
    {
        HeaderFooter header = section.HeadersFooters[headerType];
        if (header == null)
        {
            // There is no header of the specified type in the current section, create it.
            header = new HeaderFooter(section.Document, headerType);
            section.HeadersFooters.Add(header);
        }
        foreach (Node srcNode in srcDoc.FirstSection.HeadersFooters[headerType].ChildNodes)
        {
            Node dstNode = dstDoc.ImportNode(srcNode, true, ImportFormatMode.KeepSourceFormatting);
            header.AppendChild(dstNode);
        }
    }
}

If the problem still remains, please share following detail for investigation purposes.

  • Please attach your input Word documents (source and destination).
  • Please

create a standalone/runnable simple application (for example a Console
Application Project
) that demonstrates the code (Aspose.Words code) you used to generate
your output document

As soon as you get these pieces of information to us we’ll start our investigation into your issue.