Skip to content

Browser-WASM Support for QuestPDF #1327

@xer4yx

Description

@xer4yx

Hello👋! I wanted to add a functionality for my Blazor application where I can generate a PDF from my page content. My initial plan is to:

  1. Use the library in the client side (Blazor WASM)
  2. Create a Service class and inject it to page
  3. Retrieve the byte[] from the generated document and use it as a MemoryStream
  4. Create a DotNetStreamReference from the MemoryStream
  5. Pass the stream reference to a JS script using JSRuntime.InvokeVoidAsync
  6. The script gets the stream reference converting to: stream reference => array buffer => blob => url object (string).
  7. URL object then is used in the HTMLAnchorElement as a <a /> tag and downloads it

But the problem is on setting my license, I encounter error saying:

blazor.webassembly.js:1 PDF Generation Error: System.TypeInitializationException: The type initializer for 'QuestPDF.Settings' threw an exception.
blazor.webassembly.js:1  ---> System.TypeInitializationException: The type initializer for 'QuestPDF.Helpers.Helpers' threw an exception.
blazor.webassembly.js:1  ---> System.Exception: The QuestPDF library has encountered an issue while loading one of its dependencies.
blazor.webassembly.js:1 
blazor.webassembly.js:1 Your runtime is not supported by QuestPDF. The following runtimes are supported: win-x86, win-x64, linux-x64, linux-arm64, linux-musl-x64, osx-x64, osx-arm64. Your current runtime is detected as 'browser-wasm'. 
blazor.webassembly.js:1  ---> System.DllNotFoundException: QuestPdfSkia
blazor.webassembly.js:1    at QuestPDF.Skia.SkNativeDependencyCompatibilityChecker.ExecuteNativeCode()
blazor.webassembly.js:1    at QuestPDF.Helpers.NativeDependencyCompatibilityChecker.CheckIfExceptionIsThrownWhenLoadingNativeDependencies()
blazor.webassembly.js:1    --- End of inner exception stack trace ---
blazor.webassembly.js:1    at QuestPDF.Helpers.NativeDependencyCompatibilityChecker.<TestOnce>g__ThrowCompatibilityException|18_0(Exception innerException)
blazor.webassembly.js:1    at QuestPDF.Helpers.NativeDependencyCompatibilityChecker.TestOnce()
blazor.webassembly.js:1    at QuestPDF.Helpers.NativeDependencyCompatibilityChecker.Test()
blazor.webassembly.js:1    at QuestPDF.Skia.SkNativeDependencyCompatibilityChecker.Test()
blazor.webassembly.js:1    at QuestPDF.Helpers.Helpers..cctor()
blazor.webassembly.js:1    --- End of inner exception stack trace ---
blazor.webassembly.js:1    at QuestPDF.Settings..cctor()
blazor.webassembly.js:1    --- End of inner exception stack trace ---

I was thinking if there will be plan on creating a support for browser-wasm?

I've tried to downgrade the version of QuestPDF to 2023.12.X - 2023.9.X but to no avail it produces the same type of error in the console.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions