sheriff Posted April 16, 2007 Share Posted April 16, 2007 hi all .. I have a php generated page. How can I save it to a pdf ? I have readed dompdf's docs, but i don't understand anythig. Can anyone help me with this ? Thanks ! this is the code: <?php include('include/db.php'); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> <center> <br> <font color="#000000" size="4"><strong>Lista Produse</strong></font><br><br> <table align="center" bgcolor="#DDD2BA" cellpadding="1" cellspacing="1" width="78%"> <tr> <td width="34%" bgcolor="#475558" align="center"><font color="#FFFFFF" size="3"><strong>Nume</strong></font> <td width="44%" bgcolor="#475558" align="center"><font color="#FFFFFF" size="3"><strong>Descriere</strong></font> <td width="6%" bgcolor="#475558" align="center"><font color="#FFFFFF" size="3"><strong>UM</strong></font> <td width="10%" bgcolor="#475558" align="center"><font color="#FFFFFF" size="3"><strong>Pret</strong></font> </tr> <?php if(isset($_POST)){ if(count($_POST['check'])){ $list_selected = ""; foreach($_POST['check'] as $key => $ids){ $list_selected .= $ids .","; } $list_selected = substr($list_selected,0,strlen($list_selected)-1); // This will give ur selected ids like this 100,203,125,123 }else{ $list_selected = "-1"; } } $query = "select * from products WHERE pr_id IN (".$list_selected.")"; $result = mysql_query($query); $count = mysql_num_rows($result); $color1 = "#DDDAD4"; $color2 = "#DDD7CC"; $row_count = 0; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; $id = $row['pr_id']; $name = $row['pr_name']; $desc = $row['pr_desc']; $um = $row['pr_um']; $price = $row['pr_price']; //$total = $price*$_request['discountt']/100; ?> <tr> <td bgcolor="<?php echo $row_color; ?>"><?php echo $name; ?></td> <td bgcolor="<?php echo $row_color; ?>"><?php echo $desc; ?></td> <td align="center" bgcolor="<?php echo $row_color; ?>"><?php echo $um; ?></td> <td align="right" bgcolor="<?php echo $row_color; ?>"><?php echo $price; ?> RON </td> </tr> <?php $row_count++; } echo "</table>". "</body></html>"; ?> Link to comment https://forums.phpfreaks.com/topic/47203-solved-php-to-pdf/ Share on other sites More sharing options...
cyrixware Posted April 16, 2007 Share Posted April 16, 2007 You want your page to view in the browser pdf format or you want your codes to save.pdf extension? Link to comment https://forums.phpfreaks.com/topic/47203-solved-php-to-pdf/#findComment-230200 Share on other sites More sharing options...
sheriff Posted April 16, 2007 Author Share Posted April 16, 2007 I want the generated page to be saved as pdf in a folder and with the mail() function to send it as attachement. I have tryed eith html2pdf .. but don't work for me <?php require('html2fpdf.php'); // activate Output-Buffer: ob_start(); //START-OF-PHP code phpinfo(); // PHP code here //END-OF-PHP code // Output-Buffer in variable: $htmlbuffer = ob_get_contents(); // delete Output-Buffer : ob_end_clean(); require('html2fpdf.php'); $pdf=new PDF(); $pdf->AddPage(); $pdf->WriteHTML($htmlbuffer); $pdf->Output(); //Outputs on browser screen ?> the error : Fatal error: Cannot redeclare class HTML2FPDF in \htdocs\prosport\order\html2fpdf.php on line 2902 Thanks Link to comment https://forums.phpfreaks.com/topic/47203-solved-php-to-pdf/#findComment-230209 Share on other sites More sharing options...
cyrixware Posted April 16, 2007 Share Posted April 16, 2007 im stil fixing this problem but stil eror display. im tryin to configure it... Link to comment https://forums.phpfreaks.com/topic/47203-solved-php-to-pdf/#findComment-230215 Share on other sites More sharing options...
sheriff Posted April 16, 2007 Author Share Posted April 16, 2007 this it's work for me! Now i don't know how to send it in mail as attachement ! <?php require("html2fpdf.php"); //Get file contents $htmlFile = "oferta.html"; $file = fopen($htmlFile,"r"); $size_of_file = filesize($htmlFile); $buffer = fread($file, $size_of_file); fclose($file); //Initialize class //define RELATIVE_PATH,FPDF_FONTPATH if needed $pdf=new HTML2FPDF(); $pdf->AddPage(); //Code below used only if you want relative links to be understood //$pdf->setBasePath(dirname(__FILE__)."\".$htmlFile);//insert full path where html is $pdf->WriteHTML($buffer); $pdf->Output('oferta.pdf'); //Read the FPDF.org manual to know the other options ?> Link to comment https://forums.phpfreaks.com/topic/47203-solved-php-to-pdf/#findComment-230220 Share on other sites More sharing options...
Barand Posted April 16, 2007 Share Posted April 16, 2007 http://phpmailer.sourceforge.net/ Link to comment https://forums.phpfreaks.com/topic/47203-solved-php-to-pdf/#findComment-230251 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.