为有中文需求的客户提供多渠道中文技术支持.

Wed Nov 20, 2024 9:28 am

Spire.Doc For .NET 12.4.7如何将OfficeMath转换成Latex

leehao001
 
Posts: 15
Joined: Thu Nov 14, 2024 6:41 am

Thu Nov 21, 2024 6:03 am

您好,

感谢留言。
您是想将Word文档中的公式导出为latex吗?很抱歉,我们产品目前并不支持这一功能,我们产品目前仅支持以下格式的公式导入及导出。我已经将您的需求记录到了我们新功能需求中,编号为SPIREDOC-10958。开发会调查能否实现您的需求,一旦实现,我们会及时向您同步。再次感谢您的咨询。


Code: Select all
   
    // 导入Latex格式的公式
    math.FromLatexMathCode("LatexMathcode");
   // 导入MathML格式的公式
    math.FromMathMLCode("MathMLCode");

    // 将公式导出为MathML代码
    string mathMLCode = math.ToMathMLCode();
   // 将公式导出为OfficeMathML代码
    string officeMathMLCode= math.ToOfficeMathMLCode();


Sincerely,
Doris
E-iceblue support team
User avatar

Doris.Liu
 
Posts: 460
Joined: Mon Nov 07, 2022 8:10 am

Sun Dec 08, 2024 5:50 am

您好,谢谢您解答!

现在有一个新的问题想要请教,在使用Spire.doc在Word中插入一个新的段落的同时,如何将整个段落设置高亮和或者背景色颜色,这个段落包含文字、图片公式

leehao001
 
Posts: 15
Joined: Thu Nov 14, 2024 6:41 am

Mon Dec 09, 2024 2:44 am

您好,

感谢您的咨询。

请使用 paragraph.Format.BackColor = Color.Yellow; 设置段落背景色。

您需要更多帮助或遇到问题,请再联系我们。

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3050
Joined: Wed Jun 27, 2012 8:50 am

Mon Jul 21, 2025 1:45 am

你好,

我们最新版本 Spire.Doc Pack(hot fix)版本: 13.7.9支持了Math公式转到Latex。请知悉并参考下面代码进行测试。
Code: Select all
            Document document = new Document();
            doc.LoadFromFile(inputFile);

            StringBuilder stringBuilder = new StringBuilder();
            // Iterate through sections in the document
            foreach (Section section in doc.Sections)
            {
                // Iterate through paragraphs in each section
                foreach (Paragraph par in section.Body.Paragraphs)
                {
                    // Iterate through child objects in each paragraph
                    foreach (DocumentObject obj in par.ChildObjects)
                    {
                        // Check if the object is an OfficeMath equation
                        OfficeMath omath = obj as OfficeMath;
                        if (omath == null) continue;
                        // Convert OfficeMath equation to LaTex code
                        string mathml = omath.ToLaTexMathCode();
                        // Append MathML code to the StringBuilder
                        stringBuilder.Append("LaTeX code" + mathml);
                        stringBuilder.Append("\r\n");
                    }
                }
            }
            // Write the LaTex code to a text file
            File.WriteAllText(outputFile, stringBuilder.ToString())

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1537
Joined: Wed Apr 25, 2018 3:20 am

Return to 中文技术支持

cron