We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Mono issues on ubuntu (pdf/equations)


We are trialing Aspose.Cells for .NET before we buy it and I wanted to ask about a couple of issues we are seeing on mono. We are running mono 3.2.7 on Ubuntu 12.04

1. Saving as pdf takes a really long time on mono. On Windows/.NET, it takes about 1 second to generate the pdf from xlsx, but on Ubuntu/mono it takes about 3 minutes, using the same code. Is there something we can do to speed it up? We are using workbook.Save(path, SaveFormat.Pdf)

2. Equations don’t seem to come through properly on ubuntu/mono. The attachment json-test-1.xlsx has a simple equation and nothing else, but when we open the workbook and re-save it using Aspose.Cells, the equation comes through mangled. See the equation.png attachment

3. The equation doesn’t show up when saving as pdf on ubuntu/mono. Is there something special I need to do? See attachment json_test_1__output.pdf

Thanks for your help!

Hi William,

Thank you for considering Aspose products, and welcome to Aspose.Cells support forum.

Your mentioned issues 1) & 2) seems to be related to the availability of fonts on the machine where conversion is taking place. Please note, while converting the spreadsheets to PDF format the most important factor is the availability of the fonts used in the spreadsheet. Aspose.Cells API first tries to find the exact fonts on the machine, in case it does not find the required fonts, the API will try to substitute the fonts with any other available font.

Based on the discussion as above, we would also suggest you to explicitly set the fonts directory at the start of your application. Please use CellsHelper.FontDir property to tell the API where to look for the TrueType (TTF) fonts.

Regarding the issue 3), we have evaluated your presented scenario on Windows platform while using Aspose.Cells for .NET 8.0.0, and are able to replicate the problem on missing equation in the resultant PDF file. In order to further investigate the matter, a ticket has been logged in our bug tracking system under Id CELLSNET-42528. Please spare us little time to properly analyze the problem cause, and to provide a fix if applicable. In the meanwhile, we will keep you posted with updates in this regard.
  1. Babar, thank you for your reply. I tried setting the FontDirs:

    CellsHelper.FontDirs = new ArrayList()

    And I installed ttf-mscorefonts-installer to make sure that the Arial was available (it gets installed to /usr/share/fonts). But saving as pdf is still extremely slow. I even trimmed down the document we were generating to just text and no charts and it takes almost two minutes to save as pdf on ubuntu/mono where it is under a second on Windows/.NET.

    Do you have any other suggestions to improve the speed?

    2) It doesn’t appear that you can change the font in the Equation Editor in Excel to anything other than Cambria Math, which is limited to Windows only. Do you have any other suggestions on what to do here?

    3) Thank you, please let us know.

Hi William,

Thank you for writing back, and sorry for a bit delayed response.

Please find below the answers to your questions,

1) It is suggested that you should set only one font directly (containing required TTF fonts) in order to improve the overall performance. Providing several font directories to the Aspose.Cells APIs may increase the execution time as the API has to look for fonts on many places. Moreover, the statement CellsHelper.FontDir should be at the start of the application before invoking any other objects of Aspose.Cells API.

Attached to my post is an archive containing the TTF fonts from the Linux environment. Please extract them to any directory and point the CellsHelper.FontDir property to it. Please also download and use the latest version of Aspose.Cells for .NET for your testing. Hopefully it will improve the performance up to your expectations.

2) I am afraid, I may not be able to comment on the problem related to the equations not rendering in the resultant PDF at the moment. Reason being, we are able to observe the same issue on Windows platform as well, and currently the investigation is pending for the relevant ticket. As soon as we analyze the issue, we will be in a better position to assist you in this regard.

Thank you, Babar. Upgrading to Aspose.Cells for .NET fixed the performance issue. I didn’t realize I was using an older version. Using a single or multiple directories for the font lookups doesn’t seem to make a noticeable performance difference.

Unfortunately even with the font pack that you attached, the equations are still coming out mangled like from the image in the original post.

