Free Support Forum - aspose.com

Issue with aspose-pdf when converting pdf to docx format

Hi,

I am using aspose-pdf-16.11.0 to convert pdf to docx document.

Below is the sample code:

public void generateDocReport() {
try {
// Create license object
com.aspose.pdf.License license = new com.aspose.pdf.License();
// Load the license file into FileStream object
InputStream licence = new FileInputStream(new File(“E://Reports//Aspose.Pdf.lic”));
license.setLicense(licence);

// Load source PDF file
InputStream reportDoc = new FileInputStream(new File(“E://Reports//Assessment Summary.pdf”));
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(reportDoc);

com.aspose.pdf.DocSaveOptions saveOptions = new com.aspose.pdf.DocSaveOptions();
// Set output file format as DOCX
saveOptions.setFormat(com.aspose.pdf.DocSaveOptions.DocFormat.DocX);
// Save resultant DOCX file
pdfDocument.save(“E://Reports//Assessment Summary Docx.docx”, saveOptions);
reportDoc.close();
} catch (Exception e) {
throw new RuntimeException(“Error thrown while generating docx using Aspose.pdf.”
+ e.getLocalizedMessage(), e);
}
}

After running above program “Assessment Summary Docx.docx” file generates successfully. However when I try to open it in MS word then MS Word gives following error in a popup window saying “The Office Open XML file Assessment Summary Docx can not be opened because there are problem with content”. When I click on OK button from error popup then following message appears on a new popup window saying “Word found unreadable content in Assessment Summary Docx. Do you want to recover the contents of this document? If you trust the source of this document, click Yes”. After clicking “Yes” file opens successfully.

Please let me know how I can fix this.

Note: When I generate same file in doc format instead of docx then MS Word does not give any error and opens the file. Here the sample code for doc format generation:

com.aspose.pdf.DocSaveOptions saveOptions = new com.aspose.pdf.DocSaveOptions();
// Set output file format as DOC
saveOptions.setFormat(com.aspose.pdf.DocSaveOptions.DocFormat.Doc);
// Save resultant DOC file
pdfDocument.save(“E://Reports//Assessment Summary Doc.doc”, saveOptions);

I am attaching Assessment Summary.pdf file used as an input for above programs. Also attaching both doc and docx file generated using above programs. MS Word Error popup is also attached.

Please resolve this issue ASAP.

Thanks
Kamal Sethiya


Hi Kamal,


Thanks for your inquriy. I have tested your shared DOCX file with MS Word 2007 and unable to notice the reported issue. We will appreciate it if you please share your MS Word version here, so we will further investigate the issue and will guide you accordingly.

We are sorry for the inconvenience.

Best Regards,

Hi,

I am also using Microsoft Office Word 2007.

FYI: When I open same word doc in MS Word 2010 then it opens directly without giving any error.

Thanks
Kamal Sethiya

Hi Kamal,


Thanks for your feedback. As stated above, I am unable to notice any error/warning while opening resultant DOCX with Microsoft Office Word 2007. We have tested scenario on another machine but still unable to replicate the issue. We will appreciate it if you please share your Microsoft Office Word 2007 version details.

We are sorry for the inconvenience.

Best Regards,

Hi,


I am using is 12.0.4518.1014 version for MS Office 2007.

Thanks
Kamal Sethiya

Hi Kamal,


Thanks for sharing the details. I am using MS Office Word 2007(12.0.6741.5000) SP3. However we have logged an investigation ticket PDFJAVA-36449 in our issue tracking system for further investigation. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience.

Best Regards,