Hi Team -
In DOCX file (which is modified by ASPOSE word api) i have a page number in footer and other fixed content as well, when i try to get the last page footer of that file with below code I always get the first-page footer.
After that I have opened the same file in MS word 2010 and added a new line after the last paragraph and tried to get the last page footer with the same code, in that case, I am getting last page footer.
Attached herewith is the test document. (30.6 KB)
Can you please check and help me. Thanks!
public static String getLastPageFooter(String docPath) throws Exception
{
String content = “”;
Document doc = new Document(docPath);
SectionCollection sections = doc.getSections();
for (Section section : sections)
{
HeaderFooterCollection headerFooterCollection = section.getHeadersFooters();
HeaderFooter headerFooter= headerFooterCollection.getByHeaderFooterType(HeaderFooterType.FOOTER_PRIMARY);ParagraphCollection paragraphs = headerFooter.getParagraphs(); for (Paragraph paragraph : paragraphs) { RunCollection runs = paragraph.getRuns(); for (Run run : runs) { content += run.getText(); } content += "\n"; } } doc.removeExternalSchemaReferences(); return content;
}