Hi
i have an html output and send to the folder using ob_start and
file_put_contents('xxx.html', ob_get_contents());
my problem is
save automatically this file after converting to pdf using html2pdf
is it possible to do that:auto save the html to pdf using html2pdf
cheers

Hi
really it is not working

$output = ob_get_clean();
   echo $output; 

//mail($email,"Monthly Report send from my scheduler ahmed for:". $surname,"<html><body>$output</body></html>","MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n"); 
file_put_contents('monthly.html', ob_get_contents());

require_once(dirname(__FILE__).'/../html2pdf.class.php');
    try {
        $html2pdf = new HTML2PDF();     // you can use the default parms
        $html2pdf->setDefaultFont('Arial');
        $html2pdf->writeHTML($output);
        //$html2pdf->Output('monthly.pdf');
            //$pdf->Output('../css2/monthly.pdf','D');
               $pdf->Output('/xampp/htdocs/campion/css2/monthly.pdf','F');

              //$html2pdf->Output('C:/xampp/htdocs/campion/css2/monthly.pdf','I');
}
    catch(HTML2PDF_exception $e) { 
echo $e; 
}

Can you state what exactly is not working. Do you get any error messages? You can test the output method by trying a simple html like:

require_once(dirname(__FILE__).'/../html2pdf.class.php');
try {
    $html2pdf = new HTML2PDF(); // you can use the default parms
    $html2pdf->setDefaultFont('Arial');
    $html2pdf->writeHTML('<p>THIS IS A TEST</p>');
    //$html2pdf->Output('monthly.pdf');
    //$pdf->Output('../css2/monthly.pdf','D');
    $pdf->Output('/xampp/htdocs/campion/css2/monthly.pdf','F');
    //$html2pdf->Output('C:/xampp/htdocs/campion/css2/monthly.pdf','I');
}
catch(HTML2PDF_exception $e) {
    echo $e;
}

to try to narrow down the possible causes for errors.

Try this

http://code.google.com/p/dompdf/

include_once("dompdf/dompdf_config.inc.php");
$dompdf= new DOMPDF();

    if(isset($_REQUEST['txtContent'])){
        $content='';
        $content.='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head><html><body>';
        $content.=$_REQUEST['txtContent'];
        $content.='</body></html>';
        if(empty($content)) {
            $error="Please enter contents";     
        }
        else {
            $fileName=$_REQUEST['fileName'].'.pdf';
            $dompdf->load_html($content);
            $dompdf->render();
            $dompdf->set_paper(array(0,0,900,800));
            $dompdf->stream($fileName);
        }
    }

Hi
i have no errors only i cannot get the monthly.pdf file
$pdf->Output('/xampp/htdocs/campion/css2/monthly.pdf','F');

Have you tried with a simple test:

$html2pdf->writeHTML('<p>THIS IS A TEST</p>');
$pdf->Output('/xampp/htdocs/campion/css2/test.pdf','F');

And also make sure the directory you try to write into is writable by the web server process owner (apache or httpd or something else). If you are on Windows make sure you set the path correcty (maybe you have to use backslashes and maybe they have to be escaped)

Hi thank you very much
i was not pointed to the right folder
normally it is like this:
require_once(dirname(FILE).'../html2pdf/html2pdf.class.php');

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.