【问题标题】:Create TextBox without a border in PHPWord在 PHPWord 中创建无边框的 TextBox
【发布时间】:2017-01-20 12:52:24
【问题描述】:

我正在尝试在 PHPWord 中创建一个没有边框的 TextBox,但是将 borderColorborderSize 设置为 0null 没有任何效果,而且我总是在文本框周围至少有一个黑色边框.

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$textbox = $section->addTextBox(
    array(
        'alignment'   => \PhpOffice\PhpWord\SimpleType\Jc::END,
        'width'       => 200,
        'height'      => 40,
        'borderColor' => null,
        'borderSize'  => 0,
    )
);
$textbox->addText('dummy-text ...', null, array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END));
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord);
$objWriter->save('dummy.docx');

【问题讨论】:

    标签: php phpword


    【解决方案1】:

    要创建一个没有边框的边框,您可以使用 (git issue: no outline textbox):

    'borderSize' => 'none'
    

    测试并使用 PhpWord 0.13.0 并使用 MsWord 打开生成的文档(libreoffice 似乎无法识别此设置)

    【讨论】:

    • 好吧,我在问之前发现了这个,但不幸的是它对我不起作用。如果我使用代码 $section->addTextBox(array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::START, 'width' => 260, 'height' => 120, 'borderSize' => 'none')); 我最终在 Word for Mac 版本 15.30 中使用 this result
    • 如果我按照链接中的建议使用'borderColor' => 'none',这对我也不起作用
    • 作为临时解决方案,我将borderColor 设置为与文档的背景颜色相同,例如'borderColor' => 'white'
    【解决方案2】:

    如果有人仍在寻找 PHPWord 0.17 中的答案,则以下解决方案有效:

    'borderColor' => 'none'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-18
      • 2017-02-19
      • 2016-03-18
      • 2018-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-25
      相关资源
      最近更新 更多