We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Update Table of Content TOC Fields in MS Word & LibreOffice Documents using Java | Update TOC Page Numbers

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

@Rammoslee,

We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-20130. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Hi @awais.hafeez,
May I know the timeline for the WORDSNET-20130 ID?

Thank & Regards
Romuelee

@Rammoslee,

I am afraid, your issue is currently pending for analysis and is in the queue. There are no estimates available at the moment. Once the analysis of this issue is completed and the root cause is determined, we may then be able to calculate and share the ETA of this issue with you. We apologize for any inconvenience.

The issues you have found earlier (filed as WORDSNET-20130) have been fixed in this Aspose.Words for .NET 20.4 update and this Aspose.Words for Java 20.4 update.