phphtmlpdfdoclivedocx

Can I convert a html page to pdf with htmltodoc and LiveDocx without creating a .doc on server?


I am trying to use the class htmltodoc in order to create a .pdf from an html page with : https://web.archive.org/web/20130728045608/http://www.phpkode.com/source/s/html-to-doc-classes/html-to-doc-classes/html_to_doc.inc.php

And with the library LiveDocx (with Zend) : http://srhwd.com/documentation/moodle/_mail_merge_8php_source.html

without creating a .doc . Here is my code :

$htmltodoc= new HTML_TO_DOC();

$htmltodoc->createDocFromURL("http://www.youtube.com/","google.doc",false);

$mailMerge = new Zend_Service_LiveDocx_MailMerge(
    array (
        'username' => 'xxxxxxx',
        'password' => 'xxxxxxx'
    )
);

$mailMerge->setLocalTemplate($htmltodoc);

//$mailMerge->setLocalTemplate('template.doc'); Normally, template.doc is registered on server

$mailMerge->createDocument();

$document = $mailMerge->retrieveDocument('pdf');

header('Content-disposition: attachment; filename=document.pdf');

header('Content-type: application/pdf');

echo $document;

But it returns:

Error HTTP 500 (Internal Server Error)

Can someone help me please ?


Solution

  • If you want to convert HTML to PDF you could use a PDF lib such as :