I am trying to convert a docx document to pdf and am having trouble getting the document’s formula to show up correctly in my pdf. I am running Office 2007 and using the “insert” function to insert a document. I create a copy of the word document as well so I can make sure everything is being done correctly. Everything converts well except for the formulas.
I am using Aspose.Words 10.8.0, Aspose.Pdf 3.0.1, and Aspose.Pdf.Kit 4.1.0
Here is the code I am using:
public class pdfCreate
* Main method.
* @param args
* @throws DocumentException
* @throws FileNotFoundException
* @throws IOException
* @throws Exception
public static void main(String args) throws DocumentException, FileNotFoundException, IOException, Exception
pdfCreate test1 = new pdfCreate();
public void testGenerate() throws Exception
Document document = new Document("C:\Users\michael.a.platt.ctr\Desktop\EditTemplate.docx");
Document doc2 = new Document("C:\Users\michael.a.platt.ctr\Desktop\tester.docx");
DocumentBuilder docBuilder = new DocumentBuilder(document);
Table table = new Table(document);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte bytes = bos.toByteArray();
File file = new File("C:\Users\michael.a.platt.ctr\Desktop\test.zip");
FileOutputStream fos = new FileOutputStream(file);
ZipOutputStream out = new ZipOutputStream(fos);
ZipEntry zipAdd = new ZipEntry("EditTemplate2.docx");
bytes = bos.toByteArray();
zipAdd = new ZipEntry("EditTemplate2.pdf");
public static void insertDocument(Node insertAfterNode, Document srcDoc) throws Exception
// Make sure that the node is either a paragraph or table.
if ((insertAfterNode.getNodeType() != NodeType.PARAGRAPH) &
(insertAfterNode.getNodeType() != NodeType.TABLE))
throw new IllegalArgumentException("The destination node should be either a paragraph or table.");
// We will be inserting into the parent of the destination paragraph.
CompositeNode dstStory = insertAfterNode.getParentNode();
// This object will be translating styles and lists during the import.
NodeImporter importer = new NodeImporter(srcDoc, insertAfterNode.getDocument(), ImportFormatMode.KEEP_SOURCE_FORMATTING);
// Loop through all sections in the source document.
for (Section srcSection: srcDoc.getSections())
// Loop through all block level nodes (paragraphs and tables) in the body of the section.
for (Node srcNode: (Iterable) srcSection.getBody())
// Let's skip the node if it is a last empty paragraph in a section.
if (srcNode.getNodeType() == (NodeType.PARAGRAPH))
Paragraph para = (Paragraph) srcNode;
if (para.isEndOfSection() && !para.hasChildNodes())
// This creates a clone of the node, suitable for insertion into the destination document.
Node newNode = importer.importNode(srcNode, true);
// Insert new node after the reference node.
insertAfterNode = newNode;
I have also attached the output documents for viewing.
Thanks for your inquiry.
The problem occurs because Aspose.Words does not support rendering Office Math equations into PDF. This is a known issue. Your request has been linked to the appropriate issue. The issue ID is WORDSNET-4534. You will be notified via this forum thread as soon as this feature is supported.
Sorry for the inconvenience.
I’ve sent Awais Hafeez an email, but I don’t know if thats the correct way to contact you - so I post a message here as well.
Our customer needs support for Office math equations rendering to PDF very bad, so I would like an indication of when we could expect this to be supported - if possible.
Thanks in advance.
Thanks for your request. I am currently working on a code draft of equation rendering. I have some progress, but I think it is too early to push this feature into release. Hopefully, we will provide this feature in beta in the April release. I attached images produced by the current code for equations from your test document.
Thanks for your hard work on this issue. If you need people to test the beta in April my company is willing to implement it and give feedback if we can get a copy of that version of Aspose. Thank you again for the hard work.
Thank you for your cooperation. We will try to resolve this issue on our earliest and let you know once it is resolved.
Thank you for your continued development regarding this issue. It is rather critical to us, but we can’t afford escalating the issue and have you fix it for payment. So we’re eagerly awaiting updates :o)
Is it possible to easily detect if a given word document contains any of the math objects that cant be rendered? If so, how? We could use this to help our customer with a list of affected documents - in order to let them manually handle these until aspose supports the math object rendering.
Thanks for your inquiry. Sure, you can easily detect/retrieve OfficeMath equations by using the following code snippet:
Node equations = doc.GetChildNodes(NodeType.OfficeMath, true).ToArray();
foreach(OfficeMath eq in equations)
// You can perform any operations here (e.g. remove them)
Please let me know if I can be of any further assistance.
Moreover, this issue is in development phase. You will be notified as soon as this feature is supported. We apologize for your inconvenience.
We also have issues with this problem. When will it be ready?
Thanks for your inquiry. Good news for you i.e. WORDSNET-4534 has now been resolved and its fix will be included in the next version of Aspose.Words (v11.3.0) which is planned to be released by the end of this month (April’ 30, 2012). We will inform you via this forum thread as soon as the new release is published.
The issues you have found earlier (filed as WORDSNET-4534) have been fixed in this .NET update and this Java update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.
When will it be released for Aspose.Words for SharePoint?
Thanks for your inquiry. Unfortunately, I am currently in the process of upgrading a few softwares on my machine; so, can’t test this for the time being. Meanwhile, I would suggest you please download the latest version of Aspose.Words for Sharepoint i.e. 2.5.0 from the following link and let us know how it goes on your side:
I hope, this will help.
I have just tested it, and it worked!
It is perfect that the feature works for you. Please let us know if you found some problems with formulas rendering.