提问人:Premlatha 提问时间:11/14/2023 更新时间:11/14/2023 访问量:34
从 phpword 生成 PDF 时将无边框设置为表格不起作用
set no border to table not working when generate pdf from phpword
问:
我使用phpword创建了表。单元格 1 有边框,单元格 2 没有边框。当我生成pdf时,整个表格都带有边框。我使用tcpdf渲染器生成pdf
<?php
include_once '../vendor/autoload.php';
$phpWord = new \PhpOffice\PhpWord\PhpWord();
use PhpOffice\PhpWord\Element\Table;
use PhpOffice\PhpWord\TemplateProcessor;
use PhpOffice\PhpWord\ComplexType\TblWidth;
use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\SimpleType\Border;
$styleCell1 = array('borderColor' =>'black', 'borderSize' => 6);
$styleCell2 = array('borderColor' =>'black', 'borderSize' => 0,'borderStyle' => Border::NONE);
$section = $phpWord->addSection();
$table = $section->addTable('testing');
//$table = new Table();
$table->addRow();
$table->addCell(700,$styleCell1)->addText('cell 1');
$table->addCell(500,$styleCell2)->addText('cell 2');
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('1411_testingTable.docx');
Settings::setPdfRendererPath('../vendor/tecnickcom/tcpdf');
Settings::setPdfRendererName(Settings::PDF_RENDERER_TCPDF);
$phpWord->save('1411_testingTable.pdf','PDF');
docx 输出:
答: 暂无答案
评论