Wed Jul 17, 2019 1:02 pm
Hello!
I am testing the new functionalyty
My code is the next:
Document document = new Document();
Section section = document.AddSection();
document.CustomDocumentProperties.Add("newField", "newValue");
Field field = section.AddParagraph().AppendField("newField", FieldType.FieldDocProperty);
field.Code = @" DOCPROPERTY newField \* upper";
document.CustomDocumentProperties.Add("newDataField", "02/05/2019");
field = section.AddParagraph().AppendField("newDataField", FieldType.FieldDocProperty);
field.Code = @" DOCPROPERTY newDataField \@ ""dddd, MMMM d, yyyy""";
document.CustomDocumentProperties.Add("newMoneyField", "12,56");
field = section.AddParagraph().AppendField("newMoneyField", FieldType.FieldDocProperty);
field.Code = @" DOCPROPERTY newMoneyField \# ""0,00€""";
Section section2 = document.AddSection();
document.Variables.Add("varNewField", "newValue");
field = section2.AddParagraph().AppendField("varNewField", FieldType.FieldDocVariable);
field.Code = @" DOCVARIABLE varNewField \* upper";
document.Variables.Add("varDataField", "02/05/2019");
field = section2.AddParagraph().AppendField("varDataField", FieldType.FieldDocVariable);
field.Code = @" DOCVARIABLE varDataField \@ ""dddd, MMMM d, yyyy""";
document.Variables.Add("varMoneyField", "12,56");
field = section2.AddParagraph().AppendField("varMoneyField", FieldType.FieldDocVariable);
field.Code = @" DOCVARIABLE varMoneyField \# ""0,00€""";
document.IsUpdateFields = true;
string result = @"D:\temp\Result.docx";
document.SaveToFile(result, Spire.Doc.FileFormat.Docx2013);
I have been testing the new operation.
Both with the variables and with the properties, if the modifier is numeric, it is necessary to update the fields so that the result is correct. Otherwise, if what I do is convert the doc to pdf without opening it and updating it, the result is incorrect.
The error occurs mainly with the number modifiers.
In the DOCVARIABLES, regardless of the type of modifier I need to open the doc and give it to update fields to make it work.
Am I doing something wrong?
Thank you!!