HakanL / WkHtmlToPdf-DotNet

C# .NET Core wrapper for wkhtmltopdf library that uses Webkit engine to convert HTML pages to PDF.
GNU Lesser General Public License v3.0
366 stars 66 forks source link

aspnet:6.0-alpine docker image problem #88

Closed stefanodesimone closed 1 year ago

stefanodesimone commented 1 year ago

Hi all, I'm using visual studio pro 2022, in my docker file i use: FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS base Install:

  1. libgdiplus
  2. freetype-dev
  3. libpng-dev
  4. jpeg-dev
  5. libjpeg-turbo
  6. libjpeg-turbo-dev
  7. libc-dev
  8. libx11-dev

When i try to create a pdf file an error occur: AggregateException: One or more errors occurred. (Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported.)

Can anyone help me? Thx Stefano

HakanL commented 1 year ago

The Alpine image is very bare-bones and requires quite a bit of dependencies. A good start is to look at what is in the sample https://github.com/HakanL/WkHtmlToPdf-DotNet/blob/master/src/TestConsoleAppDocker/Dockerfile. And also look at this issue that has a link to a potential solution. Once you figured out the solution feel free to post a PR with an Alpine docker example.

HakanL commented 1 year ago

I've added a sample now that uses Alpine, it's quite different from the other distribution (very skinny), so you may run into issues with images, etc (basically I only tested that it could generate the simple text-only PDF). I think it would be better to use the larger base distribution. https://github.com/HakanL/WkHtmlToPdf-DotNet/tree/master/src/TestConsoleAppDockerAlpine

stefanodesimone commented 1 year ago

Work like a charm!!! Thanks a lot Stefano