下载后文件未显示本地语言

问题描述

我有一个使用 node.js 开发并托管在 heroku 上的应用程序。我们正在 node.js 服务器上生成 pdf 并将流发送到前端,以便用户可以下载文件

当我在本地主机上尝试时,我能够在文件中看到正确的内容。但是当我在 heroku 上托管 node.js 代码并尝试相同的代码时,该文件没有在 pdf 中显示本地语言(泰卢固语,一种印度语言)。下面是我得到的文件截图。

enter image description here

下面的代码是前端代码,它将命中服务器api并从服务器获取文件内容

to

下面的代码是下载文件。上面代码中得到响应后调用函数

const response = await axios.post(
          '/reports/pdf',{ tests: this.tests },{ responseType: 'blob' },);
        window.console.log(response);
        if (response) {
          this.createAndDownloadBlobFile(response,'tests');
        }

node.js 代码如下

createAndDownloadBlobFile(body,filename,extension = 'pdf') {
      const blob = new Blob([body]);
      const fileName = `${filename}.${extension}`;
      if (navigator.msSaveBlob) {
        // IE 10+
        navigator.msSaveBlob(blob,fileName);
      } else {
        const link = document.createElement('a');
        // browsers that support HTML5 download attribute
        if (link.download !== undefined) {
          const url = URL.createObjectURL(blob);
          link.setAttribute('href',url);
          link.setAttribute('download',fileName);
          link.style.visibility = 'hidden';
          document.body.appendChild(link);
          link.click();
          document.body.removeChild(link);
        }
      }
    },

我尝试了几种不同的方法,将响应格式更改为 base64 并更改数据格式。但是还是没有用。任何帮助将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)