从PHP转换DOCX到PDF [重复]

问题描述:

This question already has an answer here:

Hi this is my first post here.

I have trouble in converting a docx file to pdf from PHP. I am using PHPDOCX to convert the docx to xhtml and then pass the XHTML to TCPDF to generate the PDF. But I am losing a lot of formatting.

So I guess the above method is pointless.

Is there any free libraries that converts docx to pdf on the fly from PHP?

</div>

此问题已经存在 这里有一个答案: p>

  • 使用PHP将docx转换为pdf 4 answers span> \ n li> ul> div>

    这是我在这里的第一篇文章。 p>

    我遇到了麻烦 将docx文件从PHP转换为pdf。 我正在使用PHPDOCX将docx转换为xhtml,然后将XHTML传递给TCPDF以生成PDF。 但是我失去了很多格式化。 p>

    所以我猜上面的方法毫无意义。 p>

    是否有任何将docx转换为pdf的免费库 从PHP飞? p> div>

you can go through the fallowing link,there we have phpdocx library.It may help you

www.phpdocx.com

$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
$phpLiveDocx->setUsername('username')
            ->setPassword('password');
$phpLiveDocx->setLocalTemplate('document.doc');
// necessary as of LiveDocx 1.2
$phpLiveDocx->assign('dummyFieldName', 'dummyFieldValue');
$phpLiveDocx->createDocument();
$document = $phpLiveDocx->retrieveDocument('pdf');
file_put_contents('document.pdf', $document);
unset($phpLiveDocx);

Click here To details

Link