0

我在垂直旋转 pdf 单元测试时遇到问题。我不想添加新的旋转单元格。我想旋转现有的单元格文本。我正在使用 Yii 和 tcpdf 库。

我目前正在使用:

        $pdf->Rotate(-90);
        $pdf->Cell(0,0,'22-01-2020',1,1,'L',0,'');
        $pdf->StopTransform()

添加一个新的旋转单元格。但我想旋转一个现有的单元格。请帮助我。

4

1 回答 1

0

简单$pdf->StartTransform();的你想要旋转的单元格在哪里:

$pdf->StartTransform();
$pdf->Rotate(-90);
$pdf->Cell(0,0,'22-01-2020',1,1,'L',0,'');  // CELL YOU WANT
$pdf->StopTransform()

使用您的代码进行编辑:

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
spl_autoload_register(array('YiiBase','autoload'));
$pdf->SetCreator(PDF_CREATOR);
$pdf->AddPage();  
$mydata = array('name' => 'test');      
$postdata = http_build_query($mydata);
$opts = array('http' =>
   array(
   'method'  => 'POST',
   'header'  => 'Content-Type: application/x-www-form-urlencoded',
   'content' => $postdata
  )
);
$context  = stream_context_create($opts);
$html_path = 'testpdf.php';
$html = file_get_contents($html_path, false, $context);
$pdf->StartTransform();
$pdf->Rotate(-90);
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->StopTransform();
$pdf->lastPage();
$fileNL = 'test.pdf';
$pdf->Output($fileNL, 'I');

编辑 2
代码仅旋转第一列:

$(document).ready(function() {
  $('.rotate').css('height', $('.rotate').width());
});
td {
  border-collapse: collapse;
  border: 1px black solid;
}
tr:nth-of-type(5) td:nth-of-type(1) {
  visibility: hidden;
}
.rotate {
  /* FF3.5+ */
  -moz-transform: rotate(-90.0deg);
  /* Opera 10.5 */
  -o-transform: rotate(-90.0deg);
  /* Saf3.1+, Chrome */
  -webkit-transform: rotate(-90.0deg);
  /* IE6,IE7 */
  filter: progid: DXImageTransform.Microsoft.BasicImage(rotation=0.083);
  /* IE8 */
  -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083)";
  /* Standard */
  transform: rotate(-90.0deg);
}
<h2>HTML Table</h2>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td>
      <div class='rotate'>90 DEGREE ROW</div>
    </td>
    <td>B</td>
    <td>C</td>
    <td>D</td>
    <td>E</td>
  </tr>
  <tr>
    <td>
      <div class='rotate'>90 DEGREE ROW</div>
    </td>
    <td>G</td>
    <td>H</td>
    <td>I</td>
    <td>J</td>
  </tr>
  <tr>
    <td>
      <div class='rotate'>90 DEGREE ROW</div>
    </td>
    <td>L</td>
    <td>M</td>
    <td>N</td>
    <td>O</td>
  </tr>


</table>

于 2020-01-31T08:10:39.347 回答