I am attempting to convert a XWPFDocument to PDF format and everything except the maths formulas are being exported. I believe this is to do with the convert method in opensagres's PdfConverter class.
When decompiling and attempting to search for the root of the problem, it led me to the visitBodyElements
method in the XWPFDocumentVisitor
class.
protected void visitBodyElements(List<IBodyElement> bodyElements, T container) throws Exception {
if (!this.masterPageManager.isInitialized()) {
this.masterPageManager.initialize();
}
String previousParagraphStyleName = null;
for(int i = 0; i < bodyElements.size(); ++i) {
IBodyElement bodyElement = (IBodyElement)bodyElements.get(i);
switch(bodyElement.getElementType()) {
case PARAGRAPH:
XWPFParagraph paragraph = (XWPFParagraph)bodyElement;
String paragraphStyleName = paragraph.getStyleID();
boolean var10000;
if (paragraphStyleName != null && paragraphStyleName.equals(previousParagraphStyleName)) {
var10000 = true;
} else {
var10000 = false;
}
this.visitParagraph(paragraph, i, container);
break;
case TABLE:
previousParagraphStyleName = null;
this.visitTable((XWPFTable)bodyElement, i, container);
break;
case CONTENTCONTROL:
this.visitSDT((XWPFSDT)bodyElement, i, container);
}
}
}
This method does not contain a case where the bodyElement is a formula and I believe this is why it is not being converted to PDF. However, it that the case? How are Maths formulas being stored in the XWPFDocument
class?