How can i create a forumla in a Word Document from 1/2 to a Break
3 Replies
MJ
Mohanaselvam Jothi
Syncfusion Team
July 17, 2019 07:32 AM UTC
Hi Christian,
Thank you for contacting Syncfusion support.
To achieve your requirement, we suggest you to append predefined symbols using its character code in the Word document. Also, you can append custom formula by appending EQ field in the Word document.
Please refer the below code example and let us know if it helps you:
Thank you for contacting Syncfusion support.
To achieve your requirement, we suggest you to append predefined symbols using its character code in the Word document. Also, you can append custom formula by appending EQ field in the Word document.
Please refer the below code example and let us know if it helps you:
|
//Creates a new Word document
WordDocument document = new WordDocument();
//Add one section and one paragraph
document.EnsureMinimal();
//Get the last paragraph.
WParagraph paragraph = document.LastParagraph as WParagraph;
paragraph.AppendText("Symbol using character code : ");
//Append fraction symbol using its character code.
paragraph.AppendText("\u00BD");
//Add paragraph into the Word document
paragraph = document.LastSection.AddParagraph() as WParagraph;
paragraph.AppendText("Custom formula using Equation field ");
//Append equation field
WField field = paragraph.AppendField("EQ", FieldType.FieldExpression) as WField;
//Set field code to preserve fractions
field.FieldCode = "EQ \\f(2,3)";
//Saves and closes the Word document
document.Save("Sample.docx");
document.Close();
|
Please let us know if you have any other questions.
Regards,
Mohanaselvam J
CS
Christian Stutz
July 18, 2019 07:57 AM UTC
Hello,
the eq fields works, but there is the wrong style!
i want to display like the pic.
Thanks for help
Christian
PR
Poorani Rajendran
Syncfusion Team
July 18, 2019 02:01 PM UTC
Hi Christian,
Thank you for your update
To achieve your requirement, we suggest you to append predefined symbols using its character code in the Word document and can increase the size of the text by using CharacterFormat.FontSize API
Please refer the below code example and let us know if it helps you:
Thank you for your update
To achieve your requirement, we suggest you to append predefined symbols using its character code in the Word document and can increase the size of the text by using CharacterFormat.FontSize API
Please refer the below code example and let us know if it helps you:
|
//Creates a new Word document
WordDocument document = new WordDocument();
//Add one section and one paragraph
document.EnsureMinimal();
//Get the last paragraph.
WParagraph paragraph = document.LastParagraph as WParagraph;
//Append fraction symbol using its character code.
paragraph.AppendText("1/2" + " " + "\u00BD");
WTextRange text = paragraph.ChildEntities[0] as WTextRange;
//Sets the size for the text
text.CharacterFormat.FontSize = 12;
//Saves and closes the Word document
document.Save("Sample.docx");
document.Close();
|
Please find the output document generated at our side.
https://www.syncfusion.com/downloads/support/forum/145978/ze/Sample_DOCIO1063165128
Please let us know if you have any other questions.
Regards,
Poorani Rajendran
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
CS Christian Stutz
- Jul 16, 2019 02:10 PM UTC
- Jul 18, 2019 02:01 PM UTC