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. Image for the cookie policy date

Equations not properly converted when converting from Word to PDF

Hello!

Is this a limitation of the library or is there a possible workaround?

Thanks!

3 Replies

MN Meikanda Nayanar Syncfusion Team April 25, 2019 11:53 AM UTC

Hi Michael 
 
We need to analyze your input Word document to understand which type of equation is used. Syncfusion Word library (DocIO) does not support equations created other than “Equation field”. Could you please provide us the input Word document along with the code snippets which are used at your end? So that we can analyze further in line with your requirement and provide exact solution at the earliest.

Note: If you have any confidential data in your Word document, please replace with some dummy data and provide us the same. We just need your document to recreate the problem you face.
 
 
Please let us know if you need any further assistance in this. 

Thanks 
Meikandan 



MI Michael April 25, 2019 08:44 PM UTC

Hi!

Thanks for the response. Here is the input *.docx file and output *.pdf file.

The code I used is:

using (MemoryStream mem = new MemoryStream())
            {
                mem.Write(Input, 0, Input.Length);

                //Loads an existing Word document
                WordDocument wordDocument = new WordDocument(mem, FormatType.Docx);

                //Initializes the ChartToImageConverter for converting charts during Word to pdf conversion
                wordDocument.ChartToImageConverter = new ChartToImageConverter();

                //Sets the scaling mode for charts (Normal mode reduces the Pdf file size)
                wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal;

                //Creates an instance of the DocToPDFConverter - responsible for Word to PDF conversion
                DocToPDFConverter converter = new DocToPDFConverter();

                //Sets ExportBookmarks for preserving Word document headings as PDF bookmarks
                converter.Settings.ExportBookmarks = Syncfusion.DocIO.ExportBookmarkType.None;

                //Sets true to enable the fast rendering using direct PDF conversion.
                converter.Settings.EnableFastRendering = true;

                //Converts Word document into PDF document
                PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);

                using (MemoryStream mem2 = new MemoryStream())
                {
                    //Saves the PDF file to file system
                    pdfDocument.Save(mem2);

                    //Closes the instance of document objects
                    pdfDocument.Close(true);

                    wordDocument.Close();

                    Output = mem2.ToArray();
                }
}

It is almost the same as what is found in the documentation for DocIO.

Thanks!

Attachment: Equations_a8356b7f.rar


VA Vijayasurya Anandhan Syncfusion Team April 29, 2019 08:48 AM UTC

Hi Michael, 
 
Thanks for your update. 
 
On further analyzing the input word document provided from your side, we found that the input word document contains “EquationML” elements. Currently DocIO doesn’t have support for EquationML in a Word document. So, equations are not preserved properly in Word to PDF conversion. We have already logged this requirement as a feature request, but we don’t have any immediate plans to implement this feature. At the planning stage for every release cycle, we review all open features. We will let you know when this feature is implemented. The status of implementation can be tracked through our Features Management System: 
  
As a workaround, the equation can be saved as an image and replaced in the Word document using Microsoft Word and then use the Word document for conversion. Please find the input Word document and generated PDF for the above workaround in the following sample.  
Thanks, 
Vijayasurya A 


Loader.
Live Chat Icon For mobile
Up arrow icon