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

Free Support Forum - aspose.com

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.


<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>AR-SA</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

<![endif]–>

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.