thank you @sergei.shibanov. We are using .net 6
@asokratous
I wrote a project with a Xunit test using the code you provided. In my VirtualBox 7.0.8 under Ubuntu 22.04 it works without exceptions. I am attaching a link so that you can download the project and try it with you.
The project uses the Aspose.Pdf.Drawing library 23.07
On Ubuntu, I installed the libgdiplus package with the commands
sudo apt update
sudo apt install libgdiplus
and package with Microsoft compatible fonts
sudo apt-get install ttf-mscorefonts-installer
I suggest trying to run the attached project in your environment.