Fonts are not embedded, despite either 'EmbedSystemFonts' or 'SaveSubsetFonts' is set to 'true' due to 'EmbedTrueTypeFonts' option is set to 'false'

nodes1.save(“C:\Users\Administrator\Desktop\111\cut.docx”); 保存时报了警告Fonts are not embedded, despite either ‘EmbedSystemFonts’ or ‘SaveSubsetFonts’ is set to ‘true’ due to ‘EmbedTrueTypeFonts’ option is set to ‘false’.,请问怎么解决

@Test
public void cutPage() throws Exception {
    Document nodes = new Document("C:\\Users\\Administrator\\Desktop\\111\\1nDoc.docx");
    System.out.println(nodes.getPageCount());
    FontSubstitutionWarningCollector callback = new FontSubstitutionWarningCollector();
    nodes.setWarningCallback(callback);
    Document nodes1 = nodes.extractPages(0, 1);
    nodes1.save("C:\\Users\\Administrator\\Desktop\\111\\cut.docx");
}

aspose for java

@soaringai 您能否在此处附上您的输入文档以进行测试? 我们将检查该问题并为您提供更多信息。

这是我的测试文档,请注意里面的字体
1nDoc.docx (28.4 KB)

@soaringai 该行为是预期的。 如果“EmbedSystemFonts”或“SaveSubsetFonts”设置为“true”且“EmbedTrueTypeFonts”选项设置为“false”,则会显示上述警告。 您可以使用以下代码进行检查:

Document doc = new Document("C:\\Temp\\in.docx");
System.out.println(doc.getPageCount());
FontSubstitutionWarningCollector callback = new FontSubstitutionWarningCollector();
doc.setWarningCallback(callback);
System.out.println(doc.getFontInfos().getEmbedSystemFonts());
System.out.println(doc.getFontInfos().getSaveSubsetFonts());
System.out.println(doc.getFontInfos().getEmbedTrueTypeFonts());

这行代码的预期应该是提取出一页,我的理解是正确的吧,但是我执行完成以后,出现了两页,这是我的输出文件
cut.docx (16.8 KB)

所以我在怀疑是不是这个警告的问题,又或者我可以怎么解决这个警告

当我把EmbedTrueTypeFonts()设置为true时,紧接着报了Font subset embedded for font ‘方正楷体_GBK’ due to exceeding the maximum allowed size of 4194304 bytes.
Font ‘SimSun’ is not embedded due to exceeding the maximum allowed size of 4194304 bytes.
Font ‘方正公文仿宋’ has not been found. Using ‘微软雅黑’ font instead. Reason: alternative name from document.
Font ‘Microsoft YaHei’ is not embedded due to exceeding the maximum allowed size of 4194304 bytes.这些警告

@soaringai 您应使用以下代码获取单页表格。但是,由于该表格遍布整个页面,因此默认情况下添加的最后一段会创建第二页。您应该更改表格大小或页面大小,以删除第二页。

Document doc = new Document("1nDoc.docx");
doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2016);
Document nodes1 = doc.extractPages(0, 1);
nodes1.save("output.docx");

@soaringai 如果您无法使用某些字体,请尝试为您的目标设置替代字体。

你好,我已经尝试使用了该断代码提取页面,但是提取结果始终不是我的预期,我的提取结果还是出现了两页,我的预期结果应该是
f0424fd3399bab7e75ee15528bd418c.png (25.0 KB)

但是实际的结果是
image.png (49.7 KB)

,我想知道怎么解决我实际输出的页面多了一页的问题

对于字体原因,我的电脑已经安装了我文档中所使用的所有字体

@soaringai 有了这段代码,我就有了一页文档:

Document doc = new Document(getMyDir() + "1nDoc.docx");
Document nodes1 = doc.extractPages(0, 1);
double pageHeight = nodes1.getFirstSection().getPageSetup().getPageHeight();
nodes1.getFirstSection().getPageSetup().setPageHeight(pageHeight + 10);
nodes1.save(getArtifactsDir() + "output.docx");

output.docx (16.6 KB)

正如我上面提到的,有一个表格填满了整个页面,没有足够的空间用于默认段落。你所能做的就是增加页面高度。但此文档没有页眉和页脚,如果要创建,页面高度将减小,表格将移动到下一页,这是默认的MS Word行为。

多一个空白页,这个我可以理解的,主要问题还是我提取的一页文档,第二页不是空白的

正如这个提到的,我查看了该文档的页面高度,他和我原始文档是一样的

@soaringai 我们已经在我们的内部问题跟踪系统中打开了以下新工单,并将根据 免费支持政策 中提到的条款提供它们的修复:

Issue ID(s): WORDSNET-26919

如果您需要优先支持以及直接联系我们的付费支持管理团队,您可以获得 付费支持服务