【问题标题】:phpword how to change image position in headerphpword如何更改标题中的图像位置
【发布时间】:2018-05-06 20:13:46
【问题描述】:

我的图片当前位于页面顶部,代码如下。我想通过在代码中添加marginTop=> 200 来降低图像的位置,但它不起作用。事实上,我已经尝试了我所知道的一切,但都失败了。有谁知道如何在phpword的标题中更改图像的位置?

$header = $section->addHeader();
$header->firstPage();
$header->addImage(
  '../images/logo/AVA-Full-Logo-Grey.jpg',
  array(
    'width'            => 250,
    'wrappingStyle'    => 'square',
    'marginTop'        => 200,
    'positioning'      => 'relative',
    'posHorizontal'    => PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_RIGHT,
    'posHorizontalRel' => 'margin',
    'posVerticalRel'   => 'line',
  )
);

【问题讨论】:

标签: php jquery html phpword


【解决方案1】:
$section->addHeader()->addWatermark("./image.png",
array(
    'width' => round(\PhpOffice\PhpWord\Shared\Converter::cmToPixel(0.5842)),
    'height' => round(\PhpOffice\PhpWord\Shared\Converter::cmToPixel(2.1336)),
    'positioning' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE,
    'posHorizontal' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE,
    'posVertical' => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE,
    'marginLeft' => round(\PhpOffice\PhpWord\Shared\Converter::cmToPixel(17)),
    'marginTop' => round(\PhpOffice\PhpWord\Shared\Converter::cmToPixel(-0.5)),
    'wrappingStyle' => 'infront'
));

此代码对我有用。您需要将定位方式设置为“绝对”,然后您可以通过更改“marginLeft”和“marginTop”参数来调整位置。

【讨论】:

    【解决方案2】:

    经过很多这样的例子,它对我有用:

    $header = $section->addHeader();
    $header->addWatermark(JPATH_SITE.'/libraries/PHPWord-master/headerandfooter/image.png', array('width' => 535, 'height' => 535,'marginTop' => round(\PhpOffice\PhpWord\Shared\Converter::cmToPixel(5.25)),'posHorizontal' => 'absolute','posVertical' => 'absolute'));
    

    【讨论】:

      猜你喜欢
      • 2011-10-29
      • 1970-01-01
      • 2022-10-12
      • 2013-08-26
      • 1970-01-01
      • 1970-01-01
      • 2021-05-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多