Formatting lost when saving as a PDF

Hello,

It seems that much of my formatting settings are lost when saving a WordDocument as a PDF. I have created the document and then called:

document.Save(fileName);

and also done this: 

            using (DocToPDFConverter converter = new DocToPDFConverter())

            {

                //Converts Word document into PDF document

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

                {

                    //Saves the PDF document

                    pdfDocument.Save(fileName);

                }

            };


I've attached the two documents so you can see that the table formatting is not being held. Is there a workaround for this? 


Attachment: PDF_Word_Comparison_38d77ce0.zip

20 Replies

AA Akash Arul Syncfusion Team January 3, 2024 06:11 AM UTC

Hi Natalie,

We have reproduced the problem Word document with equation is not preserved properly in Word to PDF conversion”.

Word

PDF


We will validate this issue and update you with more details by this weekend.

Regards,
Akash.



AA Akash Arul Syncfusion Team January 5, 2024 06:50 PM UTC

Natalie, we have confirmed that the reported issue “Equation is not aligned properly in Word to PDF conversion” is a defect and we have logged a defect report. We will include the fix for this defect in our weekly NuGet release which is estimated to be available on fourth week of January 2024.

The status of this bug can be tracked through the below link:
https://www.syncfusion.com/feedback/49762/equation-is-not-aligned-properly-in-word-to-pdf-conversion

Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”



SB Sneha Biju Syncfusion Team January 23, 2024 02:01 PM UTC

Natalie, as promised earlier, we have included the fix for the reported issue with “Equation is not aligned properly in Word to PDF conversion” in our latest weekly NuGet release (v24.1.47).

Please use the below link to download our latest weekly NuGet:
https://www.nuget.org/packages/Syncfusion.DocIO.Wpf/24.1.47

The status of this bug task can be tracked through the below link:
https://www.syncfusion.com/feedback/49762/equation-is-not-aligned-properly-in-word-to-pdf-conversion

Note: We will include this fix in our 2023 Volume 4 SP release, which will be available in the end of January 2024.



NW Natalie Westphal February 25, 2024 07:49 PM UTC

Hello,

Please see the attached photo showing a pdf in the syncfusion viewer and a word file made from the same document. While the left alignment of the equations in the "required minimum thickness" section seems to remain, the equations are centered in the pdf which is not correct. Also, the LaTex formatting using the "$" is not handled properly in the pdf. Please advise on how to resolve this issue. 


Attachment: pdf_and_word_f074307e.zip


AA Akash Arul Syncfusion Team February 26, 2024 11:23 AM UTC

Natalie, we tried to reproduce the reported problem, but it works properly on our end. For your reference, we have attached the sample application which we used at our end to reproduce the reported problem and it can be downloaded from the below attachment.

Can you please try our sample application at your end using your Word document?
If you are still facing the issue means, we suspect that the issue might be due to the input Word document. So, kindly share the input Word Document to reproduce the reported issue.

Note: If you have any confidential data in your input Word document, please replace with some dummy data and provide us the same. We just need your document to recreate the problem you face. So, once investigated the issue, we will delete the document permanently from our side and do not share with anyone.

If you are doing some other process in the code, please modify the sample attached and share it as issue reproducible sample.

Regarding: "$" is not handled properly in the pdf.
Kindly share more details about the issue.
1. Input document.
2. Issue screenshot.
3. Output document generated at your end.
4. Code snippet used on you end.

Thereby, we will proceed further to replicate the same problem at our end and will provide the more details at the earliest.


Attachment: WordToPDFEquation_71490c67.zip


NW Natalie Westphal February 26, 2024 07:51 PM UTC

Attached is the word document that shows the formatting is not maintained when the document is converted to PDF. I have tested the word document in the given WordToPDFEquation solution and have attached the pdf code output as well. 


Attachment: Word_To_PDF_5685d49d.zip


