【问题标题】:How to make the table responsive when exporting from Mysql via PHP with EZPDF使用 EZPDF 通过 PHP 从 Mysql 导出时如何使表格响应
【发布时间】:2015-11-06 12:51:19
【问题描述】:

我在通过 php 显示来自 mysql 的 ezpdf 数据时遇到问题。 Description 的内容很长,所以导出时会通过纸张。有没有办法解决这个问题?

<?php session_start();
require 'config.php';
require 'class.ezpdf.php';
require 'cek/cek_session.php';

$sql  = mysqli_query($conn, "SELECT * FROM arsip WHERE unitkerja = '$sesen_uk' ORDER BY id_arsip ASC");
$i    = 1;
if (mysqli_num_rows($sql) > 0)
{
  while($tampil = mysqli_fetch_array($sql)) 
  {
    $data[$i] = array ( 'No'      => $i,
                    'Description'        => $tampil['desc'],
                    'Department'        => $tampil['dpt'],
                    'Location' => $tampil['location'],
                  );
            $i++;
  }  

  $pdf = new Cezpdf('A4','landscape');
  $pdf->ezSetCmMargins(1, 3, 3, 3);
  $pdf->ezText('Report', 17, array('justification' => 'center'));
  $pdf->ezSetDy(-10);

  $pdf->ezTable($data, '', '', '');
  $pdf->ezSetDy(-50);

  $pdf->ezStartPageNumbers(799,50, 10, 4);
  $pdf->ezStream();
}  
  else
  {
    echo '<script>alert("Belum ada data");location.replace("report.php")</script>';
 }
 ?>

输出应该是这样的:

http://tinypic.com/r/2zyl9xj/9

任何帮助都会很棒,谢谢。

【问题讨论】:

    标签: php mysql pdf export


    【解决方案1】:

    您可以在选项中添加宽度,如下所示:

       $options=array(
    
            'width'=>550
    
           );
    
    $pdf->ezTable($data,$cols='',$title='',$options);
    

    文本将被换行

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-04
      • 1970-01-01
      • 1970-01-01
      • 2021-08-04
      • 1970-01-01
      相关资源
      最近更新 更多