The conversion from DOCX to PDF results in alterations to the content(ECDCTS-10551)

The attached document has the text “Figure 4 - Upload Files”. After conversion to PDF this text is changed to this “Figure 1 - Upload Files”. Please let us know the reason.
Below code has been used -

com.aspose.words.Document doc = new com.aspose.words.Document("C:\\Desktop\\Figure numbering.docx");
doc.save("C:\\Users\\Desktop\\Figure numbering_test.pdf");

Figure Numbering.zip (27.6 KB)

@rnara Upon conversion to PDF Aspose.Words automatically updates fields in the document. So SEQ field is updated. You can disable automatic field updating to keep the old value of the fields upon conversion to PDF:

Document doc = new Document("C:\\Temp\\in.docx");
PdfSaveOptions opt = new PdfSaveOptions();
opt.setUpdateFields(false);
doc.save("C:\\Temp\\out.pdf", opt);

If you update field in MS Word or convert document to PDF using MS Word you will see the same result as Aspose.Words. result.

We are currently converting from DOCX to PDF, and the provided code is encountering issues with accepting DOCX as input.

Document doc = new Document("C:\\Temp\\in.docx");

Additionally, when attempting to use setUpdateFields in PdfSaveOptions, an error occurs, stating 'can’t resolve method ‘setUpdateFields’
The versions in use are AsposeWords-23.12 and AsposePDF-23.11.

We are seeking guidance on resolving these challenges without making changes to the existing codebase. Your suggestions are appreciated.

Thanks,
Bhupali

@rnara It looks like you are using Document and PdfSaveOptions classes from a wrong namespace. Please try using the fully qualified class names:

com.aspose.words.Document doc = new com.aspose.words.Document("C:\\Temp\\in.docx");
com.aspose.words.PdfSaveOptions opt = new com.aspose.words.PdfSaveOptions();
opt.setUpdateFields(false);
doc.save("C:\\Temp\\out.pdf", opt);

Why are we using setUpdateFields as false?
When do we use it?
What is the purpose of using it?
What is that supposed to achieve?

@rnara Your input document contains MS Word field, in your particular case it is a SEQ field:

Field structure in MS Word consist of FieldStart, FieldSeparator and FieldEnd nodes. Content between field start and field separator is field code, and content between field separator and field end is field value – the value, which you actually see in the document. See our documentation to learn more about fields:
https://docs.aspose.com/words/java/introduction-to-fields/

Upon conversion to PDF Aspose.Words automatically updates fields in the document. So SEQ field is updated. SEQ field’s purpose is showing sequentially numbers for chapters, tables, figures, and other items in a document. In the attached document there is only one SEQ field, so it’s value is updated to 1 – the first sequential number.

If you disable updating field, Aspose.Words leaves the old (not actual) value of the field. By default PdfSaveOptions.UpdateFields option is enabled, i.e. Aspose.Words mimics MS Word behavior and updates field in the document before rendering it.