Hi
i m trying to output pdf file from html..this html is a result of a php script
i have this error from html2pdf
impossible to load the image litre.php?start=2012-09-1&end=2012-09-30&client=13
any help please

Member Avatar for LastMitch

@asaidi

i m trying to output pdf file from html..this html is a result of a php script
i have this error from html2pdf
impossible to load the image litre.php?start=2012-09-1&end=2012-09-30&client=13
any help please

Can you post the code? It's a bit confusing. It's hard to help you without see the whole code.

?php
include('db.php');
$start = date("Y-m-1", strtotime("last month"));
$end = date("Y-m-t", strtotime("last month"));  
?> 
<!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>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1252' />
<title>CAMPION The Power Behind The Water</title>
<?php
  if(preg_match('/(?i)msie [1-9]/',$_SERVER['HTTP_USER_AGENT'])) {
    echo " <link href='ie.css' rel='stylesheet' type='text/css' /> ";
  } else {
   echo "<link href='fire1.css' rel='stylesheet' type='text/css' />";
  }
?>
<style type="text/css"  >

#fixed {
    position: absolute;
    top: 0;
    left: 0;
    width: 10em;
    height: 100%;
}
@media print {
input#BTNPRINT{
display: none;
}
}    
@media screen{
    .imgs1 {
       position:absolute;
       width:30%;
       height:15%;
       top:-6px;
       left:0;
      }
  } 
img{ page-break-after: always }
.table2 {

 border:1px solid #000;

      font-family:arial,sans-serif;
      font-size:80%;
      height:150%;
      width:100%; 
}


#table4{
        border:3px solid #fff;
        position:relative;
        top:-5px;  

}
th{
    border:1px solid #000;
    border-collapse:collapse;
    padding:5px;
}   
@page { size : portrait }
@page rotated { size : landscape }
table { page : rotated }
#fn,#dp,#ar{width:110px;}
#fr,#to{width:90px;}
caption{

    font-size:100%;
    border:1px solid #000;
    border-bottom:none;
    padding:20px 0 0 0;
    text-align:left;
}
#td1{

        background-color:#9cf;

}   

</style>

</head>
<body>
<?php
$sql="SELECT * FROM count_transactions t,automatic_report a 
      WHERE DATE(t.tran_date) BETWEEN '$start' AND '$end' AND t.customer_no=a.customer AND t.account_no=a.account and a.periode=3
      GROUP BY t.customer_no";  
          $res = mysql_query($sql) or die("FAIL: $sql<br>" . mysql_error());
          $num = mysql_num_rows($result1);
