Hi,
When converting a DOCX with French date fields to PDF. I noticed the formatting has been reset to English:
Code:
var doc = new Document(@".\test.docx");
doc.Save(@".\test.pdf");
When I did the same in Word ‘save as’ PDF feature, the formatting is preserved properly.
I’ve attached the examples and a screenshot for your reference. Could you please help me take a look?
test.zip (59.5 KB)
image.png (8.5 KB)
Thanks,
@ServerSide527,
I think, you should specify the culture info before running that code:
CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
Document doc = new Document("E:\\Temp\\TEST\\test.docx");
doc.Save("E:\\Temp\\TEST\\20.3-fr-FR.pdf");
Hope, this helps.
Thanks for your advice. I’m aware of such settings but I don’t think this would work in this case.
First thing is that the document is opened in English settings in Office Word, not in French, when I converted this to PDF using Word ‘save as’ feature, it is using English local but could still produce the french date format. So I don’t think the date field region should rely on the document/application level.
Second is that if I set such settings in Aspose, all date fields will use the french setting, but in fact in Word you might have date from different regions. If I set such setting in Aspose, the result will all be changed to French. I have attached a test file and a screenshot for your reference
testmultilanguage.zip (36.6 KB)
image.png (134.2 KB)
Since Aspose.Words mimics the features in Word, it should have the same ability to judge each field separately without changing the thread locale, otherwise it is not possible to fully reflect the content in MS Word.
UPDATE: in case it helps, I’m also adding here why the French language is individually set on the field level: the style of the specific run has French region. I’ve highlighted such settings in the below screenshot.
image.png (441.1 KB)
therefore, setting up a French thread will not help the issue but overwrite the language settings in every other run which might very likely be some other languages.
Could this be fixed so Aspose would properly render content based on the correct locale of each run?
Thanks,
@ServerSide527,
Please check if the following solution is acceptable for you?
Document doc = new Document("E:\\Temp\\testmultilanguage\\test.docx");
doc.FieldOptions.FieldUpdateCultureSource = FieldUpdateCultureSource.FieldCode;
doc.Save("E:\\Temp\\testmultilanguage\\20.3-FieldUpdateCultureSource-FieldCode.pdf");
Thanks for your advice! This seemed to work perfectly for me.
By any chance, could you shed some light on why this was not the default option even if it was the default behaviour in Word? Was there any technical reason/concern behind that?
Thanks,
@ServerSide527,
We are working on your query and will get back to you soon.
@ServerSide527,
This is because we added this option in Aspose.Words at some point in the past and had to preserve the default behavior for backward compatibility.
Hope, this helps.
That makes sense, thank you for the clarification!