Jump to content

buffer help please


jake2891

Recommended Posts

Hi guys i have a pdf library that im using to generate pdf's from html. Im calling a function thats builds the html and using buffer to return the html to the pdf script. The problem is that when it runs it says the file type is missing or unsupported. Can anyone see if im using the ob_start and ob_get_flush functions correctly in my code below thanks.

 

The pdf part

 

                        if($_REQUEST['propertyIDs'] != '') {

                          $propertyIDs = explode("|",$_REQUEST['propertyIDs']);

                          foreach ($propertyIDs as $value) {

                              if($value != '') {

                              $html .= draw_property_summary($value);  //calls the function that gets the html 

                              }

                          }

                        }

                       

                        $old_limit = ini_set("memory_limit", "16M");

                        $dompdf = new DOMPDF();

                        $dompdf->load_html($html);

                        $dompdf->set_paper('letter', 'portrait');

                        $dompdf->render();

                        $dompdf->stream("dompdf_out.pdf");

                        exit(0);

 

The draw_property_summary function /* The problem part */

 

function draw_property_summary($propertyID, $r='') {

ob_start();

 

 

if($r=='') {

$department = property_department($propertyID);

$sql = "/*  select of fields here etc..  */";

$r = wrapped_query_r_get_row($sql);

}

 

$image_query= "select fileds here";

$image_result= mysql_query($image_query) or die(mysql_error());

if($image_result = wrapped_query_r_get_assoc($image_query)){

foreach ($image_result as $image_row){

$imagePath= $image_row['imageURL'].$image_row['propertyID'].'_'.$image_row['imageName'].'_large.jpg';

$img_url = $imagePath;

}

}

else {

$img_url = false;

}

 

list($postcode,$foo) = split(" ", $r['p_postcode']);

$address_line = join_nonempty(", ", array($r['p_street'], $r['p_address4'] . " ".$postcode));

 

 

 

?>

 

<table valign="top" align="center" cellpadding="2" cellspacing="0" width="95%" border="0">

<tr>

<td style="border-bottom: 1px solid rgb(0, 0, 0);" valign="top" width="260">

<?php if($img_url) { ?><img src="<?php echo $img_url; ?>" width="250" height="175"><?php } ?>

</td>

<td style="border-bottom: 1px solid rgb(0, 0, 0);" valign="top">

<span style="color: rgb(0, 0, 102); font-size: 14px;">

<strong><?php echo $address_line; ?></strong>

</span>

<br><br>

<div style="text-align: justify; font-size:12px;"><?php echo $r['p_summaryDescription']; ?></div>

<br><br>

<table cellpadding="0" cellspacing="0" width="100%">

<tbody><tr>

<td style="color: rgb(153, 0, 0);" width="70%">

<strong>Price:</strong> £<?php echo ($department == 'sales' ? number_format($r['p_sale_price']) : number_format($r['p_rental_price']).' '.$r['p_rental_frequency']); ?>

</td>

<td><em><?php echo $r['p_tenure']; ?></em>

</td>

</tr>

</table>

 

</td>

</tr>

</table>

 

$buffer = ob_get_flush();

return $buffer;

}

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/107812-buffer-help-please/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.