One other note: generation of pdf’s very frequently crashes mono with the following error:


Native stacktrace:

/opt/monodevelop/bin/mono() [0x4ab6ed]
/opt/monodevelop/bin/mono() [0x501cef]
/opt/monodevelop/bin/mono() [0x420367]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xfcb0) [0x7fd4e78b1cb0]
/lib/x86_64-linux-gnu/libc.so.6(fclose+0x2d) [0x7fd4e75506ed]
/opt/monodevelop/lib/libgdiplus.so(+0x2cd65) [0x7fd4a3349d65]
/opt/monodevelop/lib/libgdiplus.so(GdipDeleteGraphics+0x12f) [0x7fd4a33322bf]

Debug info from gdb:

Could not attach to process. If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
No threads.

Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.

Do you know how I can avoid this error?


Additional information about the crash (see screenshot):

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at ..Ž• (Aspose.Cells.Charts.Chart ) [0x00000] in :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
at ..Ž• (Aspose.Cells.Charts.Chart ) [0x00000] in :0


Further information: on mono 3.2.4, the crash is occasional, but on mono 3.2.7, which is the latest and the one we have to use in production because of a separate bug fix, the crash happens every time. One thing to note is that we have our own custom build of mono 3.2.7. If Aspose.Cells requires additional dependencies, please let me know so we can build them into our mono install.

**edit, this error is very frequent
edit2: add more crash information
edit3: add mono version information

Hi William,

I am sorry to know of your troubles. We are currently preparing environment (Ubuntu 12.04.x with mono 3.2.7) to evaluate your recently shared issue related to the System.NullReferenceException. In the meanwhile, could you please confirm if you are seeing the same problem with every spreadsheet of yours? Moreover, we will require to review a few problematic samples therefore it is requested to provide the spreadsheets triggering the said exception along with your code snippets, so we could try replicating the issue on our end in order to log appropriate tickets for correction purposes.

Hello Babar,

First of all, I am happy to report that we have purchased your product and we appreciate your continued support on this issue.

This happens on spreadsheets that have charts and does NOT happen on spreadsheets that do not have charts. Please note that we run Ubuntu 12.0.4 64 bit and mono 3.2.7 64 bit.

Here is some sample code to cause the error:

var path = @"/home/ubuntu/Downloads/Tear_Sheet_values.xlsx";
var workbookChart = new Workbook(path);
var newPath = @"/home/ubuntu/Downloads/Tear_Sheet_values.pdf";
workbookChart.Save(newPath, SaveFormat.Pdf);

I have attached the Tear_Sheet_values.xlsx to aid in your debugging. Thank you again for the help.

Hi William,

Good to know that you got on board with us, and thank you for providing the sample spreadsheet & code snippets for our testing. You have to spare us little time so we could thoroughly evaluate the problem after simulating your environment on our end. We will keep you posted with updates in this regard.

Thank you for your patience and understanding.

Hi William,

Thank you for your patience.