AN Anto Nihil Sahaya Raj Syncfusion Team February 27, 2024 03:42 PM UTC

Natalie, we have reproduced the reported issue with “Equation is not aligned properly in Word to PDF conversion” at our end. We will validate this issue and update you with more details on 29th February 2024.

Regarding: "$" is not handled properly in the pdf:
There is no “$” present in the given Word document. So, kindly share the input Word document and a screenshot of the issue. Which will help to reproduce the reported issue on our side.

Note: If you have any confidential data in your input Word document, please replace with some dummy data and provide us the same. We just need your document to recreate the problem you face. So, once investigated the issue, we will delete the document permanently from our side and do not share with anyone.



NW Natalie Westphal February 28, 2024 04:54 PM UTC

The dollar sign is used for formatting in the equation. You can see the $ in the pdf where it is in the word document LaTex equation. 


The code used when creating the word document is like this: 

\eqarray{T_m&= t + c @&=\left(0.7222\right) + \left( 0.175)\right)@&=0.8971 \mathrm{in}}




AA Akash Arul Syncfusion Team February 29, 2024 01:42 PM UTC

Natalie, please find the details below.

Regarding: Equation is not aligned properly in Word to PDF conversion.
We are still validating the issue. We will let you know the details by the start of the next week.

Regarding: "$" is not handled properly in the pdf.
We suspect that the reported issue is the “Unwanted "&" is preserved in the equation in Word to PDF conversion”. We have reproduced the mentioned issue on our end. Please find the screenshot below.

We will validate this issue and update you with more details on the start of the next week.

Please confirm us whether the above issue is the reported issue. If the reported issue is some other issue, kindly share the screenshot with us. So that we will proceed further to replicate the same issue on our end.



NW Natalie Westphal February 29, 2024 07:10 PM UTC

Yes, that is the issue that I am referring to. Thanks!



AN Anto Nihil Sahaya Raj Syncfusion Team March 4, 2024 06:10 PM UTC

Regarding: Equation is not aligned properly in Word to PDF conversion and "$" is not handled properly in the pdf:

On further checking, we have found that the array of equations used in the provided Word document includes the use of "&" within the equations. Microsoft Word aligns equations in an array based on the "&" symbol. Currently, we are checking the Microsoft Word behavior and feasibility of resolving this issue. Further details will be shared within two business days.



AN Anto Nihil Sahaya Raj Syncfusion Team March 6, 2024 02:53 PM UTC

Regarding: Equation is not aligned properly in Word to PDF conversion and "$" is not handled properly in the pdf:

On further checking, we've identified a distinct scenario involving the "&" symbol (align and spacer value) within equation arrays in Microsoft Word. Currently, DocIO doesn't support aligning equations based on & symbol in Word to PDF/Image conversion. We considered this request as a new requirement and feature request on our side. We planned to backtrack the complete behavior of this & symbol in the equation array to handle in Word to PDF/Image conversions. At now there is no immediate timeline to implement this feature. We plan to implement this in our upcoming release.

The status of this can be tracked through the below link:
https://www.syncfusion.com/feedback/51534/align-mathematical-text-of-equation-array-based-on-align-and-spacer-values-during



NW Natalie Westphal April 1, 2024 08:50 PM UTC

Can you please provide an estimate of when this feature will be included in a release? 



AN Anto Nihil Sahaya Raj Syncfusion Team April 2, 2024 09:35 AM UTC

Regarding: Equation is not aligned properly in Word to PDF conversion and "$" is not handled properly in the pdf:

As we mentioned earlier, 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 this can be tracked through the below link:

https://www.syncfusion.com/feedback/51534/align-mathematical-text-of-equation-array-based-on-align-and-spacer-values-during



NW Natalie Westphal April 3, 2024 12:42 PM UTC

Thanks for your reply.


The issue I have now is that when I use this equation: 

\eqarray{T_m&= t + c @&=\left(0.7222\right) + \left( 0.175)\right)@&=0.8971 \mathrm{in}}

