Hello,
I am using Aspose.slides 25.5 to convert PPT to PDF. I am attempting to convert a PPT that contains a mathematical equation inserted in it to PDF but, the conversion fails with below exception:
Blockquotecom.aspose.slides.exceptions.ArgumentException: The required font “Cambria Math” was not found.
at com.aspose.slides.kxh.nq(Unknown Source)
at com.aspose.slides.kxh.nq(Unknown Source)
at com.aspose.slides.kxh.nq(Unknown Source)
at com.aspose.slides.ta2.tu(Unknown Source)
at com.aspose.slides.gxw.nq(Unknown Source)
at com.aspose.slides.gxw.ul(Unknown Source)
at com.aspose.slides.rfc.nq(Unknown Source)
at com.aspose.slides.rfc.(Unknown Source)
at com.aspose.slides.gj.(Unknown Source)
at com.aspose.slides.gj.nq(Unknown Source)
at com.aspose.slides.yi.nq(Unknown Source)
at com.aspose.slides.sf3.nq(Unknown Source)
at com.aspose.slides.sf3.(Unknown Source)
at com.aspose.slides.f6v.nq(Unknown Source)
at com.aspose.slides.gw9.nq(Unknown Source)
at com.aspose.slides.gw9.tu(Unknown Source)
at com.aspose.slides.gw9.ul(Unknown Source)
at com.aspose.slides.yt3.nq(Unknown Source)
at com.aspose.slides.yt3.y1(Unknown Source)
at com.aspose.slides.Shape.qs(Unknown Source)
at com.aspose.slides.Shape.getFrame(Unknown Source)
at com.aspose.slides.v6.tu(Unknown Source)
at com.aspose.slides.v6.nq(Unknown Source)
at com.aspose.slides.wbk.tu(Unknown Source)
at com.aspose.slides.wbk.nq(Unknown Source)
at com.aspose.slides.wbk.nq(Unknown Source)
at com.aspose.slides.wbk.nq(Unknown Source)
at com.aspose.slides.Slide.nq(Unknown Source)
at com.aspose.slides.Slide.ul(Unknown Source)
at com.aspose.slides.Slide.getImage(Unknown Source)
Please find the example PPT here:
I am using RockyLinus OS where CambriaMath font is not available, so I have added a substitution rule in the java code to substitute Cambria Math font to STIX Two Math font which is available on the machine.
EquationInPPT.zip (47.2 KB)
@aakanksha76,
Thank you for reporting the issue. I have reproduced the problem where the ArgumentException occurs when converting the presentation to PDF while the font substitution rule is used. We apologize for any inconvenience caused.
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): SLIDESJAVA-39778
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,
Unfortunately, replacing the Cambria Math font doesn’t work. Since all calculations are based on data obtained using the Cambria Math font, replacing it with a different font won’t help.
If you are unable to use the Cambria Math font, we can only offer the option of removing all math-related text when converting the presentation to PDF, because without the Cambria Math font we cannot display this text.
Presentation presentation = new Presentation("EquationInPPT.pptx");
for (ISlide slide : presentation.getSlides()) {
for (IShape shape : slide.getShapes()) {
if (shape instanceof Table) {
Table table = (Table) shape;
for (IRow row : table.getRows()) {
for (ICell cell : row) {
for (IParagraph paragraph : cell.getTextFrame().getParagraphs()) {
for (IPortion port : paragraph.getPortions()) {
if (port instanceof MathPortion) {
((MathPortion) port).getMathParagraph().clear();
break;
}
}
}
}
}
}
}
}
Hello,
Since you mentioned that the Cambria Math font cannot be replaced by another font, I attempted to embed it in the PowerPoint file before conversion. However, I observed that parts of the math equations were replaced by empty spaces in the resulting PDF, which is not the desired behavior.
Please find the example ppt with with embedded font and its generated pdf here:
CambriaMath.zip (4.4 MB)
Can you please check and help me generate a correct pdf in this case?
@aakanksha76,
Thank you for the sample presentation file. I have reproduced the problem where the parts of the math equations are replaced with empty spaces when converting the presentation to PDF.
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): SLIDESJAVA-39781
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.
Hello,
Any update on this issue?
Is it fixed in the latest Aspose.Slides version?
@aakanksha76,
The issue SLIDESJAVA-39781 has been resolved. A fix will be included in Aspose.Slides for Java 26.3, which will be published in the second half of March.
@andrey.potapov
Thank you for the update.
@aakanksha76,
Thank you for helping make Aspose.Slides better.