MERGEFIELD number formatting

@Ajisha To avoid updating the fields when converting to PDF, you can use the following code:

Document doc = new Document("input.docx");

PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.UpdateFields = false;

doc.Save("output.pdf", saveOptions);

@alexey.noskov

This is a common method for all the files, so it will not change any other scenarios right?

@Ajisha This is just a workaround. It doesn’t guarantee that problems willn’t caused. I will create a bug about this.

@Ajisha
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-27168

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.

Thank you so much.

1 Like

@vyacheslav.deryushev

I have two approaches
this is the one that you suggested,
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.UpdateFields = false;
asposeDoc.Save(copyFilePathAndName, saveOptions);

This is the one I got from your support website Use French Culture from DATE Field Formatting Properties (Language Setting) & Convert DOCX to PDF using Aspose.Words (C# .NET)

doc.FieldOptions.FieldUpdateCultureSource = FieldUpdateCultureSource.FieldCode;

I am not sure which one to use. Both of them works Can you please give me suggestions?

@Ajisha Thanks for pointing.

doc.FieldOptions.FieldUpdateCultureSource = FieldUpdateCultureSource.FieldCode;

would be more effective for you.

Thank you so much.

1 Like

@alexey.noskov Hi

Our organization got the liccense for aspose.total however last time we had only aspose.words. Will there be any changes in the logic if I want to use aspose.words from aspose.total or it works like the existing code.

@Ajisha Aspose.Total is a type of license that includes all Aspose products. So you can use any of them separately without changing your code.

@alexey.noskov Thank you for all your help we got the license. However, The same logic does not work when we have this date format in the template

Can you please give us a fix for this we are currently using latest released aspose.words version and our license is total.
FANREN_Date Issue.docx (60.1 KB)
This is the line of code we use.

doc.FieldOptions.FieldUpdateCultureSource = FieldUpdateCultureSource.FieldCode;

I have attached the document for your reference.

@Ajisha Could you please elaborate the problem in more details? As I can see Aspose.Words properly update the field value. I used the following simple code for testing:

Document doc = new Document(@"C:\Temp\in.docx");
foreach (Field f in doc.Range.Fields)
{
    if (f.Type == FieldType.FieldDate)
        Console.WriteLine(f.DisplayResult);
}
Console.WriteLine("==========================");

doc.FieldOptions.FieldUpdateCultureSource = FieldUpdateCultureSource.FieldCode;
doc.UpdateFields();
foreach (Field f in doc.Range.Fields)
{
    if (f.Type == FieldType.FieldDate)
        Console.WriteLine(f.DisplayResult);
}

The output is the following:

    03 avril 2014
29 août 2024
29 août 2024
==========================
03 avril 2014
30 août 2024
30 août 2024

@Ajisha We have finished analyzing WORDSNET-27168 and concluded that this is not a bug. By default, AW updates fields with the current culture. To update some fields (e.g. DATE, TIME) with the field code culture (as MS Word does), you need to set the Document.FieldOptions.FieldUpdateCultureSource property to FieldUpdateCultureSource.FieldCode. This solution is similar to the one suggested to you earlier.

The issues you have found earlier (filed as WORDSNET-27168) have been fixed in this Aspose.Words for .NET 24.10 update also available on NuGet.

How to set cell table shading dynamically same as

Setting Background Color Dynamically

<<backColor [“red”]>>text with red background<</backColor>>

Can you please give me the template syntax for this ?

@Ajisha To make the engine fill the whole cell rather than a piece of text between opening and closing backColor tags, it is needed to put the closing backColor at the end of the cell, so opening and closing backColor tags to capture the whole cell. For example see the following simple template:

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

ReportingEngine engine = new ReportingEngine();
engine.BuildReport(doc, new object());
           
doc.Save("C:\\Temp\\out.docx");

in.docx (13.1 KB)
out.docx (10.3 KB)

@alexey.noskov I am using the latest version 24.8.0 in aspose.words and using the license aspose.total.net.lic. In this version the aspose.words wraps the text in the table to the next row. However the version 20.8 does not have this issue. Do you have a solution for this?

Thanks
Ajisha

@Ajisha Could you please attach your input, problematic and expected output documents along with code that will allow us to reproduce the problem? We will check the issue and provide you more information.

@alexey.noskov I used the latest version and the issue is resolved. Thanks

1 Like

Removed the content from the para