Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Fri Mar 04, 2022 10:05 am

Hi,

I am using the free version, and have the following question:
When I export a document, that contains a math formula, to pdf, the formula is OK on the first export, but the font is getting bigger every time I export again.
I boiled it down to this code:

public void WORD_PDF_export()
{
Document src = new Document();
src.LoadFromFile(testdirWord + "\\math.docx"); // document contains just one math-formula

for (int i = 0; i < 5; i++)
{
Document resultDoc = new Document();
Section section = resultDoc.AddSection();

DocumentObject obj = findMath(src);
section.Body.ChildObjects.Add(obj.Clone());

string outputfile = testdirWord + @"\out\zahlen_" + i.ToString() + ".pdf";
resultDoc.SaveToFile(outputfile, FileFormat.PDF);
resultDoc.Close();
}
src.Close();
}

where findMath is:

DocumentObject findMath(Document src)
{
foreach (DocumentObject obj in src.Sections[0].Body.ChildObjects)
{
if (obj is Paragraph)
foreach (DocumentObject p in obj.ChildObjects)
if (p is OfficeMath)
return obj;
}
return null;
}

the test-document for the code above contains just one math formula, it does not matter which, one character will do also.
The resulting font in the resulting pdf is the same size as in the docx-file for i=0.
But it gets bigger with each increment of i.
if I put the line containing src.LoadFromFile inside the loop, the resulting pdf is OK.

Another Question: Integral signs don't get exported at all, it seems.
Is that a limitation of the free version?

thanks in advance
Bruno

bruno.skorepa
 
Posts: 4
Joined: Wed Jul 14, 2021 6:00 pm

Mon Mar 07, 2022 2:12 am

Hello Bruno,

Thanks for your inquiry!

I tested the code you provided with the latest Free Spire.Doc for .NET Version:10.2, but did not reproduce your issue, the font of the generated PDF is in the same size. Here I attached the input file I am using for your reference.

compare.png

If you are not using the latest free version, I just recommend that you can try it first. If the issue still exists, please provide us with your input file for further investigate. Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Mar 07, 2022 2:55 pm

Hello Marcia,

Yes, you are right, this is not an issue in the latest version anymore.
I am very sorry for the inconvenience, I should have updated, before I wrote this post (and would have saved myself some time too).

the Integral sign is also exported in the latest version.
although: lower and upper bounds are not below and above (as expected) but beside the integral sign.
and: vector arrows are not exported to pdf

maybe you can relay these issues to the development team.

Thanks a lot
Bruno

bruno.skorepa
 
Posts: 4
Joined: Wed Jul 14, 2021 6:00 pm

Tue Mar 08, 2022 1:36 am

Hello Bruno,

You are welcome!

For the two issues you mentioned, do you mean the formula like this? If so, sorry that I did not reproduce the issue. If there is any misunderstood here, please provide us with your input file for further investigate. Thanks in advance.
toPDF.png


Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Wed Mar 09, 2022 6:18 am

Hello Marcia,

thanks again for your quick answer.
Actually you are right, the bounds are not really above/below the integral sign in WORD either.

So, to my last question: about the vector arrows.
the arrows are missing in the exported file.
see attached picture.

thanks in advance
Bruno

bruno.skorepa
 
Posts: 4
Joined: Wed Jul 14, 2021 6:00 pm

Wed Mar 09, 2022 7:09 am

Hello Bruno,

Thanks for sharing more information!

I did notice the issue you mentioned, after further investigate, I found that our "NewEngine" method for converting Word to PDF has solved this issue. I just recommend that you can try this method by the following code.

Code: Select all
            Document document = new Document();
            document.LoadFromFile("E:\\testdoc\\formula.docx");
            document.UseNewEngine = true;//uese new engine method
            document.SaveToFile("res.pdf");


The "NewEngine" method has a better behavior in converting tables to PDF, and also supported comments and track changes detail show in PDF. In addition, we will gradually migrate the internal conversion code to this method, and the original method will be gradually deprecated. If you have any questions about the new method, just feel free to contact us.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Wed Mar 09, 2022 11:06 am

Thank you very much!
and thanks for your patience,
Bruno

bruno.skorepa
 
Posts: 4
Joined: Wed Jul 14, 2021 6:00 pm

Thu Mar 10, 2022 6:26 am

Hello Bruno,

You are welcome!

If you encounter any issues related to our product in the future, just feel free to contact us.

Have a nice day!

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.Doc