HiQPdf Cannot get the executing assembly directory

1.2k Views Asked by At

When I try to convert html to PDF using HiQPdf on Linux (on Windows works ok) I get this error:

Something went wrong: System.Exception: Cannot get the executing assembly directory. Empty directory
   at hiqpdfimpl.ᤤ..ctor(ᤣ A_0)
   at HiQPdf.HtmlToImage.ᜀ(String A_0, String A_1, String A_2, ᣩ& A_3, Hashtable& A_4)
   at HiQPdf.HtmlToPdf.ᜀ(String A_0, String A_1, String A_2, String A_3, Boolean A_4)
   at HiQPdf.HtmlToPdf.ᜀ(Stream A_0, String A_1, String A_2, String A_3, String A_4, Boolean A_5)
   at HiQPdf.HtmlToPdf.ᜁ(String A_0, String A_1, String A_2, String A_3, Boolean A_4)
   at HiQPdf.HtmlToPdf.ConvertHtmlToMemory(String html, String baseUrl)
1

There are 1 best solutions below

1
Tropin Alexey On

Now it's working on Linux starting from .NET Core. First of all you must get rid of System.Drawing.Common in your code because now it's only supported on Windows. You can use ImageSharp, SkiaSharp or Microsoft.Maui.Graphics instead. All of them are cross-platform.

Then, install libgdiplus.

On ubuntu: sudo apt-get install -y libgdiplus

On macOs (homebrew must be installed in your system): brew install mono-libgdiplus

Restart Nginx server: sudo systemctl restart nginx

If the problem is still there, open terminal in project folder and make

nuget restore <Your-project-or.sln>