QuestPDF / QuestPDF

QuestPDF is a modern open-source .NET library for PDF document generation. Offering comprehensive layout engine powered by concise and discoverable C# Fluent API. Easily generate PDF reports, invoices, exports, etc.
https://www.questpdf.com
Other
12k stars 629 forks source link

Unable to load shared library 'QuestPdfSkia' or one of its dependencies #812

Closed NelsonSantos closed 1 month ago

NelsonSantos commented 8 months ago

Describe the bug Unable to load shared library 'QuestPdfSkia' or one of its dependencies

To Reproduce 1-Install the version 2024.3.0-beta I installed all dependencies like HarfBuzzSharp.NativeAssets.Linux, SkiaSharp.NativeAssets.Linux.NoDependencies, skiSharp, etc 2-Call anything like QuestPDF.Settings.License = LicenseType.Community; 3-Deploy on docker linux environment 4-Run your app

Expected behavior I can't run it on "release", just in debug mode (on local machine, no docker, works)

Environment What version of the library do you use? -> 2024.3.0-beta What operating system do you use? (OS type, x64 vs x86 vs arm64) -> mac OSx Ventura 13.6 on Intel i9

Additional context

The type initializer for 'QuestPDF.Settings' threw an exception.

The QuestPDF library has encountered an issue while loading one of its dependencies.

Unable to load shared library 'QuestPdfSkia' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: 
/app/bin/Debug/net7.0/runtimes/linux-x64/native/QuestPdfSkia.so: cannot open shared object file: No such file or directory
/app/bin/Debug/net7.0/runtimes/linux/native/QuestPdfSkia.so: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.16/QuestPdfSkia.so: cannot open shared object file: No such file or directory
/app/bin/Debug/net7.0/QuestPdfSkia.so: cannot open shared object file: No such file or directory
/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /app/bin/Debug/net7.0/runtimes/linux-x64/native/libQuestPdfSkia.so)
/app/bin/Debug/net7.0/runtimes/linux/native/libQuestPdfSkia.so: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.16/libQuestPdfSkia.so: cannot open shared object file: No such file or directory
/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /app/bin/Debug/net7.0/libQuestPdfSkia.so)
/app/bin/Debug/net7.0/runtimes/linux-x64/native/QuestPdfSkia: cannot open shared object file: No such file or directory
/app/bin/Debug/net7.0/runtimes/linux/native/QuestPdfSkia: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.16/QuestPdfSkia: cannot open shared object file: No such file or directory
/app/bin/Debug/net7.0/QuestPdfSkia: cannot open shared object file: No such file or directory
/app/bin/Debug/net7.0/runtimes/linux-x64/native/libQuestPdfSkia: cannot open shared object file: No such file or directory
/app/bin/Debug/net7.0/runtimes/linux/native/libQuestPdfSkia: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.16/libQuestPdfSkia: cannot open shared object file: No such file or directory
/app/bin/Debug/net7.0/libQuestPdfSkia: cannot open shared object file: No such file or directory
AbdullahAlhariri commented 8 months ago

I'm getting this issue too on ubuntu 22.04

AbdullahAlhariri commented 8 months ago

I found that using 2024.3.0-beta causes the problem. I have now switched to '2023.12.5' and it works as it should, but it is of course an older version

MarcinZiabek commented 8 months ago

Would you please share the exact version that does not work and the exact specifications of the environment? (what operating system, if you are using containers, what OS in the container, what CPU architecture, etc.). I am a little confused by your comments and want to ensure I am following your findings correctly πŸ˜„

NelsonSantos commented 8 months ago

Would you please share the exact version that does not work and the exact specifications of the environment? (what operating system, if you are using containers, what OS in the container, what CPU architecture, etc.). I am a little confused by your comments and want to ensure I am following your findings correctly πŸ˜„

Hello,

I think that @AbdullahAlhariri do a mistake, the 2024.3.0-beta is the problem version and 2023.12.5 is the fix.

In the new 2024.3.0-beta version I needed the new text justification and SVG image printing functions.

But you don't need to call any of above functions to raise de exception, in my case, a just call to QuestPDF.Settings.License = LicenseType.Community using the 2024.3.0-beta version raises the exception on docker. On dev machine, running outside of docker, there are no exception's.

