We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Word to pdf content lose with aspose-words 18.11

I use aspose-words 18.11 to convert word to pdf, but some content is lost. Files as attached.

Sc5d904446c57494d81aba4775d1b49d1O.docx (80.6 KB)
test1.pdf (92.0 KB)

My code:

public static byte[] transFile2PDFArray(String fileName, byte[] byt)  {
        try{
            if (fileName.endsWith(PDF)) {
                return byt;
            } else if(fileName.endsWith(DOCX_FILE) || fileName.endsWith(DOC_FILE)) {
                Document document = new Document(new ByteArrayInputStream(byt));
                //保存结果文件
                ByteArrayOutputStream bOut = new ByteArrayOutputStream(byt.length);
                document.save(bOut, SaveFormat.PDF);
                byte[] result = bOut.toByteArray();
                bOut.close();
                return result;
            }
            else{
                LogUtil.error(logger,"file Type cannot support:" +fileName);
                return null;
            }
        }catch(Exception en){
            LogUtil.error(logger,"transFile2PDFArray error");
            return null;
        }

@likeice Thank you for reporting this problem to us. For a sake of correction it has been logged as WORDSNET-23682. We will keep you informed and let you know once it is resolved.

@likeice We have completed analysis of the issue and concluded this is not a bug. The problem occurs because altChank Mhtml inside the document contains -aw-headerfooter-type:header-primary style in root div element. This is Aspose.Words roundtrip style and we can’t avoid reading it. As a workaround you can try either resaving this document to regular Docx with MS Word or remove the mentioned style from Mhtml altChank.