DOCM to PDF with doc.UpdateFields() issue

Hello,

Today I stumbled upon an issue when I try convert DOCM file I attached to PDF with calling wordDoc.UpdateFields() function. My code snippet is below.

If I try use Microsoft Word to export the same file to PDF with calling wordDoc.Fields.Update(), output PDF file looks better. I attached the source DOCM file and also PDF files I crested using Aspose and MS Word to this ticket.

So, could you please tell me if you can fix this issue? I’m ready to order update for my subscription if this issue can be fixed soon.

Mikhael
DOCM to PDF files.zip (220.0 KB)

Dim sSrcFile = "C:\In\Testdoc.docm"
Dim sOutPDF = "C:\out\new aspose test - Testdoc - update.pdf"

Dim wordDoc As New Aspose.Words.Document(sSrcFile)
wordDoc.UpdateFields()

Dim soPDF As Aspose.Words.Saving.PdfSaveOptions = Aspose.Words.Saving.SaveOptions.CreateSaveOptions(Aspose.Words.SaveFormat.Pdf)
wordDoc.Save(sOutPDF, soPDF)

@Mikhael Unfortunately, I cannot reproduce the problem on my side. PDF documents generated on my side look the same with and without updating fields:
out.pdf (32.9 KB)
out_updatefields.pdf (32.9 KB)

Hello @alexey.noskov,

Do you have any idea how can we debug this issue?
Shall I send you my test project?
Or may be you can tell me how can I configure Aspose.Words to createw a log file?

Because output PDF file I created still looks as you can see on the screenshot image below.

Mikhael

@Mikhael Yes, please create a simple console application that will allow us to reproduce the problem on our side. We will check the issue and provide you more information.

@alexey.noskov ,

Here is it:
https://download.print-driver.com/ex/mb/Aspose.Words-Simple-test.zip

Mikhael

@Mikhael Thank you for additional information. Still the problem is not reproducible on my side. Please make sure you have attached the correct problematic input document in the initial post in the topic.

Hello @alexey.noskov ,

Right now I downloaded ZIP file I attached at my 1-st message of this ticket and used “Aspose.Words Simple test” project I shared for you today to convert Testdoc.docm to PDF.

And the result is below.

Shall we use AnyDesk to let you debug this issue on my computer remotely?

Mikhael

@Mikhael Thich culture is set in your environment?

Bingo!

I changed it from “ru-Ru” to “en-US” and Aspose created correct PDF file!
Please look at the screenshot image below.

Is it possible to fix this issue? Or I should CurrentCulture to “en-US” every time I need to call wordDoc.UpdateFields()?

Mikhael

@Mikhael By default Aspose.Words uses the current thread culture to update the fields. You can specify FieldOptions.FieldUpdateCultureSource property to FieldUpdateCultureSource.FieldCode . In this case Aspose.Words will use culture applied to the field code while formatting field value. But in your case this approach does not work.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-27458

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@Mikhael We completed analyzing the issue and concluded it is not a bug. MS Word updates fields in the sample document in the same way.

The FieldUpdateCultureSource.FieldCode does not change behavior as intended. As per the FieldOptions.FieldUpdateCultureSource property documentation:

The setting affects only date/time fields with @ format switch.

And this is how the MS Word works. It updates most fields with current locale, but uses field code language settings when format date/time based results with \@ format switch.

Aspose.Words updates all fields with current thread culture by default. The FieldUpdateCultureSource.FieldCode option mimics MS Word behavior.