Aspose word for Java - acceptAllRevisions()方法没有按预期工作

时间:2018-03-05 21:10:29

标签: java aspose aspose.words

我正在尝试比较两个单词文档,它不适用于某些word文档,并且对其他文档工作正常。

以下是我们正在使用的完整代码。

com.aspose.words.Document wordDoc1 =  new com.aspose.words.Document(oldDocStream);
com.aspose.words.Document wordDoc2 =  new com.aspose.words.Document(newDocStream);
wordDoc1.acceptAllRevisions();
wordDoc2.acceptAllRevisions();

if(!wordDoc1.hasRevisions() && !wordDoc2.hasRevisions()){ 
    wordDoc1.compare(wordDoc2, "Aspose Word API", new Date());
}else{
    logger.info("Aspose Limitation: Unable to compare docs, it contains unaccepted revisions");
}

下面的代码块成功执行,没有任何异常,所以我假设接受修订成功

wordDoc1.acceptAllRevisions();
wordDoc2.acceptAllRevisions();

但是,wordDoc1.hasRevisions()会返回 true ,这意味着接受修订失败

结果以下消息在控制台中打印。

"Aspose Limitation: Unable to compare docs, it contains unaccepted revisions"

有人可以帮忙解决这个问题吗?我也在官方论坛上提出了同样的建议。

1 个答案:

答案 0 :(得分:0)

试试这个:

 com.aspose.words.Document wordDoc1 =  new com.aspose.words.Document(oldDocStream);
    com.aspose.words.Document wordDoc2 =  new com.aspose.words.Document(newDocStream);
    wordDoc1.acceptAllRevisions();
    wordDoc2.acceptAllRevisions();
    file.save(newDocStream);
    file.save(oldDocStream);

    com.aspose.words.Document wordDoc1Accepted =  new com.aspose.words.Document(oldDocStream);
    com.aspose.words.Document wordDoc2Accepted =  new com.aspose.words.Document(newDocStream);

    if(!wordDoc1Accepted.hasRevisions() && !wordDoc2Accepted.hasRevisions())
    { 
    wordDoc1Accepted.compare(wordDoc2Accepted, "Aspose Word API", new Date());
     }
    else{
logger.info("Aspose Limitation: Unable to compare docs, it contains unaccepted revisions");
   }