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

Free Support Forum - aspose.com

Appending letterhead document leaves page body empty

I have a word doc that has nothing but the corporate header.
I want to append additional content to the document keeping the header on the first page only.
I can add the additional content but they are always new pages rather than the body of the letterhead.

How can i approach this?
I am currently using:

foreach (Aspose.Words.Section srcSection in TempDoc)
{
Aspose.Words.Node dstSection = LetterheadDoc.ImportNode(srcSection, true, Aspose.Words.ImportFormatMode.KeepSourceFormatting);
LetterheadDoc.AppendChild(dstSection);
}

Hi Marc,

Thanks for your inquiry. Please attach the following sample resources here for testing:

  • Word document that contains header content
  • Word document which contains the content for the Body
  • Your expected Word document showing the final result. You can create expected document using Microsoft Word.

As soon as you get these pieces of information ready, we'll start investigation into your issue and provide you code to achieve the same using Aspose.Words. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.

Best regards,

here are the 3 documents requested.

thanks!

Hi Marc,


Thanks for your inquiry. You can get expected output using the following code:

Document docHead = new Document(MyDir + @“LetterheadXX.docx”);

Document docBody = new Document(MyDir + @"content.docx");

foreach (Section sec in docBody.Sections)

{

Section importedSec = (Section)docHead.ImportNode(sec, true);

importedSec.ClearHeadersFooters();

if (sec == docBody.FirstSection)

importedSec.PageSetup.SectionStart = SectionStart.Continuous;

docHead.AppendChild(importedSec);

}

docHead.Save(MyDir + @"LetterheadXX\15.10.0.docx");


Hope, this helps.

Best regards,

That was the solution!

Thanks!