My docker is running on Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-91-generic x86_64)

Client: Docker Engine - Community
 Version:           24.0.5
 API version:       1.43
 Go version:        go1.20.6
 Git commit:        ced0996
 Built:             Fri Jul 21 20:35:18 2023
 OS/Arch:           linux/amd64
 Context:           default

The docker image used for my dotnet worker-service app was FROM mcr.microsoft.com/dotnet/runtime:7.0 AS base

And my dev machine is Mac OSx Ventura 13.6

AbdullahAlhariri commented 8 months ago

I'm sorry, just read my comment again. 2024.3.0-beta Did cause the problem, and 2023.12.5 was working on my linux machine (Ubuntu 22.04.3 LTS x86_64). Kernel using is: 6.5.0-21-generic

MarcinZiabek commented 8 months ago

I thought that the glibc library is already statically linked to the native code. It apparently is not. I will investigate ways of linking it statically or using MUSL instead. Thank you for sharing this issue with me.

andreix86-64 commented 8 months ago

Hi. I could also not get QuestPdf 2024.3.0-beta to run on .NET 6 on Ubuntu 22.04.4 LTS. Then I tried to use .NET 8 and I got the following error: error:"ConsoleApp2/ConsoleApp2/bin/Debug/net8.0/ConsoleApp2: symbol lookup error: ConsoleApp2/ConsoleApp2/bin/Debug/net8.0/runtimes/linux-x64/native/libQuestPdfSkia.so: undefined symbol: _Z24SkFontMgr_New_FontConfigP9_FcConfig"

It is also important to note that this library seems to have a dependency on GLIBCXX_3.4.32 which is not included by default on Ubuntu 22.04.4 LTS. Therefore I had to use the following commands to get the library to load (i.e. to install GLIBCXX_3.4.32):

sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install --only-upgrade libstdc++6

Unfortunately as mentioned above I get the "undefined symbol: _Z24SkFontMgr_New_FontConfigP9_FcConfig"" error.

dolev222 commented 8 months ago

Hi, I'm running the QuestPdf 2024.3.0-beta as well and getting this error on Cloud Run linux containers. Please let me know when you have a fix :) Thanks for the great effort.

Can't use the earlier version because I need the fix with the numbers and the RTL text, so I'm pretty stuck.

dotsuber commented 8 months ago

Hi, I'm getting same exception on Linux environment. Would you please share an ETA for the fix so we can work on our schedule and maybe find other solutions in the mean time? We have customers dependent on that.

Thanks for the BIG effort, much appreciated.

dolev222 commented 7 months ago

Hi @MarcinZiabek, Thank you so much for the hard work for us!

We have waiting customers, and currently cannot use that package since we must have the RTL support and it doesn't run on Linux (alpha, beta and beta1 were tested).

Please let us know if you have any ETA or a temporary workaround so we can apply.

dolev222 commented 7 months ago

The problem was fixed for me on version 2024.3.0-rc. Thanks a lot.

luigisaggese commented 6 months ago

I'm using alpine and 2024.3.0 and i have same issue

