Как напечатать выходную таблицу в формате бумаги формата Legal при загрузке формата PDF в Codeigniter

Я попытался напечатать результат в легальной газете в альбомном формате. Но выходные данные свернуты из-за проблемы с пространством (только один столбец из 8 документов можно печатать в одну строку). Другие столбцы сломаны или свернуты.

Но я хочу видеть все столбцы в официальной газете в альбомном формате (например, 12 столбцов отображаются на одной странице без влияния на четыре боковых угла).

Я использовал библиотеку Dompdf.

Код помощника библиотеки Dompdf

<?php 
ob_start();
if (!defined('BASEPATH')) exit('No direct script access allowed');
ini_set("memory_limit","1024M");
function pdf_create($html, $filename, $stream=TRUE) 
{
    require_once("dompdf/dompdf_config.inc.php");
    spl_autoload_register('DOMPDF_autoload');
    
    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $customPaper = array(0,0,360,360);
    $dompdf->set_paper($customPaper);
    //$dompdf->set_paper('legal', 'landscape');
    $dompdf->render();
    if ($stream) {
        $dompdf->stream($filename.".pdf");
    } else {
        $CI =& get_instance();
        $CI->load->helper('file');
  //$CI->load->SetFont('arial', '', 12);
        write_file($filename.".pdf", $dompdf->output());
    }
}
?>  

Образец кода

