Word 转换成 pdf 表格宽度不对

我用 aspose-word-java 生成了一份 word,导出后打开是正常,但是转换成 pdf 就有问题
docOutFile.docx (30.2 KB)
docOutFile.pdf (49.6 KB)

Document doc = new MyDocument("docOutFile.docx");
doc.save("docOutFile.pdf");

@myboy 移除 Aspose.Words 水印可解决此问题。 请尝试在有许可证的情况下使用。 您可以使用临时许可证进行测试: Temporary License - Purchase - aspose.com

还是不行,已经去除水印了
docOutFile.docx (21.4 KB)

docOutFile.pdf (37.7 KB)

中间的表格使用代码插入的

@myboy 能否提供创建表格的完整代码? 另外,请介绍一下您使用的是什么版本的 Aspose.Words?

在提供的文档中,第二个表格的 table.setAllowAutoFit 设置为 true,而在您的代码中,您将其设置为 false。 如果我使用您的文档和 25.2 版本运行以下代码,PDF 文件将正常显示:

Document doc = new Document("docOutFile.docx");

Table table = (Table) doc.getChild(NodeType.TABLE, 1, true);
table.setAllowAutoFit(false);

doc.save("output.pdf");

output.pdf (38.0 KB)

我知道怎么回事了,我代码里不小心写成了 table.setAllowAutoFit(true); 多谢指导

1 Like