跳转到主要内容
如果您在自己的系统中使用 ABBYY Vantage,那么很可能也希望利用人工审核功能。本节将指导您如何集成人工审核。 通过 Vantage API 将文档发送进行处理后,请按照如何使用 Vantage API 处理文档中的说明监控事务状态。如果某个文档需要由人工审核人员进行审核,事务状态响应中将包含一个 manualReviewLink 键,其中带有安全链接。审核人员可以通过该链接仅访问该特定事务的数据。 在您的服务网页中嵌入一个以该链接为地址的 iframe:
<iframe src="manual-review-link"></iframe>
请注意,该链接将在创建后 168 小时过期。如果需要继续审核,请按照之前的方式向 transactions 资源发送 GET 请求以获取新的链接。

Iframe 外观

您可以通过移除 Vantage 徽标或隐藏人工审核客户端界面中的某些窗格来简化服务界面的外观。 要移除 Vantage 徽标,请在链接中添加名为 displayMode、值为 iframe 的查询参数,如下所示:
<iframe src="manual-review-link&displayMode=iframe"></iframe>
使用以下选项来配置人工审核客户端界面:
KeyDescription
features
batchEditor设为 false 以隐藏页面缩略图窗格。
batchEditor.toolbar设为 false 以显示页面缩略图窗格但隐藏工具栏窗格。
batchEditor.autoCollapse设为 true 以显示页面缩略图窗格,但在打开人工审核客户端界面时将其折叠。
docEditor设为 false 以隐藏页面图像窗格。
docEditor.toolbar设为 false 以显示页面图像窗格但隐藏其工具栏。
formEditor设为 false 以隐藏提取字段列表窗格。
rulesReport设为 false 以隐藏规则错误列表窗格。
sendToStageAvailable设为 true 以显示 Send to Stage… 按钮。
这些选项被组织在一个单独的 JSON 对象中。以下示例代码将显示一个 iframe,其中规则错误窗格被隐藏,页面缩略图窗格处于折叠状态:
"features": {
   "batchEditor": {
      "autocollapse": true,
   },
   "rulesReport": false,
}
在指向人工审核页面的链接中添加名为 settings 的查询参数,并将此 JSON 对象的内容作为该参数的值:
<iframe src="manual-review-link&settings=%7B%22features%22%3A%7B%22batchEditor%22%3A%7B%22autoCollapse%22%3Atrue%7D%2C%22rulesReport%22%3Afalse%7D%7D"></iframe>

iframe 事件

iframe 对象会向父窗口发送消息,以通知您审核员在人工审核客户端界面中的操作,从而使您能够在适当的时间进入下一步。 事件通过 targetOrigin=parent 参数发送。以下是需要监听的事件列表:
  • ManualReviewWasPaused。当审核员点击 Reject 按钮时发送。
  • ManualReviewWasCompleted。当审核员点击 Complete 按钮时发送。
  • ManualReviewWithdrawn。当审核员在一段时间内没有任何操作,且人工审核客户端任务被撤回到公共任务队列时发送。
下面的示例代码展示了如何显示用于人工审核的 iframe,并在上述任一事件被触发后将其隐藏。 用于监听 iframe 事件的示例代码:
<html style="min-height: 100%; height: 100%;">
<head>
  <script>
    var manualReviewLink; // 来自事务状态响应的链接
    window.addEventListener("DOMContentLoaded", init, false);
    function init() {
      var iframe = document.createElement("iframe");
      iframe.src = getUrl();
      iframe.style.width = "100%";
      iframe.style.height = "95%";
      try {
        document.getElementById("main").removeChild(document.querySelector("iframe"));
      } catch (e) { }
      document.getElementById("main").appendChild(iframe);
      window.addEventListener("message", receiveMessage, false);
    }
    function getUrl() {
      return manualReviewLink + "&displayMode=iframe";
    }
    function receiveMessage(event) {
      console.log(event.data);
      if (event.data.target === "parent") {
        if (event.data.eventName === "ManualReviewWithdrawn" || 
            event.data.eventName === "ManualReviewWasPaused" || 
            event.data.eventName === "ManualReviewWasCompleted" ) {
          document.getElementById("iframe").style.display = "none";
        }
      }
    }
  </script>
</head>
<body
  style="background-color: #999999; min-height: 100%; height: 100%; position: relative; margin: 0; padding: 0; background: linear-gradient(to bottom right, #4380bc, #5ba484);">
  <div id="main"
    style="height: 100%; position: relative; padding:20px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;">
  </div>
</body>
</html>