$html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
  <html>
   <head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <style>
    
     @page {
      height:100%;
     }
     table td {
      font-size:16px;
     } 
     thead:before, thead:after { display: none; }
     tbody:before, tbody:after { display: none; }

    </style>
   </head>
   <body>
    <div id="page">
     <table>
      <tr>
       <td style="text-align:center;font-weight:bold;font-size:10px;" width="100%">
        DAKSHINA BHARAT HINDI PRACHAR SABHA, MADRAS
       </td>
      </tr>
      <tr>
       <td style="text-align:center;font-weight:bold;font-size:10px;" width="100%">
        POST GRADUATE AND RESEARCH INSTITUTE
       </td>
      </tr>
      <tr>
       <td style="text-align:center;font-weight:bold;font-size:10px;" width="100%">
        DEPARTMENT OF P.G. EXAMS
       </td>
      </tr>
     </table>
     <div style="clear:both"></div>
     <table  style="text-align:left">
      <tr>
       <td colspan="2" width="200" style="font-size:9px; font-weight:bold;">
         CENTRE :' . strtoupper($centreName['collegeCentre']).'
       </td>
      </tr>
     </table>
     <div style="clear:both"></div>
     <table align="center" width="100%" class="dataTable span12" border="1" cellspacing="0" cellpadding="5" style="border: 1px solid #000;text-align:center;max-width:100%;"> 
                            <thead>
                                <tr>
                                    <th rowspan="2">S&nbsp;No</th>
                                    <th class="showHallDiv" rowspan="2">Roll No</th>
                                    <th rowspan="2">D Code No</th>';
                                    if($paperDetails)
                                    {   
                                        $sno=0;
                                        foreach($paperDetails as $row){
                                            $sno++;
                                            $paperTypeStatus ='';
                                            if($row['paperType'] == 1 && $row['examType'] == 1){
                                                $paperTypeStatus ='Comp-Wri';
                                                
                                                $html .= '<th colspan="4" data-ref="'.$row['shortName'].'" class="headerCaption">
                                                    P'.$sno.' '.$paperTypeStatus.'<br>'.$row['paperTotalMark'].' Mark
                                                </th>';
                                            }
                                            elseif($row['paperType'] == 1 && $row['examType'] == 2){
                                                $paperTypeStatus ='Comp-Pra';
                                                $html .= '<th colspan="4" data-ref="'.$row['shortName'].'" class="headerCaption">
                                                    P'.$sno.' '.$paperTypeStatus.'<br>'.$row['paperTotalMark'].' Mark
                                                </th>';
                                            }
                                            elseif ($row['paperType'] == 2 && $row['examType'] == 1) {
                                                $paperTypeStatus ='Opt-Wri';
                                                $html .= '<th colspan="5" data-ref="'.$row['shortName'].'" class="headerCaption">
                                                    P'.$sno.' '.$paperTypeStatus.'<br>'.$row['paperTotalMark'].' Mark
                                                </th>';
                                            }
                                            elseif ($row['paperType'] == 3) {
                                                $paperTypeStatus ='Thesis';
                                                $html .= '<th colspan="4" data-ref="'.$row['shortName'].'" class="headerCaption">
                                                    P'.$sno.' '.$paperTypeStatus.'<br>'.$row['paperTotalMark'].' Mark
                                                </th>';
                                            }
                                            elseif ($row['paperType'] == 4){
                                                $paperTypeStatus ='Viva';
                                                $html .= '<th colspan="4" data-ref="'.$row['shortName'].'" class="headerCaption">
                                                    P'.$sno.' '.$paperTypeStatus.'<br>'.$row['paperTotalMark'].' Mark
                                                </th>';
                                            }
                                            else{
                                                $paperTypeStatus ='';
                                            }
                                        }
                                    }
                                    $html .= '<th rowspan="2" colspan="2">Total</th>
                                    <th rowspan="2" colspan="2">Result</th>
                                </tr>
                                <tr>';
                                    if($paperDetails){
                                        $opt=0;
                                        $sno=0;
                                        foreach($paperDetails as $row1){
                                            $sno++;
                                            if($row1['examType'] != '2' && $row1['paperType'] == 1)
                                            {
                                                $html .= '<th>Int</th>
                                                <th>Ext</th>
                                                <th>Tot</th>
                                                <th>Res</th>';
                                            }elseif($row1['examType'] != '2' && $row1['paperType'] == 2)
                                            {
                                                $opt++;
                                                $html .= '<th>Sub</th>
                                                <th>Int</th>
                                                <th>Ext</th>
                                                <th>Tot</th>
                                                <th>Res</th>';
                                            }else{
                                                $html .= '<th colspan="2">Ext</th>
                                                <th>Tot</th>
                                                <th>Res</th>';
                                            }
                                        }
                                    }
                                $html .= '</tr>
                            </thead>
                            <tbody>';
                                $totalStudents = 0;
                                $i=0;
                                if($studentResults)
                                {                       
                                    foreach($studentResults as $row)
                                    {
                                        $academicYearId = $this->session->userdata('DBHPSCCISACADEMICYEAR');
                                        $totalStudents++;
                                        $grndTotal = 0;
                                        if($courseId == 2 && $row['registerNo'] !='' || $courseId == 6 && $row['registerNo'] !='' || $courseId == 9 && $row['registerNo'] !='' || $courseId == 10 && $row['registerNo'] !=''){
                                            $row['hallticketNumber'] = $row['registerNo'];
                                        }
                                        else{
                                            $row['hallticketNumber'] = $row['hallticketNumber'];
                                        }
                                        $html .= '<tr>
                                            <td>'.$totalStudents.'</td>
                                            <td class="showHallDiv">'.$row['hallticketNumber'].'</td>
                                            <td>'.$row['hallEncryptNumber'].'</td>';
                                            $studentMarkDetails = $this->allsabha_pg_results_model->get_mark_details_new($row['studentId'], $academicYearId, $courseId, $semesterId, $collegeId);
                                            $j=0;
                                            $paperTotal = 0;
                                            $stuStatus = '';
                                            $remark = "FAIL";
                                            if($studentMarkDetails){
                                                foreach ($studentMarkDetails as $studentMark){
                                                    $stuStatus[]= $studentMark['remark'];
                                                    if($optionalPaperDetails){
                                                        $optionalPapers = $optionalPaperDetails['optionalPapers'];
                                                        if($optionalPapers > 0){
                                                            $studentOptionalPaperName = $this->allsabha_pg_results_model->get_optional_paper_name($studentMark['paperId'], $academicYearId, $courseId, $semesterId, $row['studentId']);
                                                            if($studentOptionalPaperName){
                                                                $html .= '<td>'.$studentOptionalPaperName['shortName'].'</td>';
                                                            }
                                                        }
                                                    }
                                                    if($studentMark['examType'] != '2'){
                                                        if($studentMark['isInternalAbsent'] == 1){
                                                        $html .= '<td style="color:#F00;">A</td>';
                                                        }else{
                                                        $html .= '<td>'.$studentMark['internalMark'].'</td>';
                                                        }
                                                    }
                                                    if($studentMark['isExternalAbsent'] != 1 && $studentMark['isInternalAbsent'] != 1){
                                                        $mark =$studentMark['internalMark'] + $studentMark['externalMark'];
                                                    }
                                                    elseif($studentMark['isExternalAbsent'] == 1 && $studentMark['isInternalAbsent'] != 1){
                                                        $mark =$studentMark['internalMark'];
                                                    }
                                                    elseif($studentMark['isExternalAbsent'] != 1 && $studentMark['isInternalAbsent'] == 1){
                                                        $mark =$studentMark['externalMark'];
                                                    }
                                                    else{
                                                        $mark =0;
                                                    }
                                                    
                                                    $paperTotal += $mark ;
                                                            
                                                    if($studentMark['examType'] != '2' && $studentMark['examType'] != '3')
                                                    {   
                                                        if($studentMark['isExternalAbsent'] == 1){
                                                        $html .= '<td style="color:#F00;">A</td>
                                                        <td colspan="1">-</td>';
                                                        }else{
                                                        $html .= '<td>'.$studentMark['externalMark'].'</td>
                                                        <td colspan="1">'.$mark.'</td>';
                                                        }
                                                    }else{
                                                        if($studentMark['isExternalAbsent'] == 1){
                                                        $html .= '<td colspan="2" style="color:#F00;">A</td>
                                                        <td colspan="1">-</td>';
                                                        }else{
                                                        $html .= '<td colspan="2">'.$studentMark['externalMark'].'</td>
                                                        <td colspan="1">'.$mark.'</td>';
                                                        }
                                                    }
                                                    $html .= '<td>';
                                                        $color="";
                                                        $relVal = '';
                                                        if($studentMark['remark'] == "PASS" && $studentMark['isExternalAbsent'] != "1"){
                                                            $relVal = "P";
                                                            $color="color:#54A353;";
                                                        }
                                                        else if($studentMark['remark'] == "FAIL" && $studentMark['isExternalAbsent'] != "1"){
                                                            $relVal = "F";
                                                            $color="color:#F00;";
                                                        }
                                                        else{
                                                            $relVal = "-";
                                                        }
                                                        $html .= '<span style="'.$color.'">'.$relVal.'</span>
                                                    </td>';
                                                }
                                            }

                                            if($stuStatus){
                                                if(in_array('FAIL', $stuStatus)){
                                                    $status = 'FAIL';  
                                                }elseif(in_array('NULL', $stuStatus)){
                                                    $status = 'FAIL';  
                                                }else{
                                                    $status = 'PASS';
                                                } 
                                            }
                                            
                                            $html .= '<td colspan="2" class="bold total_'.$studentMark['hallticketNumber'].'" id="total_'.$studentMark['hallticketNumber'].'">'.$paperTotal.'</td>';
                                            if($status == "PASS"){
                                                $html .= '<td colspan="2" style="color: #54A353">'.$status.'</td>';
                                            }
                                            else{
                                                $html .= '<td colspan="2" style="color: #F00">'.$status.'</td>';
                                            }
                                        $html .= '</tr>';
                                    }
                                }
                            $html .= '</tbody>
                        </table>
             </div>
         </body>
  </html>';

  /*$pdf->writeHTML($html, true, false, true, false, '');
  $pdf->Output($center['collegeCentre'].'_'.$courseName['shortName'].'_'.$semester['semesterName'].'.pdf', 'D');*/
  pdf_create($html, 'Result_sheet'.date('Y-m-d'), TRUE);

Текущий выход

0 ответов

Другие вопросы по тегам