vikramlearning / blazorbootstrap

An Enterprise-class Blazor Bootstrap Component library built on the Blazor and Bootstrap CSS frameworks.
https://docs.blazorbootstrap.com/
Apache License 2.0
565 stars 15 forks source link

Can't view PDF in MAUI Blazor #719

Open animike opened 1 month ago

animike commented 1 month ago

Description When running the app in Visual Studio in Windows Machine, the GUI controls show, but the pdf area is blank. When checking developer tools with ctrl+shift+i javascript errors appear reported in the console:

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec. pdfjs-4.0.379.worker.min.mjs:1

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec. blazor.webview.js:1

Failed to fetch dynamically imported module: https://0.0.0.0/_content/Blazor.Bootstrap/blazor.bootstrap.pdf.js TypeError: Failed to fetch dynamically imported module: https://0.0.0.0/_content/Blazor.Bootstrap/blazor.bootstrap.pdf.js at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args) at BlazorBootstrap.PdfViewerJsInterop.InitializeAsync(Object objRef, String elementId, Double scale, Double rotation, String url) at BlazorBootstrap.PdfViewer.b__11_0() at BlazorBootstrap.BlazorBootstrapComponentBase.OnAfterRenderAsync(Boolean firstRender) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) NotifyUnhandledException @ blazor.webview.js:1

How to reproduce

  1. Create MAUI Blazor project
  2. Follow steps from https://docs.blazorbootstrap.com/getting-started/maui-blazor-net-8
  3. Add some.pdf to wwwroot
  4. Add a PdfViewer with some.pdf to Home.razor <PdfViewer Url="some.pdf" />
  5. Run on Windows Machine from Visual Studio

Expected behavior The PDF is visualized.

Screenshots blazorbootstrappdfviewer

Versions

Desktop:

gvreddy04 commented 1 month ago

@animike Thank you for trying BlazorBootstrap. We will investigate this.