简体   繁体   English

将php报告页面转换为PDF格式

[英]to convert php report page to PDF format

I am new to php and dont know how to convert php file to pdf.我是 php 新手,不知道如何将 php 文件转换为 pdf。

I am trying to convert this following code to pdf, but i was not successful.我正在尝试将以下代码转换为 pdf,但我没有成功。

Kindly help me in converting this, its a kind of urgent.I have also attached an image for which i wants the conversion.请帮我转换这个,这是一种紧急情况。我还附上了一张我想要转换的图像。

<?
$Section = isset($_GET['Section'])?$_GET['Section']:"";
?>


<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <div id="loginpanel" >
    <h3>Performa regarding Contempt Petition ('A'Category) Cases Report</h3>
  </div> 
<br />
<p id="demo" align="right" style="font-size:12px"></p>

<a href="<?=DIR_WS_SITE_CONTROL?>index.php?Page=pdf"          target="_blank">Download PDF</a>

<script>
var d = new Date();
document.getElementById("demo").innerHTML = d;
</script>

<tr><td><br/></td></tr>
</table>

<?
  //// Section start
switch($Section)
{
   case "district_report":
   default:


 $ZoneObj = new DataTable(TABLE_ZONE);
 $ZoneObj->Where = "1";
 $ZoneObj->TableSelectAll();

 ?>

<table cellpadding="5" cellspacing="1" border="1" class="TableBorder"    style="color:black">

   <tr class="InsideLeftTd">
      <td width="2%" height="25"><b>S.No</b></td>
      <td width="10%" align="left"><b>Circle</b></td>
      <td width="10%" align="left"><b>District</b></td>
      <td width="8%" align="left"><b>Total no of cases</b></td>
      <td width="8%" align="left"><b>Total no. of cases where reply filed</b></td>
      <td width="8%" align="left"><b>No. of cases due for hearing in next 21 days</b></td>
      <td width="8%" align="left"><b>No. of cases due for hearing in next 21 days(Reply Filed)</b></td>
      <td width="8%" align="left"><b>No. of cases due for hearing in next 21 days(Reply Not Filed)</b></td>
  </tr>
 <?

 $SNo=1;
 $Count=1;
 while($CurrentZon=$ZoneObj->GetObjectFromRecord())
 {
   $circleObj = new DataTable(TABLE_CIRCLE);
   $circleObj->Where = "zone_id='".$CurrentZon->id."'";
   $circleObj->TableSelectAll();

 ?>
<tr>
  <td colspan="11" align="center"><b><?=MyStripSlashes($CurrentZon->zone);?> Zone</b></td>
</tr>


<?  while($CurrentCir=$circleObj->GetObjectFromRecord())
 {  

   $DistrictObj = new DataTable(TABLE_DISTRICT);
   $DistrictObj->Where = "circle_id='".$CurrentCir->id."'";
   $DistrictObj->TableSelectAll();

 ?>

 <tr class="InsideRightTd">

    <td height="25" align="center" style="color:black" rowspan="<?=$DistrictObj->GetNumRows()?>"><?=$SNo?>.</td>

    <td align="left" style="color:black" rowspan="<?=$DistrictObj->GetNumRows()?>">
        <?=MyStripSlashes($CurrentCir->circle);?>
    </td>

  <?    while($CurrentDis=$DistrictObj->GetObjectFromRecord())
  {

   $ConObj = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj->Where = "district_id='".$CurrentDis->id."'";
   $Case_count=$ConObj->TableCountDistinct("id","id_count");

   $ConObj2 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj2->Where = "district_id='".$CurrentDis->id."' AND reply_filed='Yes'";
   $Reply_count=$ConObj2->TableCountDistinct("id","reply_count");

   $ContObj = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ContObj->Where = "district_id='".$CurrentDis->id."' AND date_next_hearing>='".date('Y-m-d')."'  AND date_next_hearing <='".date('Y-m-d', strtotime("+21 days"))."'";
   $ContObj->TableSelectAll();

   $ConObj3 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj3->Where = "district_id='".$CurrentDis->id."' AND date_next_hearing>='".date('Y-m-d')."'  AND date_next_hearing <='".date('Y-m-d', strtotime("+21 days"))."' AND reply_filed='Yes'";
   $ConObj3->TableSelectAll();

   $ConObj4 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj4->Where = "district_id='".$CurrentDis->id."' AND date_next_hearing>='".date('Y-m-d')."'  AND date_next_hearing <='".date('Y-m-d', strtotime("+21 days"))."' AND reply_filed='No'";
   $Filed_count=$ConObj4->TableCountDistinct("id","next_count");

   ?>
    <td align="center" style="color:black"><?=MyStripSlashes($CurrentDis->district);?></td>
    <td align="center" style="color:black"><?=MyStripSlashes($Case_count->id_count);?></td>

   <?   if($Reply_count->reply_count!='0'){
        $color= (($Reply_count->reply_count)*100)/$Case_count->id_count;
    }else{
        $color = '0';
    }

    if($color=='0'){?>
      <td align="center" style="color:black">
        <?=MyStripSlashes($Reply_count->reply_count)?>
      </td>

    <?}elseif($color<=65 & $color>0){?>

    <td align="center" style="color:black" bgcolor="#F75D59">
        <?=MyStripSlashes($Reply_count->reply_count)?>
    </td>

    <? }elseif($color>65 && $color<=90){?>
    <td align="center" style="color:black" bgcolor="#FFFF00">
        <?=MyStripSlashes($Reply_count->reply_count)?>
    </td>

    <? }elseif($color>90){?>
    <td align="center" style="color:black" bgcolor="#00FF00">
        <?=MyStripSlashes($Reply_count->reply_count)?>
    </td>           
    <?}?>

    <td align="center" style="color:black">
        <?=MyStripSlashes($ContObj->GetNumRows())?>
    </td>

    <td align="center" style="color:black">
        <?=MyStripSlashes($ConObj3->GetNumRows())?>
    </td>


     <? if($Filed_count->next_count==0){?>

      <td align="center" style="color:black" bgcolor="#00FF00">
        <?=MyStripSlashes($Filed_count->next_count)?>
       </td>
      <?}else{?>
       <td align="center" style="color:black" bgcolor="#F75D59">
        <?=MyStripSlashes($Filed_count->next_count)?>
        </td>
        <?}?>

     </tr>


     <? 
   } 
    $SNo++;
    $Count++;

   ////////Circle Total Starts here////////////////////////////

   $ConObj5 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj5->Where = "circle_id='".$CurrentCir->id."'";
   $Case_count=$ConObj5->TableCountDistinct("id","id_count");

   $ConObj6 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj6->Where = "circle_id='".$CurrentCir->id."' AND reply_filed='Yes'";
   $Reply_count=$ConObj6->TableCountDistinct("id","reply_count");

   $ContObj7 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ContObj7->Where = "circle_id='".$CurrentCir->id."' AND date_next_hearing>='".date('Y-m-d')."'  AND date_next_hearing <='".date('Y-m-d', strtotime("+21 days"))."'";
   $Hear_count=$ContObj7->TableCountDistinct("id","file_count");

   $ConObj7 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj7->Where = "circle_id='".$CurrentCir->id."' AND date_next_hearing>='".date('Y-m-d')."'  AND date_next_hearing <='".date('Y-m-d', strtotime("+21 days"))."' AND reply_filed='Yes'";
   $Hearing_count=$ConObj7->TableCountDistinct("id","case_count");

   $ConObj8 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj8->Where = "circle_id='".$CurrentCir->id."' AND date_next_hearing>='".date('Y-m-d')."'  AND date_next_hearing <='".date('Y-m-d', strtotime("+21 days"))."' AND reply_filed='No'";
   $Filed_count=$ConObj8->TableCountDistinct("id","next_count");       

   ?>
    <tr>
      <td colspan="3" align="center"><b><?=$CurrentCir->circle?> Circle Total</b></td>
    <td align="center" style="color:black"><b><?=MyStripSlashes($Case_count->id_count);?></b></td>

     <? if($Reply_count->reply_count!='0'){
        $color= (($Reply_count->reply_count)*100)/$Case_count->id_count;
      }else{
        $color = '0';
       }

       if($color=='0'){?>
      <td align="center" style="color:black">
        <?=MyStripSlashes($Reply_count->reply_count)?>
      </td>

    <?}elseif($color<=65 & $color>0){?>

      <td align="center" style="color:black" bgcolor="#F75D59">
        <b><?=MyStripSlashes($Reply_count->reply_count)?></b>
      </td>

    <? }elseif($color>65 && $color<=90){?>
    <td align="center" style="color:black" bgcolor="#FFFF00">
        <b><?=MyStripSlashes($Reply_count->reply_count)?></b>
    </td>

    <? }elseif($color>90){?>
    <td align="center" style="color:black" bgcolor="#00FF00">
        <b><?=MyStripSlashes($Reply_count->reply_count)?></b>
    </td>           
    <?}?>

    <td align="center" style="color:black">
        <b><?=MyStripSlashes($Hear_count->file_count)?></b>
    </td>

    <td align="center" style="color:black">
        <b><?=MyStripSlashes($Hearing_count->case_count)?></b>
    </td>

    <?  if($Filed_count->next_count==0){?>

    <td align="center" style="color:black" bgcolor="#00FF00">
        <b><?=MyStripSlashes($Filed_count->next_count)?></b>
    </td>
    <?}else{?>
    <td align="center" style="color:black" bgcolor="#F75D59">
        <b><?=MyStripSlashes($Filed_count->next_count)?></b>
    </td>
    <?}?>

   </tr>

   <?
   /////////Zone total starts here/////////////////////////

   $ConObj5 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj5->Where = "zone_id='".$CurrentCir->zone_id."'";
   $Case_count=$ConObj5->TableCountDistinct("id","id_count");

   $ConObj6 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj6->Where = "zone_id='".$CurrentCir->zone_id."' AND reply_filed='Yes'";
   $Reply_count=$ConObj6->TableCountDistinct("id","reply_count");

   $ContObj7 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ContObj7->Where = "zone_id='".$CurrentCir->zone_id."' AND date_next_hearing>='".date('Y-m-d')."'  AND date_next_hearing <='".date('Y-m-d', strtotime("+21 days"))."'";
   $Hear_count=$ContObj7->TableCountDistinct("id","fil_count");

   $ConObj7 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj7->Where = "zone_id='".$CurrentCir->zone_id."' AND date_next_hearing>='".date('Y-m-d')."'  AND date_next_hearing <='".date('Y-m-d', strtotime("+21 days"))."' AND reply_filed='Yes'";
   $Hearing_count=$ConObj7->TableCountDistinct("id","case_count");

   $ConObj8 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj8->Where = "zone_id='".$CurrentCir->zone_id."' AND date_next_hearing>='".date('Y-m-d')."'  AND date_next_hearing <='".date('Y-m-d', strtotime("+21 days"))."' AND reply_filed='No'";
   $Filed_count=$ConObj8->TableCountDistinct("id","next_count");    



    } ?>

    <tr>
    <td colspan="3" align="center"><b><?=$CurrentZon->zone?> Zone Total</b>      </td>

    <td align="center" style="color:black"><b><?=MyStripSlashes($Case_count->id_count);?></b></td>

  <?    if($Reply_count->reply_count!='0'){
        $color= (($Reply_count->reply_count)*100)/$Case_count->id_count;
      }else{
        $color = '0';
      }

     if($color=='0'){?>
      <td align="center" style="color:black">
        <?=MyStripSlashes($Reply_count->reply_count)?>
      </td>

      <?}elseif($color<=65 & $color>0){?>

      <td align="center" style="color:black" bgcolor="#F75D59">
        <b><?=MyStripSlashes($Reply_count->reply_count)?></b>
      </td>

      <? }elseif($color>65 && $color<=90){?>
      <td align="center" style="color:black" bgcolor="#FFFF00">
        <b><?=MyStripSlashes($Reply_count->reply_count)?></b>
      </td>

      <? }elseif($color>90){?>
       <td align="center" style="color:black" bgcolor="#00FF00">
        <b><?=MyStripSlashes($Reply_count->reply_count)?></b>
       </td>            
       <?}?>

        <td align="center" style="color:black">
        <b><?=MyStripSlashes($Hear_count->fil_count)?></b>
        </td>

        <td align="center" style="color:black">
        <b><?=MyStripSlashes($Hearing_count->case_count)?></b>
    </td>

   <?   if($Filed_count->next_count==0){?>

    <td align="center" style="color:black" bgcolor="#00FF00">
        <b><?=MyStripSlashes($Filed_count->next_count)?></b>
    </td>
    <?}else{?>
    <td align="center" style="color:black" bgcolor="#F75D59">
        <b><?=MyStripSlashes($Filed_count->next_count)?></b>
    </td>
    <?}?>

    </tr>


   <?}

   /////////District total starts here//////////////////////////

   $ConObj5 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj5->Where = "1";
   $Case_count=$ConObj5->TableCountDistinct("id","id_count");

   $ConObj6 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj6->Where = "reply_filed='Yes'";
   $Reply_count=$ConObj6->TableCountDistinct("id","reply_count");

   $ContObj7 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ContObj7->Where = "date_next_hearing>='".date('Y-m-d')."'  AND date_next_hearing <='".date('Y-m-d', strtotime("+21 days"))."'";
   $Hear_count=$ContObj7->TableCountDistinct("id","file_count");

   $ConObj7 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj7->Where = "date_next_hearing>='".date('Y-m-d')."'  AND date_next_hearing <='".date('Y-m-d', strtotime("+21 days"))."' AND reply_filed='Yes'";
   $Hearing_count=$ConObj7->TableCountDistinct("id","case_count");

   $ConObj8 = new DataTable(TABLE_CONTEMPT_PETITION_A);
   $ConObj8->Where = "date_next_hearing>='".date('Y-m-d')."'  AND date_next_hearing <='".date('Y-m-d', strtotime("+21 days"))."' AND reply_filed='No'";
   $Filed_count=$ConObj8->TableCountDistinct("id","next_count");    

   ?>    
    <tr class="InsideRightTd">
    <td align="center" style="color:black" bgcolor="#F5F5DC" colspan="3"><b> Grand Total</b></td>
    <td align="center" style="color:black" bgcolor="#F5F5DC"><b><?=MyStripSlashes($Case_count->id_count);?></b></td>

    <?  if($Reply_count->reply_count!='0'){
        $color= (($Reply_count->reply_count)*100)/$Case_count->id_count;
    }else{
        $color = '0';
    }

    if($color=='0'){?>
      <td align="center" style="color:black">
        <?=MyStripSlashes($Reply_count->reply_count)?>
      </td>

    <?}elseif($color<=65 & $color>0){?>

      <td align="center" style="color:black" bgcolor="#F75D59">
        <b><?=MyStripSlashes($Reply_count->reply_count)?></b>
      </td>

    <? }elseif($color>65 && $color<=90){?>
    <td align="center" style="color:black" bgcolor="#FFFF00">
        <b><?=MyStripSlashes($Reply_count->reply_count)?></b>
    </td>

    <? }elseif($color>90){?>
    <td align="center" style="color:black" bgcolor="#00FF00">
        <b><?=MyStripSlashes($Reply_count->reply_count)?></b>
    </td>           
    <?}?>

    <td align="center" style="color:black">
        <b><?=MyStripSlashes($Hear_count->file_count)?></b>
    </td>

    <td align="center" style="color:black">
        <b><?=MyStripSlashes($Hearing_count->case_count)?></b>
    </td>

    <?  if($Filed_count->next_count==0){?>

    <td align="center" style="color:black" bgcolor="#00FF00">
        <b><?=MyStripSlashes($Filed_count->next_count)?></b>
    </td>
    <?}else{?>
    <td align="center" style="color:black" bgcolor="#F75D59">
        <b><?=MyStripSlashes($Filed_count->next_count)?></b>
    </td>
    <?}?>
    </tr>

   </table>

  <?    break;
   }
  ?>

   <table cellpadding="0" cellspacing="0" border="0" style="color:black" align="center">
     <tr></tr><br/>

     <tr>
      <td>Less than 65% &nbsp;&nbsp;<div style="width:60px;height:20px;border:1px solid #000;background:#F75D59;"></div>     </td>
      <td>Between 65-90%&nbsp;&nbsp;<div style="width:60px;height:20px;border:1px solid #000;background:#FFFF00;"></div></td>
      <td>Greater Than 90% &nbsp;&nbsp;<div style="width:60px;height:20px;border:1px solid #000;background:#00FF00;"></div></td>
      </tr>

    </table>

