we’ve been heavily testing Aspose Java Word for documents to PDF conversion and we found a few documents that cause the underlying Aspose process to stuck.
This happens when we try to instantiate the Document class by providing a certain Word docx document that uses fonts, which have not been previously loaded by FontSettings.
No exception is thrown, Aspose utilizes the CPU at 100% without a possibility to recover.
We mitigate this issue by spinning a new thread for each Document instance. If the conversion process (load document and save it as PDF) does not happen during a certain time period, we kill the thread and the underlying Aspose process with it.
If all fonts are available we haven’t observed this behavior.
The majority of documents with missing fonts will be converted. Either with substituted fonts or with missing characters. However, a few documents have fatal effects.
This is especially concerning because we plan to use Aspose on the server and we cannot guarantee that all documents will contain only available fonts.
Do you have any advice on how to proceed and properly handle this problem?
Our solution with time outing threads seems more like a hack than a proper fix.
@ondrs Could you please attach the problematic documents here for testing and provide a simple code or test application that will allow us to reproduce the problem? We will check the issue and provide you more information.
@ondrs It is safe to attach documents in the forum. Only you as a topic starter and Aspose staff can see the attachments. Also, you can send the files via private message in the forum.
OS is not relevant as the problem occurs in every environment but I am attaching the OS info that we are using in our docker container regardless and for clarity.
@ondrs Unfortunately, I still cannot reproducer the problem on my side. I have used hte following code for testing:
Document doc = new Document("/temp/in.docx");
doc.setWarningCallback(new FontSubstitutionWarningCollector());
doc.save("/temp/out.pdf");
private static class FontSubstitutionWarningCollector implements IWarningCallback {
public void warning(WarningInfo info) {
if (info.getWarningType() == WarningType.FONT_SUBSTITUTION) {
System.out.println(info.getDescription());
}
}
}
I have used the latest 23.6 version of Aspose.Words for Java for testing. Could you please try implementing IWarningCallback as in my example and let us know what warnings you see in the output? Also, please try using the latest version on your side.
2023-07-04 11:42:48,275 [nREPL-session-1bbea322-f963-48d6-910c-aced84c6fe74] WARN [de.doc-converter.convert.aspose] - Import of element 'shapedefaults' is not supported in Docx format by Aspose.Words.
2023-07-04 11:42:48,792 [nREPL-session-1bbea322-f963-48d6-910c-aced84c6fe74] WARN [de.doc-converter.convert.aspose] - Import of element 'extraClrSchemeLst' is not supported in Docx format by Aspose.Words.
2023-07-04 11:42:51,043 [nREPL-session-1bbea322-f963-48d6-910c-aced84c6fe74] WARN [de.doc-converter.convert.aspose] - Font 'Calibri' has not been found. Using 'Liberation Sans' font instead. Reason: table substitution.
2023-07-04 11:42:51,314 [nREPL-session-1bbea322-f963-48d6-910c-aced84c6fe74] WARN [de.doc-converter.convert.aspose] - Font 'Calibri Light' has not been found. Using 'DejaVu Sans' font instead. Reason: font info substitution.
And the output from top
top - 11:46:16 up 10 min, 0 users, load average: 1.51, 1.22, 0.62
Tasks: 3 total, 1 running, 2 sleeping, 0 stopped, 0 zombie
%Cpu(s): 16.8 us, 0.1 sy, 0.0 ni, 83.2 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 11234332 total, 4118068 free, 2186700 used, 4929564 buff/cache
KiB Swap: 1048572 total, 1045220 free, 3352 used. 8380688 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 de 20 0 5920644 1.3g 31436 S 99.7 12.3 4:53.01 java
116 de 20 0 11844 2772 2536 S 0.0 0.0 0:00.00 sh
122 de 20 0 56216 3732 3204 R 0.0 0.0 0:00.00 top
@ondrs Thank you for additional information. Could you please also attach the following fonts from your environment, where the problem is reproducible:
‘Liberation Sans’
‘DejaVu Sans’
Also, have you tried running the same conversion using the latest 23.6 version of Aspose.Words for Java. If your license does not allow to update to the latest version, you can request a free 30-days temporary license for testing.
I haven’t tried the latest version yet. It would take some time for us to update.
If possible, I would like to first try to identify and verify the problem with version 22.4.
Is it possible for you to replicate it?
Have you noticed a similar bug before?
@ondrs The problem is reproducible with 22.4 version. I have checked with other versions and the problem does not occur starting from 22.7 version. According to release notes there were fixed several issues with hanging upon building document layout. So I would suggest you to update to the newer version of Aspose.Words.