【问题标题】:Full line background color全线背景颜色
【发布时间】:2019-09-19 13:53:37
【问题描述】:

我的 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);

有人可以帮助我吗?

【问题讨论】:

    标签: php phpword


    【解决方案1】:

    我对 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/

    【讨论】:

      猜你喜欢
      • 2011-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-07
      • 2012-09-30
      • 2013-04-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多