‘壹’ php 中 把html生成word时,里面需要盖一个电子公章。试了背景图片,定位都不行,求助大神。
我也遇到导出html成word时,背景图片显示不了,用定位也不管有,你是怎么解决的
‘贰’ thinkPHP5.0怎么在生成的word中加入图片
如果使用的是phpword插件操作word 可以看下这篇
‘叁’ 使用phpword 如何才能在一个表格中的某个单元格 插入多张图片
require_once 'PHPWord.php';
$PHPWord = new PHPWord();
$section = $PHPWord->createSection();
//定义样式数组
$styleTable = array(
'borderSize'=>6,
'borderColor'=>'006699',
'cellMargin'=>80
);
$styleFirstRow = array(
'borderBottomSize'=>18,
'borderBottomColor'=>'0000ff',
'bgColor'=>'66bbff'
);
//定义单元格样式数组
$styleCell = array('valign'=>'center');
$styleCellBTLR = array('valign'=>'center','textDirection'=>PHPWord_Style_Cell::TEXT_DIR_BTLR);
//定义第一行的字体
$fontStyle = array('bold'=>true,'align'=>'center');
//添加表格样式
$PHPWord->addTableStyle('myOwnTableStyle',$styleTable,$styleFirstRow);
//添加表格
$table = $section->addTable('myOwnTableStyle');
‘肆’ php 如何将word 转换为 html 或者图片
word另存为html吧,
‘伍’ php导出word和pdf文件
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
//有了这些,可以把带html标签的html源码导入到word里,并且可以保持html的样式。
/*
<STYLE>
BR.page { page-break-after: always }
</STYLE>
在<head>部分加这个是为了实现打印的时候分页
*/
$wordStr = '<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<STYLE>
BR.page { page-break-after: always }
</STYLE>
</head><body>';
$wordStr = "<b>hello</b><p>this is html code</p>";
$wordStr .= '</body></html>';
//防止导出乱码
$file = iconv("utf-8", "GBK", $filename);
header("Content-Type: application/doc");
header("Content-Disposition: attachment; filename=" . $file . ".doc");
echo $wordStr;
?>
<?php
header("Content-type:application/pdf");
// 文件将被称为 downloaded.pdf
header("Content-Disposition:attachment;filename='downloaded.pdf'");
// PDF 源在 original.pdf 中
readfile("original.pdf");
?>
‘陆’ PHPword怎么在载入的模板中插入一张图片
在word文档中,插入一个图片作为背景的操作步骤:
1、单击页面布局---页面颜色----填充效果;
2、弹出填充效果对话框,单击选择图片按钮;
3、弹出选择图片对话框,选择所需要的图片即可,如图所示。