php - 在 PhpWord 中创建右浮动图像

标签 php phpword

我想要右边的图片,左边的文字围绕着图片 float 。反过来效果很好,在 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。 .

最佳答案

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

$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',
));

关于php - 在 PhpWord 中创建右浮动图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34286454/

相关文章:

php - 服务器上的 SQL 查询返回 SQL 错误,而在本地主机上工作正常

php - 未选择 MySQL 数据库。我哪里错过了?

php - Cakephp beforeFilter 与构造函数

php - 根据父 ID 从四个数组创建多维数组

php - 使用 PHPWord 下载 DOCX 文件时出现损坏的文件

php - Laravel 路线,具有 1 个必需参数和可选的无限参数

PHPWord:使用 Laravel 4 插入分页符并设置边距和页面方向

php - 如何在phpword中将列表添加到加载的模板

php - 使用phpword将html转换为word

php - 从 PHPWord 生成的 .docx 生成 PDF