richard-scryber / scryber.core

Scryber.Core is a dotnet 6 html to pdf engine written entirely in C# for creating beautiful flowing documents from html templates including css styles, object data binding and svg drawing.
Other
195 stars 31 forks source link

Linux Container and System.Drawing.Common Library Errors #69

Open eoehen opened 2 years ago

eoehen commented 2 years ago

I have problems to run scryber in a .net 6 linux container.

FROM mcr.microsoft.com/dotnet/aspnet:6.0
...

The Installation the library libgdiplusdoes not seem to solve the problem. https://github.com/richard-scryber/scryber.core/blob/master/docs/libgdiplus.md

An unhandled exception was thrown by the application.
Exception: Scryber.PDFLayoutException: The layout of component \u0027text1\u0027 failed. The initialization of the fonts failed. The type initializer for \u0027Gdip\u0027 threw an exception.  
System.Configuration.ConfigurationErrorsException: The initialization of the fonts failed. The type initializer for \u0027Gdip\u0027 threw an exception.
System.TypeInitializationException: The type initializer for \u0027Gdip\u0027 threw an exception.  ---\u003E System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms. 

System.Drawing is a windows only library. https://docs.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only

Recommended action is to migrate to one of the following libraries:

What is the meaning about this? Should we migrate scryber.core to SkiaSharp? @richard-scryber or @VincentNikkelen If you want, I can try to do this migration.

By the way. I think the culture info in the unit test should be defined otherwise some tests f.e. with datetime will failing in some environments.

Or is there an other solution for this problem?

Thank you for your feedback.

Originally posted by @eoehen in https://github.com/richard-scryber/scryber.core/discussions/68

Jogai commented 2 years ago

ImageSharp is cross platform, and a really awesome project.

eoehen commented 2 years ago

@Jogai I don't care which library. Do you have experience with it and could you help? My goal would be that scryber.core runs under linux in a linux container. But I want to wait for the feedback from @richard-scryber .

Jogai commented 2 years ago

I have experience with the predecessor and followed development. Its really impressive what they did. (And i have huge respect for @JimBobSquarePants)

As for helping that would be more an issue with time than anything else, but I'm in need of generating PDF's in a linux container so I might have to jump in at some point anyway.

eoehen commented 2 years ago

@richard-scryber Thank you very much for your great pdf renderer.

Unfortunately I was not aware that your library does not run in a linux container. However, I absolutely need a library that runs in a linux container.

I have invested time to change scryber.core from System.Drawing to SkiaSharp. The first tests have shown that the changes in the fonts area was successful. But for the adjustment in the ImageFormatParser I lack the necessary knowledge. I need help with all this cases.

Can you please give me some feedback on this issue? What's your plan. Can we tackle this issue together, or is it not a priority for you?

On the other hand, I am forced to switch to another library, which I would find extremely unfortunate.

eoehen commented 2 years ago

Dear @richard-scryber I add a proposal to use SkiaSharp for Fonts. I prepared a solution to use SkiaSharp for colors and It looks like I have a solution for parsing images with SkiaSharp, but I need feedback.

It would be great to hear from you soon.

EndOfTheSpline commented 2 years ago

Any updates on Linux compatibility? I would also be very interested in running Scryber under Linux, preferably in a container. I would also be willing to help out with that to the best of my abilities.

Regarding the library, I would prefer not to use ImageSharp due to the licensing.

Jogai commented 2 years ago

What's wrong with the apache 2 license? (which would apply here: https://docs.sixlabors.com/articles/imagesharp.web/#license)

EndOfTheSpline commented 2 years ago

Because the Apache 2 license only applies for "non-commercial" projects, which are fairly limited for certain applications, as outlined in the repository's LICENSE;

Works in Source or Object form are licensed to You under the Apache License, Version 2.0 if.

  • You are consuming the Work in for use in software licensed under an Open Source or Source Available license.
  • You are consuming the Work as a Transitive Package Dependency.
  • You are consuming the Work as a Direct Package Dependency in the capacity of a For-profit company/individual with less than 1M USD annual gross revenue.
  • You are consuming the Work as a Direct Package Dependency in the capacity of a Non-profit organization or Registered Charity.

They've announced a license change about three years ago, and the uncertainty about what the licensing would look like (pricing, permissions, and so forth) had required us to move to alternatives instead. So in a way, ImageSharp is a bit of a hot topic here.

JimBobSquarePants commented 2 years ago

That doesn’t apply to this library though? The new license is explicitly non viral so any consumers of this library, commercial or otherwise are subject to the Apache license due to the deferral clause in the license.

Licenses are granted based upon You meeting the qualified criteria as stated. Once granted, You must reference the granted license only in all documentation.

Jogai commented 2 years ago

@EndOfTheSpline The first bullet point applies here and the second to all dependants of this project. I dont see a problem.

richard-scryber commented 2 years ago

@EndOfTheSpline - Just really starting to get back into this after a 6 month break. There is a beta package that supports net6.0 and net standard 2.0 uploaded to Nuget (6.0.0.8-beta as of now). I'm running on Mac, and working well. I've also pushed this as a blazor wasm app onto cloudflare pages as a static site - that is working awesomely! Linus should not now be an issue. Would love feedback! :-)

Also getting this into a docker container would be a great thing.

As for the license - I am no expert, but @JimBobSquarePants - really appreciate your input. At the moment my expectation is that as this license is open, and anyone using Scryber will have a transitive package dependancy on ImageSharp then it should be ok. @Jogai - your input is appreciated too.