.NET Core 2 adding image to paragraph fails on macOS


#1

Hi,
The code that I use to add an image in a pdf document raises an exception when I run it under MacOS.
“Invalid image stream (The type initializer for ‘Gdip’ threw an exception.)”

I’ve created a sample project with VisualStudio for Mac that illustrates the problem.
Please clone this repo https://github.com/ntodorov/aspose_example
Rebuild and run.

What should I change?

=== Visual Studio Community 2017 for Mac ===

Version 7.5.3 (build 7)
Installation UUID: 0c6c30a2-1c1b-4e74-8fef-d07a14dfc864
Runtime:
Mono 5.10.1.47 (2017-12/8eb8f7d5e74) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)

Package version: 510010047

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.0.5
2.0.0
SDK: /usr/local/share/dotnet/sdk/2.1.4/Sdks
SDK Versions:
2.1.4
2.0.0
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.10.1/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.1
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 9.4.1 (14161)
Build 9F2000

=== Xamarin.Mac ===

Version: 4.2.1.29 (Visual Studio Community)

=== Xamarin.iOS ===

Xamarin.iOS not installed.
Can’t find mtouch or the Version file at /Library/Frameworks/Xamarin.iOS.framework/Versions/Current.

=== Xamarin.Android ===

Not Installed

=== Xamarin Inspector ===

Version: 1.4.0
Hash: b3f92f9
Branch: master
Build date: Fri, 19 Jan 2018 22:00:34 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 705030007
Git revision: 13cecd02aceddf29a1ed57b86f81c02994df1483
Build date: 2018-06-14 15:48:08-04
Xamarin addins: 7065de97cf22c9038fdc39dd627f2c30790fd8af
Build lane: monodevelop-lion-d15-7

=== Operating System ===

Mac OS X 10.13.5
Darwin 17.6.0 Darwin Kernel Version 17.6.0
Tue May 8 15:22:16 PDT 2018
root:xnu-4570.61.1~1/RELEASE_X86_64 x86_64


#2

@niktv

Thanks for contacting support.

We are constantly working over improving the .NET Core support in our API. However, there are some operations which we recommend in order to avoid such issue that you are facing. Would you please try your scenario again after installing libgdiplus package and Microsoft Core Fonts in your device. In case you still face any issue, please let us know. We will further proceed to help you out.


#3

My understanding is that ligdgiplus is installed with the Mono project, I saw it on the installation list when i reinstalled Mono. If you give me steps to verify that I will do it and report back.
Microsoft Core fonts - for macOs i’ve googled that they are there, and potentially updated with the installation of MS Office for MacOs and I have that too. Again if you give me steps to verify installation I will do that and report it.


#4

@niktv

Thanks for your feedback.

We have logged an investigation ticket as PDFNET-45054 in our issue tracking system. We will further investigate the scenario and in case of any further progress and update, we will surely inform your within this forum thread. Please be patient and spare us little time.

We are sorry for the inconvenience.


#5

Any news about this issue?

I also saw it when trying very simple AWS Lambda (serverless) function that uses aspose.pdf .net and tries to add image to the pdf.
Do you want me to create another request for that situation?

P.S. Friendly advise: Generating pdfs with AWS Lambda functions is a powerfull option and if I cannot use Aspose for that I will need to find other solution. Many other developers will need it soon too. Fixing the issue sooner will help us stay with Aspose.


#6

@niktv

Thanks for your inquiry.

I am afraid earlier logged issue is still pending due to previously logged issues in the queue.

We have logged your concerns and details along with already logged issue and will definitely consider them while investigating the issue. As soon as we have some definite updates regarding resolution of the issue, we will surely inform you. Please spare us little time.

We are sorry for the inconvenience.


#7

@niktv

We have further investigated the logged ticket with latest version of the API and could not replicate the issue. Please check following steps which we performed before testing the scenario with Aspose.PDF for .NET 18.9:

Environment and Setup

macOS 10.13.6 (17G65)
Visual Studio for Mac (Community) v 7.6.7 (build 49)
NETCORE 2.0
MONO 5.12.0

Manually installed Windows fonts
Important: Arial.ttf (Please also install other fonts as well.)

Manually installed gdiplus from console
"brew install mono-libgdiplus"

Recommendations:

Please install the font Arial.ttf, reinstall gdiplus.dll, update the version of MONO framework, and latest version of Apose.PDF for .NET.

In case you still face any issue, please feel free to let us know.