Closed lucho78 closed 7 months ago
Bonsoir Luc, maybe it's the same problem as #2066. The base library now uses .mjs files instead of .js files. Sometimes this requires extra configuration.
If that's not the problem, can you see something in the console or the network tab?
Thanks for your reply Stephan but there is something weird on my side:
Here the network traces on my browser with the version 19.0.4
In the dom:
I've checked and my assets folder contains all the files needed
Why the file "viewer-3.xx.min.js" is correctly downloaded in the version 18.1.x
In the dom:
Any suggestions? Thanks a lot Cheers Luc
I'm confused. The preview tab in your screenshot seems to indicate the JavaScript file is downloaded, but you say it's not?
The only idea crossing my mind is that the file ending has changed to *.mjs
. JavaScript interprets mjs
files differently than *.js
files, so that's nothing I can change. Maybe your server needs additional configuration to ship this file as a JavaScript file.
Sorry my previous message was not very clear. Basically the file pdf-4.xx.min.mjs is correctly downloaded. But the file viewer-4.0.730.mjs is not included in the DOM so not downloaded on the local machine.
For your information, I'm doing the test with a local server (local tomcat embedded in Spring boot)
I see. Please add a breakpoint at the loadViewer()
method. Is it ever called?
Until recently, I always found the method by opening the file ngx-extended-pdf-viewer.mjs
, but it seems in production mode you have to find the method in the main.js
.
Hi Stephan, First thanks a lot for your support. I really appreciate :-)
It seems that the method "script.onload" is never triggered for me.
The code on the line 400348 is never called. So the method "loadViewer" is never called.
I've checked: the file "http://localhost:8080/assets/pdf-4.0.730.min.mjs" exists and it's accessible from the browser.
Any idea? Thanks Luc
No idea. If the first <script>
is added properly to the DOM and if it triggers loading the pdf.js file, and if that's successful, it's hard to imagine why onload()
is not called. That's a basic JavaScript functionality.
Did you try different browsers? And did you try [minifiedJSLibrary]="false"
? Maybe it has something to do with a virus scanner or an ad blocker (but that's a far shot).
You could also try to update to version 19.0.6. It fixes the viewer if it's running in an iFrame. Maybe the same bug fix helps you, too.
I've tried with the version 19.0.6 with the parameter [minifiedJSLibrary]="false". I get the same behavior with chrome.
With firefox, I get the following exception:
Same behavior if [minifiedJSLibrary]="true"...
Any other ideas? Thanks a lot Luc
Yes, I'm back to my first theory. You must configure Spring Boot correctly. It seems it isn't familiar with *.mjs files. Something along these lines. I didn't test them, they may be buggy, but you get the idea:
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**/*.mjs")
...
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.mediaType("mjs", new MediaType("text", "javascript"));
}
}
Super thanks a lot for your great support. The following config on Spring boot solves my issue. @Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.mediaType("mjs", new MediaType("text", "javascript")); }
Hi, I've tried the latest version of the module. It works fine with 'ng serve but when I compile it the pdf is not shown. I did not change the procedure since a while and it works fine with the version 18.
What should I change in the build to make it work? Thanks Luc