We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Extra spaces in Footer text

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")

Kindly help me to solve this issue.

Hi there,

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);
        foreach (Node srcNode in srcDoc.FirstSection.HeadersFooters[headerType].ChildNodes)
            Node dstNode = dstDoc.ImportNode(srcNode, true, ImportFormatMode.KeepSourceFormatting);

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.