---> System.Exception: The QuestPDF library has encountered an issue while loading one of its dependencies. ---> System.DllNotFoundException: Unable to load shared library 'QuestPdfSkia' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:Error loading shared library /app/runtimes/linux-x64/native/QuestPdfSkia.so: No such file or directoryError loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.4/QuestPdfSkia.so: No such file or directoryError loading shared library /app/QuestPdfSkia.so: No such file or directoryError loading shared library QuestPdfSkia.so: No such file or directoryError loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /app/runtimes/linux-x64/native/libQuestPdfSkia.so)Error loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.4/libQuestPdfSkia.so: No such file or directoryError loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /app/libQuestPdfSkia.so)Error loading shared library libQuestPdfSkia.so: No such file or directoryError loading shared library /app/runtimes/linux-x64/native/QuestPdfSkia: No such file or directoryError loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.4/QuestPdfSkia: No such file or directoryError loading shared library /app/QuestPdfSkia: No such file or directoryError loading shared library QuestPdfSkia: No such file or directoryError loading shared library /app/runtimes/linux-x64/native/libQuestPdfSkia: No such file or directoryError loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.4/libQuestPdfSkia: No such file or directoryError loading shared library /app/libQuestPdfSkia: No such file or directoryError loading shared library libQuestPdfSkia: No such file or directory at QuestPDF.Skia.SkNativeDependencyCompatibilityChecker.API.check_compatibility_by_calculating_sum(Int32 a, Int32 b) at QuestPDF.Skia.SkNativeDependencyCompatibilityChecker.CheckIfExceptionIsThrownWhenLoadingNativeDependencies() --- End of inner exception stack trace --- at QuestPDF.Skia.SkNativeDependencyCompatibilityChecker.Test() at QuestPDF.Helpers.NativeDependencyCompatibilityChecker.Test() at QuestPDF.Settings..cctor() --- End of inner exception stack trace --- at QuestPDF.Settings.set_License(Nullable1 value)`

MarcinZiabek commented 6 months ago

I'm using alpine and 2024.3.0 and i have same issue

---> System.Exception: The QuestPDF library has encountered an issue while loading one of its dependencies. ---> System.DllNotFoundException: Unable to load shared library 'QuestPdfSkia' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:Error loading shared library /app/runtimes/linux-x64/native/QuestPdfSkia.so: No such file or directoryError loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.4/QuestPdfSkia.so: No such file or directoryError loading shared library /app/QuestPdfSkia.so: No such file or directoryError loading shared library QuestPdfSkia.so: No such file or directoryError loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /app/runtimes/linux-x64/native/libQuestPdfSkia.so)Error loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.4/libQuestPdfSkia.so: No such file or directoryError loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /app/libQuestPdfSkia.so)Error loading shared library libQuestPdfSkia.so: No such file or directoryError loading shared library /app/runtimes/linux-x64/native/QuestPdfSkia: No such file or directoryError loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.4/QuestPdfSkia: No such file or directoryError loading shared library /app/QuestPdfSkia: No such file or directoryError loading shared library QuestPdfSkia: No such file or directoryError loading shared library /app/runtimes/linux-x64/native/libQuestPdfSkia: No such file or directoryError loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.4/libQuestPdfSkia: No such file or directoryError loading shared library /app/libQuestPdfSkia: No such file or directoryError loading shared library libQuestPdfSkia: No such file or directory at QuestPDF.Skia.SkNativeDependencyCompatibilityChecker.API.check_compatibility_by_calculating_sum(Int32 a, Int32 b) at QuestPDF.Skia.SkNativeDependencyCompatibilityChecker.CheckIfExceptionIsThrownWhenLoadingNativeDependencies() --- End of inner exception stack trace --- at QuestPDF.Skia.SkNativeDependencyCompatibilityChecker.Test() at QuestPDF.Helpers.NativeDependencyCompatibilityChecker.Test() at QuestPDF.Settings..cctor() --- End of inner exception stack trace --- at QuestPDF.Settings.set_License(Nullable1 value)`

What operating system are you using? If Linux, what version exactly? At this moment, QuestPDF does not support the Alpine Linux, but one community member is helping us to reintroduce the support.

luigisaggese commented 6 months ago

@MarcinZiabek yes i just saw that on the last version is removed the support for alpine. To reply to your question I'm using mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS runtime

Vfurt commented 6 months ago

Hello everyone. I've also encountered this problem using version 2024.3.0 in an aws lambda function. Tried updating HarfBuzzSharp.NativeAssets.Linux and SkiaSharp.NativeAssets.Linux.NoDependencies but had no luck. It was working fine on 2023.9.0

toanxyz commented 6 months ago

After upgrading to latest version, everything just stop working.

I'm using Debian 12 (aspnet:8.0-bookworm-slim), I have no clue what is wrong, in local it works fine.

image

MarcinZiabek commented 6 months ago

I am very sorry for any issues related to the latest version. The 2024.3.X release is one of the most significant redesigns of the library, and although it has been tested by the Community for nearly two months, some hiccups are expected once it is fully available to all developers.

I've also encountered this problem using version 2024.3.0 in an aws lambda function. Tried updating HarfBuzzSharp.NativeAssets.Linux and SkiaSharp.NativeAssets.Linux.NoDependencies but had no luck. It was working fine on 2023.9.0

