我使用GoogleDocumentA.I来识别不同类型的表格,如美国政府表格、W2表格、W9表格、发票表格、收据表格。
当我试图处理表单时,我从GoogleDocumentA.I中得到了这个错误:
Unable to find a document of type 'w2_', found 1 other document types
或
Unable to find a document of type 'w9_', found 1 other document types
当我试图处理一个W2表单PDF文件时,得到了这个错误,在其他类型的PDF上也得到了这个错误。
这是我的密码:
const download_pdf = (bucketName, fileName) => {
return new Promise(async (resolve, reject) => {
//console.log("finalGS URL", `gs://${bucketName}/${fileName}`, "bucket:", bucketName, "fileName: ", fileName)
const storage = new Storage()
const bucket = storage.bucket(bucketName)
const file = bucket.file(fileName)
try {
//download the file in memory
const res = await file.download()
let pdfBuffer = res?.flat()?.[0] || res?.[0]
if (pdfBuffer) {
resolve(pdfBuffer)
} else {
throw new Error(`Something went wrong when downloading file!`)
}
} catch (e) {
console.error("error When Downloading Fiile ", e)
reject(e)
}
})
}
const encodedImage = await download_pdf(bucket_name, file_name)
const request = {
name,
document: {
content: encodedImage,
mimeType: 'application/pdf',
}
};
// Recognizes text entities in the PDF document
const [result] = await client.processDocument(request);
document = result?.document;起初,我认为我的文件出了问题,但是当我将它直接上传到google云平台时,它在那里工作,但当我试图从我的代码中处理它时,错误不是永久的--它只是随机发生的,有时它能工作,我得到了公认的数据,但大多数时候我都会收到这个错误。
我已经检查了我的代码两次,这是根据谷歌的文件,我没有发现任何错误。
提前谢谢你!
PDF文件:W9.pdf
更新:看起来问题就在谷歌这一边,到目前为止,我在将文件上传到Google平台文件AI时也会遇到同样的错误,还在等待谷歌团队的回应。
https://stackoverflow.com/questions/68657131
复制相似问题