我在使用phpword(https://phpword.readthedocs.io/en/latest/index.html)时遇到问题
我想创建一条线,其中所有背景都是一种颜色(宽度为100%),但是我只能将背景设置为文本的大小。
$titleStyle=array('name' => 'Calibri','size' => 11, 'align' =>'center','marginTop' => 10,'bgColor' => 'd0cece');
// Create a new table style
$table_style = new \PhpOffice\PhpWord\Style\Table;
$table_style->setUnit(\PhpOffice\PhpWord\Style\Table::WIDTH_PERCENT);
$table_style->setWidth(100 * 50);
$table_style->setBgColor('d0cece');
// Set up our table.
$tableTitle = $section->addTable($table_style);
$tableTitle->addRow();
$tableTitle->addCell()->addText('Identificação pessoal',$titleStyle);
有人可以帮助我吗?
答案 0 :(得分:0)
我对PhpWord不太熟悉,但是您是否尝试过将单元格的宽度设置为文档的100%?
$titleStyle = array(
'name' => 'Calibri',
'size' => 11,
'align' =>'center',
'marginTop' => 10,
'bgColor' => 'd0cece',
'width' => 11905.51181102
);
根据我在文档中看到的内容,像元宽度需要以twip
单位提供,从210mm转换后为11905.51181102
(A4页面宽度)
https://www.translatorscafe.com/unit-converter/en/typography/1-3/twip-centimeter/