【问题标题】:Create right floating image in PhpWord在 PhpWord 中创建右浮动图像
【发布时间】:2015-12-15 10:16:14
【问题描述】:

我想要一张图片在右边,左边的文字在图片周围浮动。反之亦然,Recipies section in the documentation 上也有一个例子。但是,我没有使用右侧浮动的图像进行此操作。我尝试了什么:

addImage('myimage.png', 
   array(
       'width'=>320, 
       'height'=>240, 
       'align'=>'right',
       'wrappingStyle'=>'square',
       'positioning' => 'absolute'
   )
);

或

addImage('myimage.png', 
   array(
       'width'=>320, 
       'height'=>240, 
       'align'=>'right',
       'wrappingStyle'=>'square',
       'positioning' => 'absolute',
       'posHorizontalRel' => 'margin',
       'posVerticalRel' => 'line'
   )
);

我还尝试了负图像宽度等,但这也没有用。不幸的是,整个项目的文档真的很差,至少在phpword.readthedocs.org。

【问题讨论】:

    标签: php phpword


    【解决方案1】:

    我也遇到了同样的问题,到目前为止,互联网上还没有答案。所以这就是我想出的:

    $section->addImage('image.png', array(
        'width' => 40,
        'height' => 40,
        'wrappingStyle' => 'square',
        'positioning' => 'absolute',
        'posHorizontal'    => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_RIGHT,
        'posHorizontalRel' => 'margin',
        'posVerticalRel' => 'line',
    ));
    

    【讨论】:

    • 是的——正是我想要的。有趣的是,您可以使用“页面”而不是边距;)
    猜你喜欢
    • 1970-01-01
    • 2013-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-19
    • 2011-12-15
    • 2017-02-19
    • 1970-01-01
    相关资源
    最近更新 更多