Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't view PDF in MAUI Blazor #719

Closed
animike opened this issue May 18, 2024 · 2 comments · Fixed by #804
Closed

Can't view PDF in MAUI Blazor #719

animike opened this issue May 18, 2024 · 2 comments · Fixed by #804
Assignees
Labels
area-maui area-pdf-viewer bug Something isn't working

Comments

@animike
Copy link

animike commented May 18, 2024

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

  • .NET Version: .NET 8
  • BlazorBootstrap: 2.2.0

Desktop:

  • OS: Windows 10
@gvreddy04
Copy link
Contributor

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

@khaoula1305
Copy link

I've been experiencing the same error for two days, trying to fix it until the idea of checking the reported issues came to mind. Thank you for posting this issue

Normally, The problem is in this js file _content/Blazor.Bootstrap/blazor.bootstrap.pdf.js and especially when importing those two lines:


 import * as pdfJS from './pdfjs-4.0.379.min.mjs';
import * as pdfWorker from './pdfjs-4.0.379.worker.min.mjs';

I hope it will be fixed soon.

@gvreddy04 gvreddy04 self-assigned this Jul 12, 2024
@gvreddy04 gvreddy04 added bug Something isn't working and removed investigate labels Jul 14, 2024
@gvreddy04 gvreddy04 added this to the 3.0.0-preview.3 milestone Jul 14, 2024
@gvreddy04 gvreddy04 linked a pull request Jul 14, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-maui area-pdf-viewer bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants