无法从 PDF.js 中找到“locale.properties”文件

Mat*_*nda 8 html pdf asp.net-mvc

我使用这个插件:PDF.js

我正在尝试解决控制台日志中显示的问题。

跟随图片:

在此处输入图片说明

是一个准备好的简单项目,只有下载并运行项目你会看到同样的问题。我已经尝试了一切,但我无法解决问题。

按照 html:

<div style="width: 800px; height: 500px;">
    <iframe width="800" height="500" id="iframePdfViewer" seamless="seamless" scrolling="no" src="~/Scripts/pdfjs-dist/web/viewer.html"></iframe>
</div>
Run Code Online (Sandbox Code Playgroud)

查看另一个包含“locale.properties”文件的图像:

在此处输入图片说明

我也收到了很多来自 l10n.js 的警告。我在这里下载了它:http : //mozilla.github.io/pdf.js/通过单击“下载”按钮。

任何解决方案?

Tet*_*oto 13

.properties在 web.config 文件中添加MIME 类型配置应该可以工作:

<configuration>
  <!-- other stuff -->

  <system.webServer>
     <staticContent>
        <mimeMap fileExtension=".properties" mimeType="application/octet-stream" />
     </staticContent>
  </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

如果项目已经部署在 IIS 中(不是 IIS Express),请转到站点名称 => MIME Types=> Add,并.properties使用application/octet-stream下面提供的图像设置扩展名:

MIME 类型设置

这是所有l10n.js错误消失的控制台日志视图:

控制台结果

使用的原因application/octet-stream是相应的文件应该被视为流,即使文件内容也是可读的并以文本格式存储。

参考:l10n.js - locale.properties 404(未找到)


小智 5

如果您使用 .net core (2.1) 尝试在“public void Configure(IApplicationBuilder app, IHostingEnvironment env)”方法中添加 .properties 作为静态文件

var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".properties"] = "application/octet-stream"; 

app.UseSpaStaticFiles(new StaticFileOptions
{
      ContentTypeProvider = provider
});
Run Code Online (Sandbox Code Playgroud)