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

Free Support Forum - aspose.com

Table in MS Word Footer to PDF

hi,


I have a table with three columns in the footer of a MS Word document, when i save the document as PDF the footer allignment in PDF document is messed up. how to fix this?
i have attached both MS Word and PDF documents for your reference.

Please let me know.

Thanks in advance!


code used to add footer is as below:

builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
Table footer =builder.StartTable();

builder.CellFormat.Borders.LineWidth = 0;
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
if (!StringUtils.Compare(userInput.GetValue(“FL”), “”) || !StringUtils.Compare(userInput.GetValue(“FR”), “”))
{
builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.Auto;
builder.Write(userInput.GetValue(“FL”));
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.CellFormat.Borders.Top.LineWidth = 1;
}

builder.InsertCell();
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.CellFormat.Borders.Top.LineWidth = 1;

if (StringUtils.Compare(userInput.GetValue(“FC”), “PageXofY”))
{
builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(15);
builder.InsertField(“PAGE”);
builder.Write(" of ");
builder.InsertField(“NUMPAGES”);

}
else if (StringUtils.Compare(userInput.GetValue(“FC”), “PageX”))
{
builder.Write("Page ");
builder.InsertField(“NUMPAGES”);
}
else if (StringUtils.Compare(userInput.GetValue(“FC”), “PageNo”))
{
builder.InsertField(“PAGE”);
}

if (!StringUtils.Compare(userInput.GetValue(“FR”), “”) || !StringUtils.Compare(userInput.GetValue(“FL”), “”))
{
builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.Auto;

builder.Write(userInput.GetValue(“FR”));
builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
builder.CellFormat.Borders.Top.LineWidth = 1;
}
builder.EndRow();
builder.CellFormat.Borders.LineWidth = 0;
builder.EndTable();

Hi Chenna,

Thanks for your inquiry. In your case, I suggest you please call Document.UpdateTableLayout method before saving the final output Pdf. This method updates widths of cells and tables in the document according to their preferred widths and content. You do not need to call this method if the tables appear correct in the output document.

If you still face problem, please share following detail for investigation purposes.


  • Please attach your input Word document.
  • 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.