Error when saving as PDF

The code is straight forward but errors on this:

workbook.save(“output.pdf”);

Not being able to look into com.aspose.cells.u33 or com.aspose.cells.z5p to see what the cause is has me stumped. Anyone else encounter this? I’m using aspose-cells-22.5 and this is being ran on a Java 8 JRE on a Linux box.

Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.aspose.cells.u33
at com.aspose.cells.z5p.(Unknown Source)
at com.aspose.cells.z5p.(Unknown Source)
at com.aspose.cells.z3r.a(Unknown Source)
at com.aspose.cells.Shape.am(Unknown Source)
at com.aspose.cells.s13.a(Unknown Source)
at com.aspose.cells.p.a(Unknown Source)
at com.aspose.cells.p.a(Unknown Source)
at com.aspose.cells.p.a(Unknown Source)
at com.aspose.cells.p.b(Unknown Source)
at com.aspose.cells.p.c(Unknown Source)
at com.aspose.cells.p.a(Unknown Source)
at com.aspose.cells.a.b.y1.a(Unknown Source)
at com.aspose.cells.m2v.a(Unknown Source)
at com.aspose.cells.m2v.a(Unknown Source)
at com.aspose.cells.m2v.a(Unknown Source)
at com.aspose.cells.x_j.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at …

@sscare,

Please send us the template file to reproduce the issue so that we can figure the issue out and provide fix if possible.

The problem is that I’m using OpenJDK and a trim flavor of Linux and neither include fonts. For whatever reason, when I removed the image I added to the worksheet the save to PDF works. When I say works, the PDF is exactly what I want and looks good. When I try to add the image I get the above error.

It seems when the worksheet has an image Cells goes berserk when trying to save as a PDF and there are no fonts installed on the system. Quite bizarre that a PNG file needs fonts for a PDF. The xlsx file works fine and the PDF works if I remove the image.

As a workaround I manually installed fonts to the jre lib directory and the PDF works with the image.

@sscare,

It looks like your issue is sorted out now. If you still think it is an issue with Aspose.Cells API and you want us to investigate/evaluate, kindly do zip and attach your template file containing the image. We will look into your issue soon.

Here it is along with these instructions to reproduce:

Unzip CellsErrorExample.zip

open command prompt and naviage to unzipped directory

Do a docker build:

docker build -t cellsexample .

Do a docker run:

docker run --name cellsexample -p 8081:8081 -d cellsexample

Open this url:

http://localhost:8081/example/pdf

Look into the docker console to see the error log. I copied the error I see in error.txtCellsErrorExample.zip (17.1 KB)

@sscare

Picture is a kind of Shape, we do some initializations including initializing fonts for Shape.

Fonts are important, otherwise you will not get the desired output as you see in Micorsoft Excel.

It seems that it is a known issue for OpenJDK: NPE at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264) when using install4j caused by font config missing · Issue #693 · adoptium/temurin-build · GitHub .

Agreed that fonts are important but I tried setting the Cells font folder, font source folder, etc and none of those prevented this error.

Since OpenJDK is becoming more and more prevalent wouldn’t is make sense for the Cells code to catch this error and default to using the fonts that have been set using the Cells api? Use those fonts to allow adding a Picture instead of just erroring out.

There are lots of fonts which users can use in their spreadsheets, so we might not embed fonts in the code. Anyways, we will evaluate it and get back to you soon. In the mean time, you may please make sure at least there should be Arial font in your fonts folder and the folder can be accessed by the application seamlessly (there should be no rights issue).

@sscare,

We have logged a ticket with an id “CELLSJAVA-44774” to investigate your issue in details. We will look into the details of the issue. Once we have an update on it, we will let you know.

The issues you have found earlier (filed as CELLSJAVA-44774) have been fixed in this update. This message was posted using Bugs notification tool by Peyton.Xu