这份docx文件转换成pdf耗时340多秒并且cpu占用高,是什么原因啊?
Supply Agreement-HPL & WALVAX-PCV13-Final.docx (338.1 KB)
@Cover123 感谢您报告此问题。 我们已经在我们的内部问题跟踪系统中打开了以下新工单,并将根据 免费支持政策 中提到的条款提供它们的修复:
Issue ID(s): WORDSNET-29430
如果您需要优先支持以及直接联系我们的付费支持管理团队,您可以获得 付费支持服务 。
该文档包含大量空的嵌套字段。作为一种变通方法,您可以使用以下代码来转换该文档:
private static void removeEmptyFields(Document doc) {
boolean again = true;
while (again) {
again = false;
for (Node startNode : doc.getChildNodes(NodeType.FIELD_START, true).toArray()) {
FieldStart start = (FieldStart) startNode;
ArrayList<Node> chain = new ArrayList<>();
boolean empty = true, innermost = true, closed = false;
for (Node n = start; n != null; n = n.nextPreOrder(doc)) {
if (n != start && n.getNodeType() == NodeType.FIELD_START) { innermost = false; break; }
chain.add(n);
if (n.getNodeType() == NodeType.RUN && !n.getText().trim().isEmpty()) { empty = false; break; }
if (n.getNodeType() == NodeType.FIELD_END) { closed = true; break; }
}
if (innermost && empty && closed) {
for (Node n : chain)
n.remove();
again = true;
}
}
}
}
public void removeEmptyNestedFields() throws Exception {
Document doc = new Document("input.docx");
removeEmptyFields(doc);
doc.save("output.pdf");
}