I am working on project to convert .mpp file to pdf with Aspose.Tasks version 23.11.0. When I set a default font while converting .mpp file to pdf but I get following error on linux os(It works OK with Windows OS):
“aspose.tasks.TasksRenderingException: Cannot find fallback font ‘Generic Sans Serif’. Please check that the system font folders or font folders specified in FontSettings contain True Type font files.”
code I am using is:
Project project = new Project("TestFile.mpp");
com.aspose.tasks.PdfSaveOptions pdfOptions = new com.aspose.tasks.PdfSaveOptions();
FontSettings fontSettings = pdfOptions.getFontSettings();
fontSettings.setUseProjectDefaultFont(false);
fontSettings.setDefaultFontName(defaultFontName);
project.save("TestFilePDF.pdf", pdfOptions);
Even after setting default font, I get above error, didn’t get what is going wrong.
Documentation I referred is:
FontSettings
@aakanksha76 ,
can you ensure that Generic Sans Serif
font is installed in your Linux OS ?
By default Aspose.Tasks scans the following folders for the fonts:
/usr/share/fonts
/usr/share/fonts/truetype/msttcorefonts
/usr/share/fonts/msttcore
~/.fonts
"/usr/local/share/fonts
/Library/Fonts
/System/Library/Fonts
/System/Library/Fonts/Supplemental
/System Folder/Fonts
Generic Sans Serif font is not installed on Linux OS and that’s why I am setting Default Font to another font called “liberation mono” which is present on Linux OS through,
String defaultFontName = "Liberation Mono";
fontSettings.setDefaultFontName(defaultFontName);
which it should use this default font instead of “Generic Sans Serif” as written in documentation for fontSettings.setDefaultFontName(),
but somehow it is not working…
@aakanksha76 ,
did you set the license or try to execute the code in evaluation mode?
@vasiliy.sinitsyn
Yes, I have set the aspose total license and executed code.
Previously I had used below code to set Default Font which was working,
Project project = new Project("TestFile.mpp");
com.aspose.tasks.PdfSaveOptions pdfOptions = new com.aspose.tasks.PdfSaveOptions();
pdfOptions.setUseProjectDefaultFont(false);
pdfOptions.setDefaultFontName(defaultFont);
project.save("TestFilePDF.pdf", pdfOptions);
but now,
pdfOptions.setUseProjectDefaultFont(boolean value);
pdfOptions.setDefaultFontName(String);
are deprecated, so I was using FontSettings to achieve same but it seems to not work.
@aakanksha76
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): TASKSNET-11120
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@aakanksha76 ,
can you attach your .MPP file and the resulting PDF file (exported in Windows OS) ?
Uploaded the .mpp file here for you reference.
TestFile.zip (117.6 KB)
Please note, we use Java for our project.
@aakanksha76 ,
can you execute fc-list on your Linux OS and attach the output ?
Sure,
here is the output file,
fc-list_output.zip (4.2 KB)
@vasiliy.sinitsyn
Hello,
Any update on this ticket?
@aakanksha76 ,
yes, we cannot reproduce the issue on our end.
Could you try the same scenario on the latest version (24.2) ?
As a temporary workaround you can install ‘Arial’ or ‘Generic Sans Serif’ fonts in your Linux OS.
@aakanksha76 ,
also FontResolveCallback can be used to replace unresolved fonts:
Project project = new Project("TestFile.mpp");
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.getFontSettings().setFontResolveCallback(new FontResolveCallbackDelegate() {
@Override
public void invoke(FontResolveEventArgs e) {
// if font is unresolved, set the font to "Liberation Mono"
if (e.getResolvedFontName() == null) {
e.setResolvedFontName("Liberation Mono");
}
}});
project.save("output.pdf", saveOptions);
Hi @vasiliy.sinitsyn
Upgrading to latest version (24.2) has solved the issue.
Thank you for your support!