Word文档转换pdf文档,标题的字变少了

word文档,通过aspose转换,其中的标题少了最后一个字
使用的jar版本是words-24.3-17
附件链接:标题少字.7z - Google Drive
里面包含原始word文档,生成pdf文档

@serendipity.zhq 您的文档中使用的以下字体在我这边不可用:

  • 方正小标宋简体

您可以将其附在此处进行测试吗?

出现该问题很可能是因为文档中使用的字体在处理文档的环境中不可用。 如果 Aspose.Words 找不到文档中使用的字体,则字体被替换。 由于字体规格的差异,这可能会导致布局差异,并导致页面检测不正确。 您可以实现 IWarningCallback 以在执行字体替换时收到通知。
以下文章可能对您有用:
https://docs.aspose.com/words/java/specify-truetype-fonts-location/
https://docs.aspose.com/words/java/install-truetype-fonts-on-linux/

这是我的字体文件:https://drive.google.com/file/d/1Gkytc1sWMrs1k8VenWiYiBpPkHsyU7uH/view?usp=sharing

FontSettings fontSettings = new FontSettings();
fontSettings.setFontsSources(new FontSourceBase[]{
        new SystemFontSource(),
        new FolderFontSource(getFontPath(), true)
});
LoadOptions loadOptions = new LoadOptions();
loadOptions.setFontSettings(fontSettings);

这是我加载字体的代码

@serendipity.zhq
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-26778

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@serendipity.zhq We have completed analyzing the issue and are going to close it as Not a Bug. Aspose.Words behavior matches MS Word.

It appears the behavior changes on saving to .docx because on saving to docx both MS Word and Aspose.Words change font formatting for the problematic text.
In the source .doc file, MS Word UI reports that the last glyph (‘心’) in the problematic paragraph has character spacing expanded by 6.95pt. The glyph does not fit to line 1, it is wrapped to the next line and goes below the shape bottom, becoming invisible.
On conversion to docx, both via MS Word or Aspose.Words, MS Word UI reports that the same glyph has character spacing condensed by 0.25pt. Character spacing for other glyphs on the problematic paragraph changes, too, but apparently it results in the text fitting into the container text box after conversion to .docx.
As line wrapping in Aspose.Words layout happens to match MS Word layout both for .doc and for .docx we do not see why it should be changed.

We believe we can say that line wrapping in Aspose.Words layout matches MS Word both before and after conversion to .docx. We do not see why we should change it to match WPS Office layout.

The issues you have found earlier (filed as WORDSNET-26778) have been fixed in this Aspose.Words for Java 24.7 update.

After testing, the problem has not been solved.
version: aspose-words-24.7-jdk17.jar
The following is my code:

        FontSettings fontSettings = new FontSettings();
        fontSettings.setFontsSources(new FontSourceBase[]{
                new SystemFontSource(),
                new FolderFontSource(getFontPath(), true)
        });

        LoadOptions loadOptions = new LoadOptions();
        loadOptions.setFontSettings(fontSettings);

        Document wpd = null;
        try {
            wpd = new Document(srcFile, loadOptions);
            wpd.getLayoutOptions().setCommentDisplayMode(CommentDisplayMode.SHOW_IN_ANNOTATIONS);

            PdfSaveOptions opt = new PdfSaveOptions();
            opt.getMetafileRenderingOptions().setRenderingMode(MetafileRenderingMode.BITMAP);
            wpd.save(dstFile, opt);
        } catch (Exception e) {
            e.printStackTrace();
    }

@serendipity.zhq As it has been mentioned above, the issue has been closed as not a bug.