arklumpus / MuPDFCore

Multiplatform .NET bindings for MuPDF
GNU Affero General Public License v3.0
115 stars 20 forks source link

Install MuPDFCore in Blazor WebAssembly #18

Open tzographos opened 2 years ago

tzographos commented 2 years ago

Hello, I am trying to install the library to a Blazor WebAssembly project in .NET 6.0, and I am getting the error of a missing MuPDFWrapper dll.
Do you have any ideas?

edit: I need to mention that I even tried adding the library as a blazor native dependency (using NativeFileReference) but the error persisted.

arklumpus commented 2 years ago

Hi! That doesn't surprise me, as the library does not contain a native WASM assembly... To allow this, one would need to recompile everything (starting from MuPDF itself) targeting WASM. This should not be impossible, but I have never tried it; maybe I will get around to it in the future 😅

Let's leave this open until I have a chance to give it a go and see if it is feasible.

tzographos commented 2 years ago

I used emscripten to produce the output in wasm. It worked, and I was able to add the native dependency. But I was still receiving the dll missing error. Yeah, I think it needs a little rework.

arklumpus commented 2 years ago

The thing is that MuPDFCore uses the MuPDFWrapper DLL, which uses the MuPDF library... I don't know if that's what you did, but I think you would need to compile both MuPDF and MuPDFWrapper using Emscripten.

I have never done this before though, so I'm not sure exactly what's needed... I will get experimenting if I have some time!

arklumpus commented 1 year ago

I have had a look at this, and I don't think this is likely to work easily... I have managed to compile a WASM MuPDF, but it seems that not all of the API are there; in fact, even their WASM/JavaScript version has a relatively limited number of functions (https://github.com/ArtifexSoftware/mupdf-wasm).

In particular, my call to fz_create_context fails; I'm not sure if there's something wrong on my end, but I don't really have time to investigate further.