it is shown as above in the pdf where the "&" sign is still present in the document. 


However, if I remove the "&" from the initial equation so that it is: 

\eqarray{T_m&= t + c @=\left(0.7222\right) + \left( 0.175)\right)@=0.8971 \mathrm{in}

then, the entire equation is shown on only one line. 


Is it possible to make add the equation breaks another way so that the equation is shown on multiple lines but does not include the "&"?



AN Anto Nihil Sahaya Raj Syncfusion Team April 4, 2024 02:10 PM UTC

Regarding - it is shown as above in the pdf where the "&" sign is still present in the document:
If "&" is used within the equations in the Word document, the Microsoft Word application preserves the space instead of the "&". Currently, DocIO does not handle this scenario. Therefore, the "&" is preserved in the converted PDF document. This problem will be resolved once the below feature is implemented. We will inform you when this feature is implemented.

The status of this can be tracked through the below link:
Align mathematical text of equation array based on align and spacer (&) values during Word to PDF conversion in WPF | Feedback Portal (syncfusion.com)

Regarding - Is it possible to make add the equation breaks another way so that the equation is shown on multiple lines but does not include the "&"?

Yes, it is possible to show the equation on multiple lines without including the "&" within the equation by adding the "@" at the end of the equation. Please refer to the equation below:

"\\eqarray{T_m= t + c @=\\left(0.7222\\right) + \\left( 0.175)\\right)@=0.8971 \\mathrm{in}@}"


Unfortunately, we are facing preservation issues while using the above equation in our DocIO library. We will validate and share further details within two business days.



AN Anto Nihil Sahaya Raj Syncfusion Team April 8, 2024 02:32 PM UTC

Regarding - Is it possible to make add the equation breaks another way so that the equation is shown on multiple lines but does not include the "&"?
We have confirmed that the reported issue with “Equation array is not preserved properly in multiple lines” is a defect and we have logged a defect report. We will include the fix for this defect in our weekly NuGet release, which is estimated to be available within two weeks.


The status of this bug can be tracked through the below link: Equation array is not preserved properly in multiple lines in WPF | Feedback Portal (syncfusion.com)


Disclaimer: Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.




SB Sneha Biju Syncfusion Team April 23, 2024 11:31 AM UTC

Regarding - Is it possible to make add the equation breaks another way so that the equation is shown on multiple lines but does not include the "&"?
As promised earlier, we have included the fix for the reported bug with “Equation array is not preserved properly in multiple lines” in our latest weekly NuGet release (v25.1.41).

Root cause of the issue:
The equation array without '&' after '@' was only partially handled. As a result, the equation array was not split properly.

Please use the below link to download our latest weekly NuGet:
Syncfusion.DocIO.Wpf

The status of this bug task can be tracked through the
below link.
Equation array is not preserved properly in multiple lines in WPF | Feedback Portal (syncfusion.com)

Note: We will include this fix in our 2024 Volume 1 SP release, which will be available in the beginning of May 2024.



NW Natalie Westphal June 25, 2024 06:24 PM UTC

Thank you for this solution.

However, this solution does not allow the equation to be aligned at the '=' on each line of the equation. Is there a solution for that? 



DA Dharanitharan Ayyasamy Syncfusion Team June 26, 2024 05:05 PM UTC

Natalia, as we have mentioned before, Microsoft Word aligns the equations in an array based on the "&" symbol. Currently, DocIO doesn't support aligning equations based on “&” symbol in Word to PDF/Image conversion. We have already logged a feature request “Align mathematical text of equation array based on align and spacer (&) values during Word to PDF conversion” in our database. At now there is no immediate timeline 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 this can be tracked through the below link:
Align mathematical text of equation array based on align and spacer (&) values during Word to PDF conversion in WPF | Feedback Portal (syncfusion.com)


Loader.
Up arrow icon