简体   繁体   English

无法运行 Azure 表单识别器布局 _ 遇到意外的元素引用

[英]Not able to run Azure Form Recognizer Layout _ Unexpected element reference encountered

I try to use azure form recognizer layout to parse data and got issue.我尝试使用 azure 表单识别器布局来解析数据并遇到问题。 It can success run for some forms but some cases it will shown error "Unexpected element reference encountered: #/readResults/0/selectionMarks/0".对于某些表单它可以成功运行,但在某些情况下它会显示错误“遇到意外的元素引用:#/readResults/0/selectionMarks/0”。 Im not sure is that a bug or something wrong with my code.我不确定我的代码是错误还是错误。 Can someone advice?有人可以建议吗? Bellow is the code im using:波纹管是我使用的代码:

 router.post("/concinv", upload.single("form_file"), async (req, res, next) => {
  const endpoint = process.env.AZURE_ENDPOINT;
  const apiKey = process.env.AZURE_API_KEY;
  let file = req.file;
  const file_name = file.filename;

  if (!file_name) {
    return res.status(400).json("No files were uploaded.");
  }
  try {
    const uploadPath = path.join(__dirname, "../../../" + req.file.path);

    const readStream = fs.createReadStream(uploadPath);
    const client = new FormRecognizerClient(
      endpoint,
      new AzureKeyCredential(apiKey)
    );   

    const pollerLayout = await client.beginRecognizeContent(readStream, {
      contentType: "application/pdf",
      onProgress: (state) => {
        console.log(`status of DO: ${state.status}`);
      },
    });
    const layouts = await pollerLayout.pollUntilDone();    

    return ServiceResponse.Ok(res, {
      Items: layouts,
    });
  } catch (error) {
    return ServiceResponse.BadRequest(res, { err: error.message });
  }
});

From the error message it seems some of your documents don't have selection mark hence the reference failed.从错误消息来看,您的某些文档似乎没有选择标记,因此引用失败。 Can you please double check?你能仔细检查一下吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM