Free Support Forum - aspose.com

Page Background Color gone

I have a Microsoft Word document which having few pages. First page and Last page are having the same blue page background color. The middle pages are dynamic. When the middle pages are generated with more pages, the blue page background color will gone (with white background) in the Last page.

Appreciate any comment and helps.

@siewli.hue,

Thanks for your inquiry. Please ZIP and attach your input Word document here for testing. We will investigate the issue on our side and provide you more information.

Sample Background Color issue.zip (401.0 KB)
@tahir.manzoor
Sample as attached. when additional contents added to endorsement bookmark in page 7, purple background color in page 8 will become white background color.

Thanks for your support in advance.

@siewli.hue,

Thanks for your inquiry. In your document there is section break at page 7 and this section has shape node with filled color in header. Please check the attached image for detail. Shape in header.png (32.1 KB)

When you insert the content for endorsement bookmark, this section is pushed down to the next pages. Please note that Aspose.Words mimics the behavior of MS Word. If you insert the content at page 7 using MS Word, you will get the same output.

@tahir.manzoor
Thank you for your quick response.

We have similar setting in page 13 (EPL Endorsement bookmark). However, page 14 background color still remain to be displayed correctly. We are follow this setting for page 7 and 8 but it is not working in the middle page?

@siewli.hue,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document. No need to share this document if it is “Sample Background Color issue.docx”.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

@tahir.manzoor

  1. The input word document is same - “Sample Background Color issue.docx”
  2. Attached is the output which generated from my system. When there is endorsement contents in Page 7, background color in page 9 is gone.
    However, when there is endorsement contents in Page 14, background color in Page 16 still retain.
  3. Expected output is like in Page 14 & Page 16 in the same output file that when there is endorsement contents, the background color should retain.
  4. Sorry that I don’t have standalone console application. Our system is an internal web site.

Thank you.AU_DOEPL_PS_0118_247633.zip (381.8 KB)

@siewli.hue,

Thanks for sharing the detail. In your case, you need to insert the same shape node in the desired section. Please note that the purple background is Shape node in the first header of section. You need to copy the nodes of same section in the desired section.

Please use Node.Clone method to clone the nodes of header and append them into destination section using HeaderFooter.ChildNodes.Add method.

Hi Tahir,
This text will be hidden
Herewith i have attached the stand alone console application. The solution contains Template folder with 1) Schedule and 2) Endorsement documents.
There are 2 output files in the output folder.AsposeFunctionTest.zip (1.1 MB)

  1. Schedule_output_withCoverpage
  2. Schedule_output_withOutCoverpage

There is cover page with color background at 41 page in the Schedule template. After insert the endorsement to Schedule using the function “InsertDocumentAtBookmark” that Color background cover page not available. Please refer the output folder for with and without cover page.

Kindly give your input to fix this issue. Thank you.

@siewli.hue,

Thanks for your inquiry. The content of page 41 has section with PageSetup.DifferentFirstPageHeaderFooter property as true. You are setting this property to false in the code. Please comment this line of code to see the correct output.

for (int i = 1; i < mainDocument.Sections.Count - 1; i++)
{
    Section sec = mainDocument.Sections[i];
    sec.PageSetup.DifferentFirstPageHeaderFooter = false; // this line of code changes the output
}

You can modify this code as shown below to get the desired output. Hope this helps you.

// Except the last page of Main document i.e Count -1 maintain same Footer
for (int i = 1; i < mainDocument.Sections.Count - 1; i++)
{
    Section sec = mainDocument.Sections[i];
    if (sec.HeadersFooters[HeaderFooterType.HeaderFirst] != null && sec.HeadersFooters[HeaderFooterType.HeaderFirst].GetChildNodes(NodeType.Shape, true).Count == 0)
        sec.PageSetup.DifferentFirstPageHeaderFooter = false;
}