Apply Bold formatting to equations

Hello,

In the attached project, I am using some code that you gave me in order to apply formatting to all characters in an equation. I have added an option to set the equation to be bold, but the bold format is not being applied to all of the characters in the equation. Can you please take a look and let me know how I can resolve this issue? 


Thanks.


Attachment: LatexEquation_4251db7a_(1)__Copy_5ae46f31.zip

6 Replies

DS Dharanya Sakthivel Syncfusion Team November 25, 2024 07:03 PM UTC

Hi Natalie,

Based on the given details, we understand that you are trying to apply bold formatting to the equations. Kindly refer to the documentation and GitHub link for applying bold formatting. You can also refer to the code snippet below for reference:

WordDocument document = new WordDocument();

 document.EnsureMinimal();

 document.LastParagraph.AppendMath(@"\mathbf{A_{33} B_{44}}");



Regards,
Dharanya.



NW Natalie Westphal November 25, 2024 09:03 PM UTC

Hi Dharanya,

Adding \mathbf formats the equation as text so none of the equations are formatted properly, so this is not a solution to my original problem. Is there another way to do this? 


Thanks. 



DS Dharanya Sakthivel Syncfusion Team November 26, 2024 04:10 PM UTC

Natalie,
We have modified the code snippet to apply bold formatting in
MathFormat style. In Microsoft Word, bold formatting for equations is applied in MathFormat style to ensure proper preservation. Kindly use the below line of code in the SetCharacterFormatToRunElement() method and also refer to the attached modified sample for reference.


runElement.MathFormat.Style = MathStyleType.Bold;


Regards,
Dharanya.


Attachment: LatexEquationModified_c4c97cfd.zip


NW Natalie Westphal November 26, 2024 09:46 PM UTC

Hello,

Please see the attached file that displays a PDF where some of the characters are still not shown in bold. Please advise on how to solve this issue. 


Thanks. 


Attachment: ReportGeneration__Copy_d31a0a7d.zip


DS Dharanya Sakthivel Syncfusion Team November 27, 2024 06:37 PM UTC

Natalie,
We have reproduced the reported problem while viewing the content in the PDF Viewer—some characters are still not displayed in bold. However, when we saved the PDF document, we verified that the bold formatting for the equation content was applied correctly. We will check the reason why some equation characters are not shown in bold and share further details within two days.

Regards,
Dharanya.



AN Anto Nihil Sahaya Raj Syncfusion Team November 29, 2024 04:53 PM UTC

Hi Natalie,

On further investigation, font glyphs are not available in the PDF document, so that bold is not applied in the PDF document. We recommend setting the EmbedFonts and EmbedCompleteFonts APIs to true during Word to PDF conversion. This setting allows you to embed the complete font information (glyphs) from the TrueType fonts used in the converted PDF document. It is helpful to resolve the reported issue.

Please use the highlighted code snippet below during the Word to PDF conversion to resolve the reported issue.

private void CreateAndDisplayReport()

 {

     var reportInfo = Report.GenerateProjectReportTemplate();

 

     var reportGenerator = new ReportGenerator();

     var document = reportGenerator.BuildSyncfusionReport(reportInfo);

 

     var tempPath = Path.GetTempFileName();

 

     using (DocToPDFConverter converter = new())

     {

         converter.Settings = new DocToPDFConverterSettings() { ExportBookmarks = ExportBookmarkType.Bookmarks, EmbedFonts = true, EmbedCompleteFonts = true };

         //Converts Word document into PDF document

         using (PdfDocument pdfDocument = converter.ConvertToPDF(document))

         {

             //Saves the PDF document

             pdfDocument.Save(tempPath);

         }

     };

 

     document.Close();

 

     pdfViewer.Load(tempPath);

 }


Regards,

Anto Nihil S


Loader.
Up arrow icon