jake2891 Posted May 31, 2008 Share Posted May 31, 2008 Hi guys, thanks for taking the time to read my post. Im having a little difficulty with my code, ive made comments in the code where my problems are and what the problem is. Any input would be greatly appreciated. But basically its a php script that uses a pdf library that generates pdf's from html. 2 problems in my code below. /** uses the pdf library The below code gets location ids calls a function that gets the property information with the location id puts the information into html then spits it back which generates a pdf document. */ $html = ''; if($_REQUEST['locationIDs'] != '') { $locationIDs = explode("~",$_REQUEST['locationIDs']); $img_urls = array(); foreach($locationIDs as $value){ /* calls the function which gets the html */ /* lists the html and image path returned from the buffer in the draw_property_summary function */ list($p_html, $img_path) = draw_property_summary($value,$propertySearchDepartment); $img_urls[] = $img_path; $html .= $p_html; } /** Rite heres problem no 1, the below code should delete the image saved in the draw_property_summary function now we have the image in the html, see function. But it doesnt. */ foreach($img_urls as $img_url){ if($img_url){ if(!is_dir($img_url)){ // been through the checks and its not a directory and the image is there unlink($img_url); //something faulty here? } } } $old_limit = ini_set("memory_limit", "16M"); $dompdf = new DOMPDF(); $dompdf->load_html($html); /* reads the html */ $dompdf->set_paper('letter', 'portrait'); $dompdf->render(); $dompdf->stream("dompdf_out.pdf"); exit(0); } function draw_property_summary($propertyID,$department){ ob_start(); global $SearchApiUrl; $param='?hash='.$propertyID; $result=''; $data=''; /* just gets property information */ $viart_xml = fopen($SearchApiUrl.$param, "r"); if($viart_xml) { while (!feof($viart_xml)) { $result.= fread($viart_xml, 1024); } } if($result) { $data = unserialize($result); foreach ($data as $row) { $address_line = join_nonempty(", ", array($row['address1'], '<br>'.$row['address2'])); $img_url = $row['image_url']; $description = $row['description']; $department == 'sales' ? $price = $row['price_numeric'] : $row['rent_numeric']; $tenure = $row['tenure']; } } $handle = fopen($img_url, "r"); $source = ''; while (!feof($handle)) { $source .= fgets($handle); } /* Here i change the name of the image i got and save it to a temp directory Problem No2, after i rename the image and save it that works fine but the image in the pdf generated comes out tiny i dont know why because when i view the image in the browser its a normal size, tried changing the width and height in the html below but it stil remains tiny?? */ file_put_contents('../images/tmp/'.$propertyID.'.jpg',$source); fclose($handle); $img_url = 'http://'.$_SERVER['SERVER_NAME'].'/images/tmp/'.$propertyID.'.jpg'; ?> <table> <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> </tr> </table> <?php $buffer = ob_get_contents(); ob_end_clean(); /* returns the html and the image url */ return array($buffer, $img_url); } Please use CODE tags when posting code Link to comment https://forums.phpfreaks.com/topic/108133-calling-php-experts/ Share on other sites More sharing options...
DarkerAngel Posted June 2, 2008 Share Posted June 2, 2008 try harder retard That was a vary intelligent first post there buddy, as for the original poster, sorry I don't have any experience with the pdf libs Link to comment https://forums.phpfreaks.com/topic/108133-calling-php-experts/#findComment-555429 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.