please help, Why the method doc.updateField() is not working to refresh TOC for a document is created from MS Word?, but it’s work for the same file it’s SAVED from LibreOffice.
Input:
MSOffice: https://drive.google.com/file/d/17_alr-6gs3wsocylfjx34sumkqpo9m7q/view?usp=sharing
LibreOffice: https://drive.google.com/file/d/1hlw_dnpecojzoqpvnsqburjysyou5ux2/view?usp=sharing
Output:
MSOffice: https://drive.google.com/file/d/1ft4gdop4o32fc0vhasoljixvvflvtxbj/view?usp=sharing
LibreOffice: https://drive.google.com/file/d/1smohxcgtfsm8qwlqv6l_j5h0hzyxbej6/view?usp=sharing
Source Code:
public static void main(String[] args) {
try {
File workingFile = new File("/home/ramoslee/work/testScript/MSOfficeService/Example/TOC_From_Libre.DOCX");
tableContentTesting(workingFile, "/home/ramoslee/work/testScript/MSOfficeService/Example/" + "/test/TOC_Libre_Out.DOCX");
File workingFile1 = new File("/home/ramoslee/work/testScript/MSOfficeService/Example/TOC_From_office.DOCX");
tableContentTesting(workingFile1, "/home/ramoslee/work/testScript/MSOfficeService/Example/" + "/test/TOC_office_Out.DOCX");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static void tableContentTesting(File workingFile, String ouputfile) {
try {
setAsposeLicense();
com.aspose.words.Document doc = null;
doc = new com.aspose.words.Document(workingFile.getPath());
doc.updateFields();
doc.save(ouputfile);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Thank & Regards
Romuelee Buesa