当我试图使用Linux上的HiQPdf (在上)将html转换为PDF时,我得到了以下错误:
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)发布于 2022-07-07 11:13:50
现在,它正在从.NET核心开始在Linux上工作。首先,您必须在代码中去掉System.Drawing.Common,因为现在是它只在Windows上支持。您可以使用ImageSharp、SkiaSharp或Microsoft.Maui.Graphics代替。他们都是跨平台的。
然后,安装libgdiplus。
On ubuntu:sudo apt-get install -y libgdiplus
On (必须在您的系统中安装自制):brew install mono-libgdiplus
重新启动Nginx服务器:sudo systemctl restart nginx
如果问题仍然存在,请在“项目”文件夹中打开终端,并使
nuget restore <Your-project-or.sln>
https://stackoverflow.com/questions/60266924
复制相似问题