Greetings
We are using Aspose Tasks for Java in version 17.5 (jdk16).
We have the code that looks something like this:
Note: InputStream is just a stream of the empty mpp project
public void convertToImage(InputStream sourceStream, OutputStream targetStream) throws Exception {
Project project = new Project(sourceStream);
project.save(targetStream, createOptions());
}
private SaveOptions createOptions() {
SaveOptions saveOptions = new ImageSaveOptions(SaveFileFormat.PNG);
saveOptions.setView(ProjectView.getDefaultGanttChartView());
saveOptions.setFitContent(true);
saveOptions.setRollUpGanttBars(false);
saveOptions.setDrawNonWorkingTime(true);
saveOptions.setPageSize(PageSize.A4);
saveOptions.setTimescale(Timescale.Days);
return saveOptions;
}
So when we try to save a project as an image we get this exception:
class com.aspose.tasks.private.Exceptions.InvalidOperationException: Cannot find any fonts installed on the system.
com.aspose.tasks.private.ad.i.a(Unknown Source)
com.aspose.tasks.private.ad.i.a(Unknown Source)
com.aspose.tasks.private.ad.i.a(Unknown Source)
com.aspose.tasks.y.a(Unknown Source)
com.aspose.tasks.p$a.(Unknown Source)
com.aspose.tasks.p.(Unknown Source)
com.aspose.tasks.x.(Unknown Source)
com.aspose.tasks.x.(Unknown Source)
com.aspose.tasks.w.n(Unknown Source)
com.aspose.tasks.i.l(Unknown Source)
com.aspose.tasks.m.l(Unknown Source)
com.aspose.tasks.w.l(Unknown Source)
com.aspose.tasks.czs.a(Unknown Source)
com.aspose.tasks.Project.a(Unknown Source)
com.aspose.tasks.Project.save(Unknown Source)
…
So the error says that there are no fonts on the system, but interestingly enough running the code below lists all the fonts installed (so Java ‘sees’ the fonts):
GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
for (String font : e.getAvailableFontFamilyNames()) {
log.debug(font);
}
So my questions are:
- does the Aspose task library need any specific fonts?
- how and where does it look for fonts in the system?
- is there any Java code we could run (on the customer’s production server) to debug what the problem is? (from the given exception it is hard to understand what the problem really is…)