php图片怎么向左对齐,如何在phpWord中并排对齐文本和图像?

我需要并排对齐徽标和文字.但是当生成word文档时,文本总是位于徽标图像下方.我尝试了这里指出的解决方案:

http://phpword.codeplex.com/discussions/232684

但它对我不起作用.

这是我试过的(不是上面提到的解决方案)

$section = $PHPWord->createSection();

$image = $section->addImage('_mars.jpg',array ('width'=>100));

// Add table

$table = $section->addTable();

for($r = 1; $r <= 1; $r++) { // Loop through rows

// Add row

$table->addRow();

for($c = 1; $c <= 1; $c++) { // Loop through cells

// Add Cell

//I tried adding image in this line.

$table->addCell(1750)->addText("Row $r,Cell ".

$section->addImage('_mars.jpg',array('width'=>100)));

}

}

我收到了这个错误

$section->addImage() partCatchable fatal error: Object of class PHPWord_Section_Image could not be converted to string in

谁能告诉我如何在表格单元格中添加图像?

解决方法:

你应该使用文本运行:

$section = $PHPWord->createSection();

$image = $section->addImage('_mars.jpg',array ('width'=>100));

// Add table

$table = $section->addTable();

for($r = 1; $r <= 1; $r++) { // Loop through rows

// Add row

$table->addRow();

for($c = 1; $c <= 1; $c++) { // Loop through cells

// Add Cell

$cell = $table->addCell(1750);

$textrun = $cell->createTextRun();

$textrun->addText("Row $r,Cell ");

$textrun->addImage('_mars.jpg',array('width'=>100));

}

}

标签:php,phpword

来源: https://codeday.me/bug/20190612/1226572.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值