while($rows = mysql_fetch_array($res)) { 
ob_start();            
              $var=0;
              $tot1=0;
              $tot22=0;
              $tot33=0;
              $tot44=0;
              $general1=0;
              $dateb =$rows['tran_date'];
              $dateb1=date('M-Y',strtotime($dateb));             
              $i=0; 
              $netw=$rows['unit_serial'];
              $client=$rows['customer_no'];
              $auto=$rows['account_no'];
              $channel=$rows['pulse_channel'];
              $email=$rows['email'];
              $client=$rows['customer'];  
?>
<table id ='table4'><tr>
<?php
$q1="SELECT unitName FROM net_watch_units WHERE serial_no=$netw";
                   $res1=mysql_query($q1);
                   $r1=mysql_fetch_array($res1);
                   $account=$r1['unitName']; 
$q2="SELECT account_name FROM account_details WHERE auto_id=$auto";
                   $res2=mysql_query($q2);
                   $r2=mysql_fetch_array($res2);
                   $name=$r2['account_name'];  
$q3="SELECT customer_name FROM customer_details WHERE auto_id=$client";
                   $res3=mysql_query($q3);
                   $r3=mysql_fetch_array($res3);
                   $surname=$r3['customer_name'];  
$query1="select account_ref,serial_no,pulser1_name,pulser2_name,pulser3_name,pulser4_name from net_watch_units
         where serial_no=$netw ";
$result2=mysql_query($query1);
$record2=mysql_fetch_array($result2);
$pulser1=$record2['pulser1_name'];  
$pulser2=$record2['pulser2_name'];
$pulser3=$record2['pulser3_name'];
$pulser4=$record2['pulser4_name'];
if($pulse[0]=='1' && $pulse[1]=='2' && $pulse[2]=='3' && $pulse[3]=='4'){
   $chane1=$pulser1; 
   $chane2=$pulser2; 
   $chane3=$pulser3; 
   $chane4=$pulser4;  
} 
if($pulse[0]=='1' && $pulse[1]=='' && $pulse[2]=='' && $pulse[3]==''){
   $pulser2=''; 
   $pulser3=''; 
   $pulser4='';  

}  
if($pulse[0]=='' && $pulse[1]=='2' && $pulse[2]=='' && $pulse[3]==''){
   $pulser1=''; 

   $pulser3=''; 

   $pulser4='';  

}  
if($pulse[0]=='' && $pulse[1]=='' && $pulse[2]=='3' && $pulse[3]==''){
   $pulser1=''; 
   $pulser2='';
   $pulser4='';  

}  
if($pulse[0]=='' && $pulse[1]=='' && $pulse[2]=='' && $pulse[3]=='4'){
   $pulser1=''; 
   $pulser2='';
   $pulser3=''; 


}  
?>    
<td rowspan="2" style="width:30%"><img src='campion.png' alt='The Power Behind The Water'/></td>
<td colspan="2" style=" width:20%;font-size:12px;"><b>Unit Name </b>:  <br><?php echo $account;?> </td> 
<td colspan="2" style=" width:20%;font-size:12px;"><b>Account Name </b> :<br><?php echo $name;?></td> 
<td colspan="2" style=" width:15%;font-size:12px;"><b> Customer Name </b> : <br><?php echo $surname;?> </td></tr>
<tr><td style="font-size:12px;width:10%;"><b>Report Date</b> :  <br><?php echo $dateb1;?></td> 
<?php
         if($report=='1'){
            $rep='Litres';
         }
         if($report=='2'){
            $rep='M3';
         }
         if($report=='3'){
            $rep='Gallons (Imp)';
         }
?>
<td style="width:10%;font-size:12px;"><b>Report Units</b> :  <br>Litres </td><td colspan="3" style="font-size:12px;"><b>Report Name</b> :  <br> Monthly Totals Usage Report </td> 
</tr>
</table>
<table border='0' width='100%' bgcolor='#99eeff'> 
  <tr bgcolor='#ffccff'>

      <td><b>Date</b></td>   
      <td><b><?php echo $pulser1;?></b></td>  
      <td><b><?php echo $pulser2;?></b></td>  
      <td><b><?php echo $pulser3;?></b></td>  
      <td><b><?php echo $pulser4;?></b></td>  
      <td><b>Total</b></td>  
    </tr>

  <?php
         if($report=='1'){
            $rep='Litres';
         }
         if($report=='2'){
            $rep='M3';
         }
         if($report=='3'){
            $rep='Gallons (Imp)';
         }
$pdf="SELECT DATE(tran_date) as dateiy,unit_serial,tran_date,
      SUM(case when pulse_channel = 1 then unit_qty else 0 end) as name1,
      SUM(case when pulse_channel = 2 then unit_qty else 0 end) as name2,
      SUM(case when pulse_channel = 3 then unit_qty else 0 end) as name3,
      SUM(case when pulse_channel = 4 then unit_qty else 0 end) as name4,
      SUM(unit_qty) as Total
from count_transactions   
WHERE  DATE(tran_date) BETWEEN '$start' AND '$end'  and customer_no=$client
     GROUP BY DATE(tran_date)";  
$result=mysql_query($pdf) or die('Could not connect: ' . mysql_error());
$num=mysql_num_rows($result);
while($row= mysql_fetch_array($result)){
    $jour = $row['dateiy'];
    $jour=date('d-m-Y',strtotime($jour));
    $total = $row['Total'];
    $name1 = $row['name1'];
    $name2 = $row['name2'];
    $name3 = $row['name3'];
    $name4 = $row['name4']; 
if($report==2){
             $name1=$name1/1000;
             $name2=$name2/1000;
             $name3=$name3/1000;
             $name4=$name4/1000;
             $total=$total/1000; 
          }
          elseif($report==3){
              $name1=$name1*0.2199;
              $name2=$name2*0.2199;
              $name3=$name3*0.2199;
              $name4=$name4*0.2199;
              $total=$total*0.2199;   
          }
          else{
            $name1=$name1*1;
            $name2=$name2*1;
            $name3=$name3*1;
            $name4=$name4*1;
            $total=$total*1; 
          }
$var=$name1+$name2+$name3+$name4;
$general1=$general1+$var;
$tot1=$tot1+$name1; 
$tot22=$tot22+$name2;
$tot33=$tot33+$name3;
$tot44=$tot44+$name4; 
$name1=number_format($name1,2,'.',',');
$name2=number_format($name2,2,'.',',');
$name3=number_format($name3,2,'.',',');
$name4=number_format($name4,2,'.',',');
$var=number_format($var,2,'.',','); 
$general=number_format($general1,2,'.',',');
$namef1=str_pad(number_format($name1,2,'.',','),$imax, $pad,  STR_PAD_LEFT);
$namef2=str_pad(number_format($name2,2,'.',','),$imax, $pad,  STR_PAD_LEFT);
$namef3=str_pad(number_format($name3,2,'.',','),$imax, $pad,  STR_PAD_LEFT);
$namef4=str_pad(number_format($name4,2,'.',','),$imax, $pad,  STR_PAD_LEFT);
$totalf=str_pad(number_format($var,2,'.',','),$imax, $pad,  STR_PAD_LEFT); 
$somme1=str_pad(number_format($tot1),$imax,  $pad,  STR_PAD_LEFT); 
$somme2=str_pad(number_format($tot22),$imax, $pad,  STR_PAD_LEFT); 
$somme3=str_pad(number_format($tot33),$imax, $pad,  STR_PAD_LEFT); 
$somme4=str_pad(number_format($tot44),$imax, $pad,  STR_PAD_LEFT); 
$i++;
echo"<tr bgcolor='#ccffaa'>"; 
        echo"<td>$jour</td><td>$name1</td><td>$name2</td><td>$name3</td><td>$name4</td><td>$var</td></tr>";
}        
  $av1=round($tot1/($i),2); 
  $av2=round($tot22/($i),2);
  $av3=round($tot33/($i),2); 
  $av4=round($tot44/($i),2);  
  $avg=$av1+$av2+$av3+$av4;
  $av1=str_pad(number_format($av1,2),$imax, $pad,  STR_PAD_LEFT);
  $av2=str_pad(number_format($av2,2),$imax, $pad,  STR_PAD_LEFT);
  $av3=str_pad(number_format($av3,2),$imax, $pad,  STR_PAD_LEFT);
  $av4=str_pad(number_format($av4,2),$imax, $pad,  STR_PAD_LEFT);
  $avg1=str_pad(number_format($avg,2),$imax, $pad,  STR_PAD_LEFT); 
?>
<tr bgcolor='#ffccee'>
<td><u><b>Total </b></u></td>  
<td><?php echo $tot1;?></td> 
<td><?php echo $tot22;?></td>
<td><?php echo $tot33;?></td>
<td><?php echo $tot44;?></td>
<td><?php echo $general;?></td></tr>
<tr bgcolor='#eeffcc'>
<td><b><u>Daily Average</u></b></td> 
<td><?php echo $av1;?></td> 
<td><?php echo $av2;?></td> 
<td><?php echo $av3;?></td> 
<td><?php echo $av4;?></td> 
<td><?php echo $avg1;?></td> 
</tr></table> 
<img src='litre.php?start=<?php echo $start?>&end=<?php echo $end?>&client=<?php echo $client?>'/> 
<?php 
//$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'?'.$client=$client;
//$url="http://localhost:8080/campion/css2/monthly.php?client=$client";
//echo $url;
$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/html2pdf.class.php');
    try {
        $html2pdf = new HTML2PDF();     // you can use the default parms

                $html2pdf = new HTML2PDF('P', 'A4', 'en', true, 'UTF-8', 0);
                $html2pdf->pdf->SetDisplayMode('fullpage'); 
                $html2pdf->writeHTML($output);

        $html2pdf->Output('monthly.pdf','F');

}
    catch(HTML2PDF_exception $e) { 
echo $e; 
}
Member Avatar for LastMitch

@asaidi

In the future, when you post code remember to post which line is the ERROR because I'm not going to read a whole code!

Plus you using this package from:

http://html2pdf.seven49.net/Web/en/Home/Default.htm

If you pay for something like that, then you should ask for help regarding about it. I'm a bit confused they do have tech support with this. Why are you posting an issue when you can get answer directly by the provider?

Hi sorry about that..there is no error in my code only when i embed a picture
<img src='litre.php?start=<?php echo $start?>&end=<?php echo $end?>&client=<?php echo $client?>'/>
then i have Impossible de charger l'image litre.php?start=2012-09-1&end=2012-09-30&client=13
and also i got the html2pdf for free i m not paying the software
cheers

Member Avatar for LastMitch

@asaidi

<img src='litre.php?start=<?php echo $start?>&end=<?php echo $end?>&client=<?php echo $client?>'/>

You don't have a path to the image! That's why you got that error. You can't used litre.php! Is that where the image is stored? No, it should be in a folder!

For example:

<img src="images/01.jpg" width="500" height="500" alt="Caption 1" />

That images is a folder where the 01.jpg is store. I hope that make sense because I never seen a php file store an image it's usually a folder and a path to it.

Hi
sorry this image it is a graph
please see the script about this graph..

<?php
SESSION_START();
$start=$_GET['start'];
$end=$_GET['end'];
$netw=$_GET['netw'];
$client=$_GET['client'];

$i=0;
$db=mysql_pconnect("localhost:3306","root","root");
mysql_select_db("campion",$db); 

$sql = "SELECT DATE_FORMAT(tran_date,'%d')as datei,unit_serial,sum(unit_qty) as total,account_no,customer_no  FROM count_transactions
        WHERE DATE(tran_date) BETWEEN '$start' AND '$end' and customer_no=$client 
        GROUP BY DATE(tran_date)";
$result = mysql_query($sql);
$num=mysql_num_rows($result);
$somme=array();
$jour=array();
while($row = mysql_fetch_array($result)){
   $somme[]=$row[total];
   $jour[]=$row[datei];
}
$num=mysql_num_rows($result);
include("../css/phplot.php");
if(preg_match('/(?i)msie [1-8]/',$_SERVER['HTTP_USER_AGENT'])) {
   $graph =& new PHPlot(842,200);
}

else { 
$graph =& new PHPlot(842,200);
}
//Define the object
//Define some data
$data = array();
//Define some data
for($i=0;$i<=$num;$i++)   
$data[] = array($jour[$i],$somme[$i]);
$graph->SetDataValues($data);
$graph->SetXTickPos('none');
$graph->SetXTickLabelPos('none');
//Draw it
$graph->DrawGraph();
?>
Member Avatar for LastMitch

@asaidi

sorry this image it is a graph

You need to put <img> in order for it to read <img>

$graph->img->

hi
i put <img src='http....
how i can put
$graph->img->then the link..?

Member Avatar for LastMitch

@asaidi

i put <img src='http....
how i can put
$graph->img->then the link..?

OK, Maybe I wrote it incorrectly, I shouldn't put <> because it confused you.

You need to add img in here:

$graph->SetDataValues($data); and the rest of $graph

You don't touch this:

<img src='litre.php?start=<?php echo $start?>&end=<?php echo $end?>&client=<?php echo $client?>'/>

You leave it the way it is!

Hi
sorry about that

for($i=0;$i<=$num;$i++)   
$data[] = array($jour[$i],$somme[$i]);
?>
**<img src='$graph->SetDataValues($data)'/>**
<?php
$graph->SetXTickPos('none');
$graph->SetXTickLabelPos('none');
//Draw it
$graph->DrawGraph();

}