This is a report and i want its pdf to be downloaded.这是一份报告,我想下载它的 pdf。

I am attaching its image also我也附上了它的图片我想要pdf文件的报告图像

There is also a free windows soft called DoPdf.还有一个免费的 windows 软件叫做 DoPdf。 It's like a virtual printer you install on your PC, very light, easy, fast and painless.它就像您在 PC 上安装的虚拟打印机,非常轻便、简单、快速且无痛。 Install this "printer" on your PC and then, on your browser, "print" the page on that printer.在您的 PC 上安装此“打印机”,然后在您的浏览器上,在该打印机上“打印”页面。 All you will get is your nice and clean HTML converted to a PDF file saved on the folder you choose.您将获得的只是将漂亮干净的 HTML 转换为保存在您选择的文件夹中的 PDF 文件。 You would even can configure resolution of the generated PDF, if it will be Portrait or Landscape, black n white or colored, so, it's a very popular and nice option.您甚至可以配置生成的 PDF 的分辨率,如果它是纵向或横向、黑色、白色或彩色,那么,这是一个非常受欢迎且不错的选择。 Plus every soft on your PC will be able to use this pdf creator too, anytime, for example, your OpenOffice, etc. Best.此外,您 PC 上的每个软件都可以随时使用此 pdf 创建器,例如您的 OpenOffice 等。最好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM