从 phpword 生成 PDF 时将无边框设置为表格不起作用

set no border to table not working when generate pdf from phpword

提问人:Premlatha 提问时间:11/14/2023 更新时间:11/14/2023 访问量:34

问:

我使用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 输出:

enter image description here

PDF输出: output

php 边框 tcpdf phpword

评论

0赞 KIKO Software 11/14/2023
尝试将单元格 2 的边框涂成白色,也许这会有所帮助?
0赞 Premlatha 11/15/2023
我已经试过了,仍然有pdf的边框

答: 暂无答案