Hi
Thanks for your request. Please try using the following code.
Document doc = new Document(@"Test131\Dong_3_test_Signed.doc");
doc.AcceptAllRevisions();
DocumentBuilder builder = new DocumentBuilder(doc);
// Create collection of footer types
ArrayList footerTypesList = new ArrayList();
footerTypesList.Add(HeaderFooterType.FooterEven);
footerTypesList.Add(HeaderFooterType.FooterFirst);
footerTypesList.Add(HeaderFooterType.FooterPrimary);
Image barCode = CreateBarCodeImage("BIC1#######/BIC2#######/TRADEREF1###########/TRADEREF2###########/2007-10-11/2007-09-12/2007-08-13/USD/452345#######/567###.17##");
for (int sectIndex = 0; sectIndex < doc.Sections.Count; sectIndex++)
{
builder.MoveToSection(sectIndex);
// InsertBarcode into the each footer in the document
foreach (HeaderFooterType footerType in footerTypesList)
{
if (builder.Document.Sections[sectIndex].HeadersFooters[footerType] != null || sectIndex == 0)
{
//// Get page setup for the current section.
Aspose.Words.PageSetup pageSetup = builder.CurrentSection.PageSetup;
builder.MoveToHeaderFooter(footerType);
if (!builder.Document.Sections[sectIndex].HeadersFooters[footerType].IsLinkedToPrevious)
{
// We use table with two cells to make one part of the text on the line (with page numbering)
// to be aligned left, and the other part of the text (with copyright) to be aligned right.
Table tab = builder.StartTable();
// Calculate table width as total page width with left and right marins subtracted.
double tableWidth = pageSetup.PageWidth - pageSetup.LeftMargin - pageSetup.RightMargin;
builder.InsertCell();
// Set first cell to the page width.
builder.CellFormat.Width = tableWidth;
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Bottom;
builder.RowFormat.Height = ConvertUtil.PixelToPoint(barCode.Height);
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
Shape barcode = builder.InsertImage(barCode);
builder.EndRow();
builder.EndTable();
HeaderFooter hf = (HeaderFooter)builder.CurrentParagraph.GetAncestor(NodeType.HeaderFooter);
if (!hf.FirstChild.Equals(tab))
hf.InsertBefore(tab, hf.FirstChild);
}
}
else
{
builder.Document.Sections[sectIndex].HeadersFooters.LinkToPrevious(footerType, true);
}
}
}
doc.Save(@"Test131\out.doc");
Hope this helps.
Best regards.