arklumpus/VectSharp

MuPDF dependencies

AlexanderMagdysyuk opened this issue ยท 5 comments

Hi, can you clarify what you mean by looking strange? ๐Ÿ˜…

The way VectSharp.Raster currently works is by first creating a PDF document, and then rendering the PDF with MuPDFCore (which provides .NET bindings for the native MuPDF). I know this is not ideal, but I have plans to rework this to use SkiaSharp instead (this is already used by one of the Avalonia Canvas renderers, so I would be able to reuse some code)... When I have time ๐Ÿ˜…

I'm not sure, what is the issue with PDF?

Ok, I am looking for a possibility to render image/svg/pdf in web assembly, so check if I can avoid native (as skia) dependencies.

Ah, I see... I will have a look and see if I can come up with an alternative! VectSharp.PDF and VectSharp.SVG should be fine though, as don't have any native dependency!

Ok, I have create VectSharp.Raster.ImageSharp, which uses ImageSharp.Drawing to create the image. To install it you will have to add the ImageSharp MyGet source to your package sources, so that you can get the latest nightly version (the beta that is currently on NuGet throws an exception when you attempt to draw outside the page).

This does not have any native dependencies, but it is generally slower than using VectSharp.Raster:

image

This is interesting, it means that creating a PDF document and rendering is faster than just rendering the image, despite the additional step...

In any case, by using VectSharp.Raster.ImageSharp, VectSharp.PDF and VectSharp.SVG you should be able to generate PDF, SVG and BMP/GIF/JPEG/PBM/PNG/TGA/TIFF/WebP documents without any native dependency.

Have a look at the overloads of the SaveAsImage and SaveAsRawBytes methods to get an idea of what you can do.

I'm closing this, but feel free to reopen or to open another issue if you have any problems!

This sounds really cool! Thanks for the update.