小编Phi*_*ely的帖子

警告:无效流:dropzone 上传后来自 springboot API 的 PDF 响应上出现“FormatError: Bad FCHECK in flate flow: 120, 239”

我正在使用 dropzone 将文件发送到 springboot api,该 api 处理这些文件并返回 pdf 响应,我想将其显示在我的角度前端上。一切正常,直到显示 pdf 为止,当它呈现一个空白 pdf(具有正确的页数)以及控制台中的警告时:

\n\n
Warning: Indexing all PDF objects pdf.worker.min.js:1\nWarning: Invalid stream: "FormatError: Bad FCHECK in flate stream: 120, 239"\n
Run Code Online (Sandbox Code Playgroud)\n\n

我知道 pdf 本身没有损坏,因为当我向 API 发出 get 请求以检索同一 pdf 的存储版本时,它没有损坏并且呈现良好。

\n\n

我尝试过使用 TextEncoder:

\n\n
let enc = new TextEncoder();\nthis.masterPdf = enc.encode(event[1])\n
Run Code Online (Sandbox Code Playgroud)\n\n

使用文件读取器:

\n\n
  var\xc2\xa0reader\xc2\xa0=\xc2\xa0new\xc2\xa0FileReader();\n\xc2\xa0\xc2\xa0reader.onload\xc2\xa0=\xc2\xa0function()\xc2\xa0{\n      var\xc2\xa0arrayBuffer\xc2\xa0=\xc2\xa0this.result;\n      self.masterPdf =\xc2\xa0new\xc2\xa0Uint8Array(arrayBuffer);\n      console.log(self.masterPdf);\n      self.masterShow = true;\n  }\n  var blob = new Blob([event[1]], {type:\'application/pdf\'});\n  reader.readAsArrayBuffer(blob);\n
Run Code Online (Sandbox Code Playgroud)\n\n

并使用 StringToBytes:

\n\n
let strToByteArr = stringToBytes(event[1]);\nthis.masterPdf = new Uint8Array(strToByteArr);\n …
Run Code Online (Sandbox Code Playgroud)

pdf angularjs dropzone.js angular

2
推荐指数
1
解决办法
7660
查看次数

标签 统计

angular ×1

angularjs ×1

dropzone.js ×1

pdf ×1