使用 Aspose.Words 将word文档转换为HTML时,Windows和linux渲染出来的图片不一样

@qvyue,

我已将这些详细信息记录在我们的问题跟踪系统中,并将在任何进一步的更新中通知您。

@qvyue,

看来您的Linux机器使用FreeSerif字体家族而不是Cambria Math for Math ML元素。

-- from output.html
@font-face {
    font-family: 'Cambria Math';
    src: url('output.freeserif.ttf')
}

您可以在自己的末端执行以下两个步骤吗?

  • 在问题Linux上打开以下归档文件(它是从我的本地计算机上使用Corrent Cambria Math字体家族创建的)(windows_output.zip (218.8 KB)),并确保方程不模糊。
  • 使用我之前的注释中的代码在Linux机器上创建HTML文档,在该机器上您可以获得正确的输出(以比较来自正确和有问题的Linux的字体)。

Document doc = new Document(“in.docx”);
com.aspose.words.HtmlSaveOptions so = new com.aspose.words.HtmlSaveOptions();
so.setExportFontResources(true);
so.setOfficeMathOutputMode(HtmlOfficeMathOutputMode.MATH_ML);
doc.save(“output.html”, so);

是用这份代码来生成output.html吗?

你们是用英文然后翻译成中文的吗?
看着有点别扭,可能会导致理解差异。

比如说:“在问题Linux上打开以下归档文件”,这句话理解起来,就是Linux里面用cat 命令打开,只能看见代码。

如果你们是英文,请直接回复英文,我可以理解英文。谢谢。

1618195678(1).png (148.4 KB)
在Windows打开是如图所示,部分公式乱码。已安装贵方提供的字体。

@qvyue,

Yes, I used Google Translate to translate to Chinese (Simplified).

I have logged these details in our issue tracking system and will keep you informed here on further updates.

Ok, thank you!

@qvyue,

Regarding WORDSNET-21764, please use the following code:

Document doc = new Document("in.docx");
com.aspose.words.HtmlSaveOptions so = new com.aspose.words.HtmlSaveOptions();
so.setExportFontResources(true);
so.setOfficeMathOutputMode(HtmlOfficeMathOutputMode.MATH_ML);
doc.save("output.html", so);

This code must be run on the Linux machine where you got valid result. At this case we will get a font from this Linux for MathML elements.

Also, in a previous message we asked to open HTML document from windows_output.7z (191.4 KB) on the problematic Linux machine and confirm that equations are blurred or not (please note that the HTML should be opened in Firefox only).

@qvyue,

We are waiting for your further input on this topic (WORDSNET-21764). Please see my previous post and share the requested information. Thanks for your cooperation.

The issues you have found earlier (filed as WORDSNET-21764) have been fixed in this Aspose.Words for Java 22.7 update also available on Maven.