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

Free Support Forum - aspose.com

Content with Header and Footer

Hi,

This is the code I used to set header and footer with content. header and footer is working well but the content is not displaying.

builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.InsertImage(“D:\abc.jpg”, RelativeHorizontalPosition.LeftMargin, 510, RelativeVerticalPosition.Page, 20, 50, 50, WrapType.Through);
builder.InsertImage(“D:\def.jpg”, RelativeHorizontalPosition.LeftMargin, 25, RelativeVerticalPosition.Page, 20, 50, 50, WrapType.Through);

Table table = builder.StartTable();
foreach (DataRow item in dtGroup.Rows)
{
builder.InsertCell();
builder.Write(item);
builder.EndRow();
builder.InsertBreak(BreakType.PageBreak);
}
builder.EndTable();
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.Write(“Disclaimer”);

I want to keep a logo as header, disclaimer as footer, and the Content is table format… each item display in each page.
Kindly Help ,
Thanks.

Hi,

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

  • Your input Word document
  • Image file(s) you're inserting in document
  • Aspose.Words generated output DOCX file showing the undesired behavior
  • Please attach your expected document here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document using Microsoft Word.
  • Please create a standalone console application (source code without compilation errors) that helps us 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 further investigation into your issue and provide you more information. 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,

I have enclosed Expected OUPUT file. Already provided the Source code for it.
Kindly help as Earliest,
Thanks.

Hi,


Thanks for your inquiry. I am afraid, you can’t insert a page break inside a Table. Please try running the following code instead. (output document is attached)

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

DataTable dtGroup = GetDataTable1();

foreach (DataRow item in dtGroup.Rows)

{

builder.Writeln();

builder.Writeln();

builder.Writeln();

builder.Writeln();

builder.Writeln();

builder.Writeln();

builder.Writeln();

Table table = builder.StartTable();

builder.InsertCell();

builder.Write(item[0].ToString());

builder.EndRow();

builder.EndTable();

builder.InsertBreak(BreakType.PageBreak);

}

builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);

builder.InsertImage(@"D:\temp\aspose.words.jpg", RelativeHorizontalPosition.LeftMargin, 510, RelativeVerticalPosition.Page, 20, 50, 50, WrapType.Through);

builder.InsertImage(@"D:\temp\aspose.words.jpg", RelativeHorizontalPosition.LeftMargin, 25, RelativeVerticalPosition.Page, 20, 50, 50, WrapType.Through);

builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

builder.Write("Disclaimer");

doc.Save(MyDir + "17.2.0.docx");


Hope, this helps.

Best regards,