Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not find "locale.properties" file from PDF.js

I use this plugin: PDF.js.

I am trying to solve the problems that show in console log.

Follow image:

enter image description here

Here is a simple project ready, only download and run project you will see the same problem. I've tried everything and I can not solve a problem.

Follow 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>

See another image that contains "locale.properties" file:

enter image description here

And I also get a lot of warnings from l10n.js. I downloaded it here: http://mozilla.github.io/pdf.js/ by clicking the "download" button.

Any solution ?

like image 744
Matheus Miranda Avatar asked Aug 01 '18 13:08

Matheus Miranda


3 Answers

Adding .properties MIME type configuration inside web.config file should work:

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

  <system.webServer>
     <staticContent>
        <mimeMap fileExtension=".properties" mimeType="application/octet-stream" />
     </staticContent>
  </system.webServer>
</configuration>

If the project is already deployed in IIS (not IIS Express), go to site name => MIME Types => Add, and set .properties extension with application/octet-stream type as in provided image below:

MIME Type Setting

Here is the console log view with all l10n.js errors disappear:

Console Result

The reason behind usage of application/octet-stream is that the corresponding file should be treated as stream, even file contents are readable and stored in text format.

Reference: l10n.js - locale.properties 404 (Not Found)

like image 143
Tetsuya Yamamoto Avatar answered Nov 04 '22 02:11

Tetsuya Yamamoto


If you are using .net core (2.1) try to add .properties as static file in your "public void Configure(IApplicationBuilder app, IHostingEnvironment env)" method

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

app.UseSpaStaticFiles(new StaticFileOptions
{
      ContentTypeProvider = provider
});
like image 5
Lukáš Janeček Avatar answered Nov 04 '22 03:11

Lukáš Janeček


Inspired by Lukáš Janeček, If you are using .net core(3.1). try to add the following code to your public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".properties"] = "application/octet-stream";
app.UseStaticFiles(new StaticFileOptions()
{
     ContentTypeProvider = provider
});
like image 2
Jane Jian Avatar answered Nov 04 '22 02:11

Jane Jian