Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Aug 24, 2020 7:07 am

Hi,

Is there any way to get the merge field that is in the Header and Footer of the document. currently i am not able to get those, any way of doing that.

Thanks in Advance

charan9501
 
Posts: 2
Joined: Sat Feb 09, 2019 3:08 pm

Mon Aug 24, 2020 7:34 am

Hi,

Thanks for your inquiry.
Please refer to following code to get the merge fields in header and footer.
Code: Select all
            Document document = new Document();
            document.LoadFromFile(FilePath + @"22596.docx");
            FieldCollection fields = document.Fields;
            List<Field> fieldInHeaderFooter = new List<Field>();
           
            foreach (Field field in fields)
            {
                //detect if the field is in header and footer
                if (field.OwnerParagraph.Owner is HeaderFooter)
                {
                    fieldInHeaderFooter.Add(field);
                }
            }

If this doesn't meet your requirement, please share your input document as well as the detailed information.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Sep 02, 2020 8:47 am

Hi,

Has your issue been resolved? Could you please give us some feedback at your convenience?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.Doc