Aspose PDF 错误:“Gdip”在 Mac OSX 上使用 Dotnet Core 3.x 应用程序引发异常

duy*_*yen 3 aspose.pdf .net-core

我正在 Mac (Catalina) 上运行 Dotnet 核心应用程序 (3.1),并且我\xe2\x80\x99m 尝试通过本教程使用 Aspose PDF 将图像添加到 PDF: https: //docs.aspose.com/pdf /net/manipulate-images/ .

\n

尝试添加 imageStream 时出现错误。

\n
\n

“图像流无效(\xe2\x80\x98Gdip\xe2\x80\x99 的类型初始值设定项引发\n异常。)\xe2\x80\x99。

\n
\n
var logoFile = "logo.jpg";\nFileStream imageStream = new FileStream(logoFile, FileMode.Open, FileAccess.Read);\npage.Resources.Images.Add(imageStream); //Error on this line\n
Run Code Online (Sandbox Code Playgroud)\n

经过我的研究,这似乎与需要libgdiplus库有关。我安装了这个,brew install mono-libgdiplus但仍然收到此错误。

\n

可以复制该问题的示例项目:https://github.com/duyn9uyen/aspose-add-image-to-pdf

\n

Aspose.Pdf:版本=\xe2\x80\x9c20.3.0\xe2\x80\x9d。

\n

有人可以帮忙吗?

\n

duy*_*yen 11

  1. 需要安装libgdiplus. https://learn.microsoft.com/en-us/dotnet/core/install/macos

    brew update 
    brew install mono-libgdiplus
    
    Run Code Online (Sandbox Code Playgroud)
  2. 需要CoreCompat.System.Drawinghttps://github.com/CoreCompat/CoreCompatdotnet安装。在您runtime.osx.10.10-x64.CoreCompat.System.Drawing --version 5.8.64的 . csproj文件。

    <PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="5.8.64" />
    
    Run Code Online (Sandbox Code Playgroud)