Date Field is incorrect after DOCX to PDF Conversion using Java

Hi,

We currently use conversion from MS Word to PDF/A, using Aspose.WORD for Java (version 20.7.0). Where ever there is a DATE function used in the MS Word document, the converted PDF realizes the DATE to the date of conversion, rather than trying to set the original date that was used in the original MS Word document.

Here is a sample MS Word document, where the date in the title is 16-Dec-2020, however the conversion derives the date and fills the same as the date of conversion rather than the original date.

Please let me know if there is anything that can be done using Aspose Java API to handle such scenario. (such as - pick the original date at the time of conversion rather than, derived date etc.)

For your reference, we use below sample code snippets as per standard API method (Document.save())-

InputStream docStream; // This holds the input document stream dynamically to this variable.

ByteArrayOutputStream stream = new ByteArrayOutputStream();
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setCompliance(PdfCompliance.PDF_A_1_B);

Document msDocumentConvert = msDocumentConvert = new Document(docStream);
msDocumentConvert.save(stream, saveOptions);

Thanks a lot in advance for all your feedback and support into the same.

Rgs,

JitenFILENET_4 - forcheckDATE_20201216.zip (31.4 KB)

@jitendriya.dash

We suggest you please try the latest version of Aspose.Words for Java 20.12. Hope this helps you.

If you still face problem, please provide information about your specific culture, such as the name of the culture, language and country/region. Please also share the screenshot of input Word document along expected output PDF. We will investigate the issue and provide you more information on it.

Thanks. Have used the latest Aspose.Words for Java 20.12, and can see the same issue. Here is the sample code snippet used for the conversion, along with the original Word and converted PDF for your reference.

The problem statement is - for the date which is written using a DATE function in the input MS Word document, it shows the correct date in the read-only mode (i.e. 16-Dec-2020), however it takes today’s date and converts the date as per the system date which is wrong. (i.e. 21-Dec-2020 as per the today’s test run, with below code sample). I have highlighted the date field in a screenshot, for reference.

Thanks a lot in advance for all your feedback and support into the same. Please let me know if any specific API techniques can be used to use the original date, for DATE function at the time of conversion to PDF.

Rgs,

Jiten


public void wordandpdf() {

try {

Document doc = new Document(“C:\temp\FILENET_4 - forcheckDATE_20201216\FILENET_4 - forcheckDATE_20201216.docx”);

PdfSaveOptions options = new PdfSaveOptions();

options.setCompliance(PdfCompliance.PDF_A_1_A);

doc.save(“C:\temp\FILENET_4 - forcheckDATE_20201216\forcheckDATE_20201216.pdf”,options);

} catch (Exception e) {

e.printStackTrace();

}

}
Correct_View_with_Readonly_mode_in_Microsoft_Word.PNG (69.7 KB)
FILENET_4 - forcheckDATE_20201216.zip (121.0 KB)

@jitendriya.dash

The Date field inserts the current date in MS Word document. When you update this field, it will show you the today’s date.

We suggest you please use PdfSaveOptions.UpdateFields property as shown below to get the desired output. Hope this helps you.

Document doc = new Document(MyDir + "FILENET_4 - forcheckDATE_20201216.docx");

PdfSaveOptions options = new PdfSaveOptions();
options.setCompliance(PdfCompliance.PDF_A_1_A);
options.setUpdateFields(false);
doc.save(MyDir + "20.12.pdf", options);

This really helps, thanks for clarifying.