首页 > 解决方案 > Google Vision Api 支持 PDF 和 TIFF 文本检测,但它也可以与包含图像的 PDf 一起使用吗?

问题描述

我正在尝试使用包含图像的 pdf 以及 google vision API,但它会引发以下错误:

下午 4:35:12.207 info dialogflowFirebaseFulfillment Dialogflow 请求标头:{"host":"us-central1-detecttext-5a0c3.cloudfunctions.net","user-agent":"Apache-HttpClient/4.5.4 (Java/1.8. 0_181)","传输编码":"chunked","accept":"text/plain, /x-macromania, x-macsymbol, x-macthai, x-macturkish, x-macukraine, x-ms932_0213, x-ms950-hkscs, x-ms950-hkscs-xp, x-mswin-936, x-pck, x- sjis_0213, x-utf-16le-bom, x-utf-32be-bom, x-utf-32le-bom, x-windows-50220, x-windows-50221, x-windows-874, x-windows-949, x-windows-950, x-windows-iso2022jp","内容类型":"应用程序/json; charset=UTF-8","function-execution-id":"dvrpphf9f855","x-appengine-api-ticket":"4b7e84f29e9ce22b","x-appengine-city":"?","x-appengine- citylatlong":"0.000000,0.000000","x-appengine-country":"US","x-appengine-https":"on","x-appengine-region":"?","x-appengine-用户 IP":"35.193.50.245","x-cloud-trace-context":"
dialogflowFirebaseFulfillment ERROR: { Error: Error in extracting images from PDF file gs://detecttext-5a0c3.appspot.com/NFM-11099M1.pdf at GoogleError.Error (native) at new GoogleError (/user_code/node_modules/@google-cloud /vision/node_modules/google-gax/build/src/GoogleError.js:46:42) 在 Operation._unpackResponse (/user_code/node_modules/@google-cloud/vision/node_modules/google-gax/build/src/longrunning. js:228:29) 在 /user_code/node_modules/@google-cloud/vision/node_modules/google-gax/build/src/longrunning.js:214:18 代码:13}

标签: apipdfgoogle-cloud-platformvision

解决方案


我有同样的问题 - 在我的情况下,gzip: true上传设置导致问题:

this.client
    .bucket(bucketName)
    .upload(fullPath, {
        gzip: false,  // setting gzip: true causes the pdf annotator to fail
        metadata: {
            cacheControl: 'no-cache',
        },
    })
    .then(...)

推荐阅读