『壹』 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、彈出選擇圖片對話框,選擇所需要的圖片即可,如圖所示。