@Vfurt The 2024.3.X release does not depend on SkiaSharp anymore. Both mentioned nuget packages can be safely removed.

After upgrading to latest version, everything just stop working. I'm using Debian 12 (aspnet:8.0-bookworm-slim), I have no clue what is wrong, in local it works fine.

I don't know what exactly causes the issue on your end. In the 2024.3.1 release, I increased compatibility with existing codebases relying on QuestPDF. Would you please test the new version?

If it still does not work, would you please ensure the following flag is set to true? Settings.CheckIfAllTextGlyphsAreAvailable

flier268 commented 3 months ago

Default font Version: 2024.7.1

FROM mcr.microsoft.com/dotnet/aspnet:8.0
ENV TZ=Asia/Taipei
ARG BASE_HREF
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /app
COPY publish .

ENTRYPOINT ["dotnet", "Server.dll"]
2024-08-02 02:10:13 fail: Microsoft.AspNetCore.Server.Kestrel[13]
2024-08-02 02:10:13       Connection id "0HN5IAKKC7M19", Request id "0HN5IAKKC7M19:00000001": An unhandled exception was thrown by the application.
2024-08-02 02:10:13       QuestPDF.Drawing.Exceptions.DocumentDrawingException: Could not find an appropriate font fallback for the following glyphs: 
2024-08-02 02:10:13       $U-4E2D 'δΈ­' 
2024-08-02 02:10:13       
2024-08-02 02:10:13       Possible solutions: 
2024-08-02 02:10:13       1) Install fonts that contain missing glyphs in your runtime environment. 
2024-08-02 02:10:13       2) Configure the fallback TextStyle using the 'TextStyle.FontFamilyFallback' method. 
2024-08-02 02:10:13       3) Register additional application specific fonts using the 'FontManager.RegisterFont' method. 
2024-08-02 02:10:13       
2024-08-02 02:10:13       You can disable this check by setting the 'Settings.CheckIfAllTextGlyphsAreAvailable' option to 'false'. 
2024-08-02 02:10:13       However, this may result with text glyphs being incorrectly rendered without any warning.
2024-08-02 02:10:13          at QuestPDF.Elements.Text.TextBlock.CheckUnresolvedGlyphs()
2024-08-02 02:10:13          at QuestPDF.Elements.Text.TextBlock.CalculateParagraphMetrics(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Elements.Text.TextBlock.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Elements.Row.PlanLayout(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Elements.Row.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Drawing.Proxy.SnapshotRecorder.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Elements.Decoration.<PlanLayout>g__GetDecorationMeasurement|20_0(Element element, <>c__DisplayClass20_0&)
2024-08-02 02:10:13          at QuestPDF.Elements.Decoration.PlanLayout(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Elements.Decoration.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Elements.Padding.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Elements.Constrained.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Elements.Layers.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Infrastructure.ContainerElement.Measure(Size availableSpace)
2024-08-02 02:10:13          at QuestPDF.Drawing.DocumentGenerator.RenderPass[TCanvas](PageContext pageContext, TCanvas canvas, ContainerElement content)
2024-08-02 02:10:13          at QuestPDF.Drawing.DocumentGenerator.RenderSingleDocument[TCanvas](TCanvas canvas, IDocument document, DocumentSettings settings)
2024-08-02 02:10:13          at QuestPDF.Drawing.DocumentGenerator.RenderDocument[TCanvas](TCanvas canvas, IDocument document, DocumentSettings settings)
2024-08-02 02:10:13          at QuestPDF.Drawing.DocumentGenerator.GeneratePdf(SkWriteStream stream, IDocument document)
2024-08-02 02:10:13          at QuestPDF.Fluent.GenerateExtensions.GeneratePdf(IDocument document)
2024-08-02 02:10:13          at QuestPDF.Fluent.GenerateExtensions.GeneratePdf(IDocument document, Stream stream)
MarcinZiabek commented 3 months ago

The default font in QuestPDF does not contain Japanese characters. Please include additional fallback fonts within your application and add Fallback configuration within the TextStyle object πŸ˜„

NelsonSantos commented 1 month ago

Hi @MarcinZiabek...

Sorry for delay, but the BUG in question has been solved.

So, It's could be closed.

Thanks for that!

Best regards!

Nelson