删除 PHPWord 标头图像透明度



如何使用 PHPWord 库删除透明表单标题图像?我的代码是

    $phpWord = new PhpWord();
    $phpWord->setDefaultFontName('Calibri');
    $phpWord->setDefaultFontSize(10);
    $sectionStyle = [];
    $section = $phpWord->addSection($sectionStyle);
    $header = $section->addHeader();
    $header->addImage(
        resource_path('assets/images/finlab.png'), [
            'width' => 100,
            'marginTop' => 100,
            'posHorizontal' => 'right',
            'positioning' => 'absolute',
            'align' => 'right'
        ]
    );

现在图像在半透明的标题中。

当您使用resource_path时,您将获得图像URL,但要删除透明度,您需要使用实际的图像路径而不是图像URL。

$image=getcwd().'/assets/images/finlab.png'; //or whatever your image path is.
$header->addImage(
        $image, [
            'width' => 100,
            'marginTop' => 100,
            'posHorizontal' => 'right',
            'positioning' => 'absolute',
            'align' => 'right'
        ]
    );

最新更新