is it like this

Member Avatar for LastMitch

@asaidi

No, You really need to pay attention to the code.

Like this:

$graph->img->SetDataValues($data);

You don't have to change anything with this:

<img src='litre.php?start=<?php echo $start?>&end=<?php echo $end?>&client=<?php echo $client?>'/>

leave it alone.

Read this, it seems to me you are not familiar with this code:

http://www.asial.co.jp/jpgraph/manual/ref/RotImage.html

and also this:

http://devzone.zend.com/125/developing-professional-quality-graphs-with-php/

Hi
thank you
really i m with this code and a lot in my project it is only i m new to this html2php
i did the same as you showed me now but it does not work
really sorry

Member Avatar for LastMitch

@asaidi

really i m with this code and a lot in my project it is only i m new to this html2php
i did the same as you showed me now but it does not work

What error do you? It's still the same error? Do you have any other files that has those functions?

I'm not sure how you got this software for free. But you need to read this link:

http://devzone.zend.com/125/developing-professional-quality-graphs-with-php/

Read this section: To Cache or Not to Cache

It shows you how to get that <img> link to work.

I think it's best to read the whole article.

If you still have any questions post it here but so far it's the same error so read the article.

It seems to me that you are not trying to make it work.

Hi
thank you for your help the problem it is resolved and it was in here
instead of this:
<img src='weekly.php'/> i put this
<img src='http://localhost:8080/campion/css2/litre.php?start=<?php echo $start?>&end=<?php echo $end?>&client=<?php echo $client?>'/>

Member Avatar for LastMitch

@asaidi

<img src='http://localhost:8080/campion/css2/litre.php?start=<?php echo $start?>&end=<?php echo $end?>&client=<?php echo $client?>'/>

I get it in the end you still need to used a path to run that file.

it's good that you solve it

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.