We are able to replicate the NullRefrenceException while using your provided spreadsheet against the latest version of Aspose.Cells for .NET 8.0.0 on Ubuntu 12.04.3; MonoDevelop; Mono (Debian (64-bit). In order to further investigate the problem cause, and to provide a fix, we have logged this problem in our bug tracking system under Id CELLSNET-42539.

As soon as we get some updates regarding the aforesaid ticket, we will post here for your kind reference.

Thank you, Babar. Please keep me updated on the status. The crashing bug is much more important to us than the equation editor bug, if that is important for you to know. Also, as I indicated above, we are using Mono 3.2.7, but if you fix the crash on Mono, I can try the fix out on the version of mono that we are using.

Hi William,

I am afraid, the ticket logged earlier as CELLSNET-42539 is currently pending for analysis, and is in the queue with other tasks. I have requested the concerned development team member to schedule the ticket for investigation at earliest. As soon as we receive some news in this regard, we will post here for your kind reference.

Thank you Babar. Pdf exporting will be a very important feature for us so we appreciate the help.

Hello, Babar. Do you have an update on this issue?

Hi William,

I am afraid, we haven’t yet received any updates regarding the tickets attached to this thread. We have requested the development team to share their valuable feedback on both tickets, and we will post here as soon as some news comes in.

We are sorry for the inconvenience caused.

Hello Babar, do you have any valuable feedback from the development team that you have received over the past week since your last post here?

Hi William,

I am afraid, we haven’t yet received any updates regarding the both tickets attached to this thread. I have now elevated the priority of the tickets to the highest value possible, and have recorded notes stating the severity of the problems. We will shortly respond back with more details in this regard.

Please accept our apologies for the inconvenience caused.

Thank you, Babar. Please keep me updated.

Hi William,

We have got updates regarding the tickets attached to this thread. Please check the comments as follow,

  • CELLSNET-42528: Unfortunately, the current implementation of Aspose.Cells APIs do not support math equations as they are in your provided sample (json-test-1.xlsx). This is actually a new feature request that we may consider implementing in the future releases, but we first need to analyze it properly in order to bring it on our road map of Aspose.Cells APIs. Therefore we can not commit any timelines at the moment although the ticket is still open for further investigation.
  • CELLSNET-42539: The exception stated in this ticket is due to the reason that Aspose.Cells APIs converts the spreadsheets, charts and shapes to EMF format, and inject these EMF images into the resultant PDF. On the other hand, Mono does not support creation of EMF files as we have researched it. You can workaround this situation by specifying the ImageFormat for the object of PdfSaveOptions while converting the spreadsheets to PDF format. Please check the below provided code snippet that we have tested against Mono versions 3.2.6 & 3.2.8 with MonoDevelop 4.0.12 and the latest version of Aspose.Cells for .NET


var file = “/home/babar/Downloads/Tear_Sheet_values.xlsx”;
Workbook book = new Workbook(file);
Console.WriteLine(“Spreadsheet Loaded!”);

PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.ImageType = System.Drawing.Imaging.ImageFormat.Png;
book.Save("/home/babar/Downloads/output.pdf", pdfSaveOptions);

Console.WriteLine(“Spreadsheet Converted!”);

Please note, the above code snippet requires reference of System.Drawing namespace in the project, whereas the aforesaid namespace is present in libgdiplus library that installs automatically with the installation of MonoDevelop application. In case you do not find this library in your environment, you can get it from the below provided link.

If you wish to make sure that Mono does not provide support for EMF creation on your end, please give the below provided code snippet a try on your end. The probable outcome is either a GDI+ exception or a zero sized EMF file.

System.IO.FileStream fs = new System.IO.FileStream(@"/home/babar/Downloads/test.emf", System.IO.FileMode.Create);
System.Drawing.Bitmap dummyBitmap = null; System.Drawing.Graphics dummyGfx = null; IntPtr hdc = IntPtr.Zero; System.Drawing.Imaging.Metafile metafile = null;
try { // Below code is needed to create a .NET Graphics object that can record a metafile. dummyBitmap = new System.Drawing.Bitmap(1, 1); dummyGfx = System.Drawing.Graphics.FromImage(dummyBitmap);
hdc = dummyGfx.GetHdc();

int mWidth = 200; int mHeight = 200;
metafile = new System.Drawing.Imaging.Metafile(fs, hdc, new System.Drawing.RectangleF(0, 0, mWidth, mHeight), System.Drawing.Imaging.MetafileFrameUnit.Pixel, System.Drawing.Imaging.EmfType.EmfPlusDual);
System.Drawing.Graphics mGr = System.Drawing.Graphics.FromImage(metafile); // Use FillRectangle instead of Clear because Clear does nto seem to work for metafiles. // FillRectangle also establishes good page boundaries for the metafile.
mGr.FillRectangle(new System.Drawing.SolidBrush(Color.Empty), 0, 0, mWidth, mHeight);
//Draws mGr.DrawString(" Test draw text!", new System.Drawing.Font("Arail", 8), new System.Drawing.SolidBrush(System.Drawing.Color.Red), 50, 10); mGr.DrawLine(new System.Drawing.Pen(Color.Blue, 3), 0, 100, 200, 100); mGr.FillRectangle(new System.Drawing.SolidBrush(Color.FromArgb(100, 255, 0, 0)), 50, 50, 100, 100); mGr.Dispose(); } finally { if (metafile != null) metafile.Dispose(); if (hdc != IntPtr.Zero) dummyGfx.ReleaseHdc(hdc); if (dummyGfx != null) dummyGfx.Dispose(); if (dummyBitmap != null) dummyBitmap.Dispose(); }

Please feel free to write back in case you have questions for us.

Hello, Babar. Thank you for your reply.

I would like to report that the latest version of Aspose.Cells that you gave me (version crashes mono as soon as Aspose.Cells.dll is loaded. I am still using the same environment (mono 3.2.7, ubuntu 12.04). The old version (version only crashed mono when we tried to save a pdf that had charts in it.

I tried to debug this as far as I could, but the crash seemed deep inside of the mono code. I used gdb to help, so maybe this will give you a clue when the crash occurs:

* Assertion: should not be reached at tramp-amd64.c:405

Program received signal SIGABRT, Aborted.
0x00007ffff712b425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) backtrace
#0 0x00007ffff712b425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff712eb8b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x000000000062f2cd in monoeg_g_logv (log_domain=, log_level=G_LOG_LEVEL_ERROR, format=, args=) at goutput.c:175
#3 0x000000000062f406 in monoeg_assertion_message (format=) at goutput.c:195
#4 0x000000000050514d in stack_unaligned (tramp_type=) at tramp-amd64.c:405
#5 0x0000000040003d49 in ?? ()
#6 0x00007ffff658ed60 in ?? ()
#7 0x00000000400c0774 in ?? ()
#8 0x00000000400c0755 in ?? ()
#9 0x00000000400c074c in ?? ()
#10 0x00000000015e8660 in ?? ()
#11 0x00007ffff658f068 in ?? ()
#12 0x0100000000a3b1a0 in ?? ()
#13 0x00007ffff658f068 in ?? ()
#14 0x00007ffff658f000 in ?? ()
#15 0x00000000015e8660 in ?? ()
#16 0x00007ffff658ed38 in ?? ()
#17 0x00007ffff658f000 in ?? ()
#18 0x00007ffff658f000 in ?? ()
#19 0x00007fffed6d8240 in ?? ()
#20 0x00007fffed6d8240 in ?? ()
#21 0x00000000400c0376 in ?? ()
#22 0x00007ffff658efa0 in ?? ()
#23 0x00000000005ae2dd in mono_object_isinst (obj=0x7fffffffd3e8, klass=0x7ffff7fde780) at object.c:5256
#24 0x00000000400223a3 in ?? ()
#25 0x0000000000a3b1a0 in ?? ()
#26 0x00000000400ba0c0 in ?? ()
#27 0x00007fffffffd1a8 in ?? ()
#28 0x00007ffff7fde780 in ?? ()
#29 0x00007ffff658ed38 in ?? ()
#30 0x00007ffff658f000 in ?? ()
#31 0x00007fffffffd268 in ?? ()
#32 0x0000000040142b80 in ?? ()
#33 0x00007ffff658f000 in ?? ()
#34 0x00007ffff658ed38 in ?? ()
#35 0x0000000000000000 in ?? ()

This crash happens every time.

The first code that is run that accesses Aspose.Cells that causes the dll to be loaded is:
Aspose.Cells.License license = new Aspose.Cells.License();

The exact commit we are using to build mono is: https://github.com/mono/mono/tree/1b62dca6cc70df2a017947666619276c84050121

Since this crashes mono every single time when we start up our process, it makes Aspose.Cells completely unusable. Please help me with a fix.