Hi,
I’m trying to add some footer text to an appended document but am having no success. Here is the function I’m using. Can you please tell me why this is not working?
Thanks
public void AddDocument(string DocumentNameandPath, string FooterText)
{
if (String.IsNullOrEmpty(DocumentNameandPath))
throw new ArgumentException("DocumentNameandPath is null or empty.", "DocumentNameandPath");
// Open the source document.
Document srcDoc = new Document(DocumentNameandPath);
if (FooterText.Length > 0)
{
foreach (Section srcSection in srcDoc)
{
HeaderFooter Footer = srcSection.HeadersFooters[HeaderFooterType.FooterPrimary];
if (Footer == null)
{
Footer = new HeaderFooter(srcSection.Document, HeaderFooterType.FooterPrimary);
srcSection.HeadersFooters.Add(Footer);
}
}
srcDoc.FirstSection.HeadersFooters[HeaderFooterType.FooterPrimary].Range.Replace("*", FooterText, false, false);
}
mDocument.Document.AppendDocument(srcDoc, ImportFormatMode.UseDestinationStyles);
// AppendDoc(mDocument, srcDoc, FooterText);
}