We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can i create a forumla in a Word Document from 1/2 to a Break

Thread ID:

Created:

Updated:

Platform:

Replies:

145978 Jul 16,2019 02:10 PM UTC Jul 18,2019 02:01 PM UTC WPF 3
loading
Tags: DocIO
Christian Stutz
Asked On July 16, 2019 02:10 PM UTC

Hi,

how can i create this in word with DocIO ?


Christian

Mohanaselvam  Jothi [Syncfusion]
Replied On 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: 
//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  


Christian Stutz
Replied On 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



Poorani Rajendran [Syncfusion]
Replied On 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: 
 
//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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon