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

Free Support Forum - aspose.com

Multiple headers problem in Word

I have the following problem with creating multiple headers in WORD. I loop through a foreach and for each item i want to create a different header. How do i acchieve this? (the current code is just pasting the new header to the first header…)

attached is the code.

Hi

Thanks for your inquiry. Could you please attach your output and expected output documents? I will check the and provide you more information.

You should note that MS Word document consists of Sections, each Section can have three types of Headers/Footers – First Page, Primary and Even Pages.

In your code, it seems you just insert First Page header of the first section of the document.

Best regards.

Hi Alexey,

You are correct. The problem is solved now.

However, now i constantly get the message that the document i’m trying to open is corrupt. Is this due to licenscing model? On my development machine it works fine but i’m getting this on the server machine.

This error message can appear if the document you are attempting to open is corrupt. It is possible to recover a corrupt file or its content by using either the Recover Text converter (may require installation) or the Open and Repair feature.

Hi

Thank you for additional information. Could you please attach the corrupted document here for testing and show me the code you are using to save the output document? I will check the issue and try to provide you a solution.

Best regards.

Hi Alexey,

Attached is such a ‘corrupted’ document.

Also attached is the code generating the file.

Hi

Thank you for addition information. It seems the corruption occurs because few bytes at the end of the file are missed. This can occur if you read/write file improperly.

By the way, I can successfully open/save the document using Aspose.Words and the output document works fine in MS Word.

So please check your code one more time, maybe you read/write the document improperly somewhere.

Best regards.