Invalid PDF structure using vue3-pdf

This exception is returning on almost on every file, only one works for me From console, it also returns:

Warning: Indexing all PDF objects.

Object { message: "Invalid PDF structure.", name: "InvalidPDFException", stack: "BaseExceptionClosure@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/build/pdf.js:2222:29n@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/build/pdf.js:2225:2n__w_pdfjs_require__@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/build/pdf.js:47:30n@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/build/pdf.js:384:32n__w_pdfjs_require__@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/build/pdf.js:47:30n@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/build/pdf.js:317:41n__w_pdfjs_require__@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/build/pdf.js:47:30n@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/build/pdf.js:111:18n@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/build/pdf.js:114:10nwebpackUniversalModuleDefinition@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/build/pdf.js:25:20n@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/build/pdf.js:27:3n@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/build/pdf.js:26661:30n./node_modules/pdfjs-dist-sig/es5/build/pdf.js@http://localhost:8080/view/js/chunk-vendors.js:2504:1n__webpack_require__@http://localhost:8080/view/js/app.js:849:30nfn@http://localhost:8080/view/js/app.js:151:20n@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/web/pdf_viewer.js:408:14n__w_pdfjs_require__@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/web/pdf_viewer.js:47:30n@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/web/pdf_viewer.js:258:36n__w_pdfjs_require__@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/web/pdf_viewer.js:47:30n@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/web/pdf_viewer.js:221:52n__w_pdfjs_require__@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/web/pdf_viewer.js:47:30n@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/web/pdf_viewer.js:111:18n@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/web/pdf_viewer.js:114:10nwebpackUniversalModuleDefinition@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/web/pdf_viewer.js:25:20n@webpack-internal:///./node_modules/pdfjs-dist-sig/es5/web/pdf_viewer.js:27:3n./node_modules/pdfjs-dist-sig/es5/web/pdf_viewer.js@http://localhost:8080/view/js/chunk-vendors.js:2515:1n__webpack_require__@http://localhost:8080/view/js/app.js:849:30nfn@http://localhost:8080/view/js/app.js:151:20n@webpack-internal:///./node_modules/vue3-pdf/src/pdfjsWrapper.js:2:110n./node_modules/vue3-pdf/src/pdfjsWrapper.js@http://localhost:8080/view/js/chunk-vendors.js:2725:1n__webpack_require__@http://localhost:8080/view/js/app.js:849:30nfn@http://localhost:8080/view/js/app.js:151:20n@webpack-internal:///./node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/index.js?!./node_modules/vue3-pdf/src/vuePdfNoSss.vue?vue&type=script&lang=js:6:41n./node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/index.js?!./node_modules/vue3-pdf/src/vuePdfNoSss.vue?vue&type=script&lang=js@http://localhost:8080/view/js/chunk-vendors.js:616:1n__webpack_require__@http://localhost:8080/view/js/app.js:849:30nfn@http://localhost:8080/view/js/app.js:151:20n@webpack-internal:///./node_modules/vue3-pdf/src/vuePdfNoSss.vue?vue&type=script&lang=js:2:276n./node_modules/vue3-pdf/src/vuePdfNoSss.vue?vue&type=script&lang=js@http://localhost:8080/view/js/chunk-vendors.js:2749:1n__webpack_require__@http://localhost:8080/view/js/app.js:849:30nfn@http://localhost:8080/view/js/app.js:151:20n@webpack-internal:///./node_modules/vue3-pdf/src/vuePdfNoSss.vue:2:117n./node_modules/vue3-pdf/src/vuePdfNoSss.vue@http://localhost:8080/view/js/chunk-vendors.js:2737:1n__webpack_require__@http://localhost:8080/view/js/app.js:849:30nfn@http://localhost:8080/view/js/app.js:151:20n@webpack-internal:///./node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader/index.js?!./node_modules/cache-loader/dist/cjs.js?!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/index.js?!./src/views/Dashboard.vue?vue&type=script&lang=ts:25:86n./node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader/index.js?!./node_modules/cache-loader/dist/cjs.js?!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/index.js?!./src/views/Dashboard.vue?vue&type=script&lang=ts@http://localhost:8080/view/js/app.js:986:1n__webpack_require__@http://localhost:8080/view/js/app.js:849:30nfn@http://localhost:8080/view/js/app.js:151:20n@webpack-internal:///./src/views/Dashboard.vue?vue&type=script&lang=ts:2:406n./src/views/Dashboard.vue?vue&type=script&lang=ts@http://localhost:8080/view/js/app.js:1466:1n__webpack_require__@http://localhost:8080/view/js/app.js:849:30nfn@http://localhost:8080/view/js/app.js:151:20n@webpack-internal:///./src/views/Dashboard.vue:3:115n./src/views/Dashboard.vue@http://localhost:8080/view/js/app.js:1454:1n__webpack_require__@http://localhost:8080/view/js/app.js:849:30nfn@http://localhost:8080/view/js/app.js:151:20n@webpack-internal:///./src/router/index.ts:3:97n./src/router/index.ts@http://localhost:8080/view/js/app.js:1430:1n__webpack_require__@http://localhost:8080/view/js/app.js:849:30nfn@http://localhost:8080/view/js/app.js:151:20n@webpack-internal:///./src/main.ts:12:84n./src/main.ts@http://localhost:8080/view/js/app.js:1406:1n__webpack_require__@http://localhost:8080/view/js/app.js:849:30nfn@http://localhost:8080/view/js/app.js:151:20n1@http://localhost:8080/view/js/app.js:1551:18n__webpack_require__@http://localhost:8080/view/js/app.js:849:30ncheckDeferredModules@http://localhost:8080/view/js/app.js:46:23n@http://localhost:8080/view/js/app.js:925:18n@http://localhost:8080/view/js/app.js:928:10n" }

My function to get file:

  const getFile = async () => {
      console.log(currentDocNum);
      console.log(kpiShow.value);
      const responseFile = await rest.getFile(docsList[currentDocNum]);
      const downloadUrl = window.URL.createObjectURL(new Blob([responseFile.result]));
      const blob = new Blob([responseFile.result], { type: "application/pdf" });

      const temp = URL.createObjectURL(blob);
      const pdfSource = pdf.createLoadingTask(temp);
      console.log(temp);
      objectUrl.value = downloadUrl;
      
      pdfSource.promise.then((pdfTemp: any) => {
        numberPages.value = pdfTemp.numPages;
      });
      if (currentDocNum < docsNumber) currentDocNum++;
    };

const getFile = async (file: string): Promise<RestResponse<any>> => {
  return getRequest("/view/files?fileName="+file )
}

const getRequest = (requestString: string) =>
  viewAPI
    .get(requestString)
    .then((result) => ({ ok: true, result: result.data }))
    .catch((error) => Promise.resolve({ ok: false, error: error }))

and div

  <div class="row" v-if="!kpiShow" >
    <pdf :src="objectUrl" :page="1" ></pdf>
</div>

Answer

It have to be

const getRequest = (requestString: string) =>
  viewAPI
    .get(requestString,{responseType:"blob"})
    .then((result) => ({ ok: true, result: result.data }))
    .catch((error) => Promise.resolve({ ok: false, error: error }))