问题描述
当标头为空时,我可以添加水印,但是当标头不为空时,我不能添加水印。
我有一个单词文档“ test_doc.docx”,其中的标题中写有一些文本,并且有3页,而3页的标题中有相同的文本。
当我下载文件时-
下面是我的代码-
$filename = "test_doc.docx";
$file_path = APPPATH."templates/test_doc.docx";
$PHPWord = \PHPOffice\PHPWord\IOFactory::load($file_path);
$PHPWord->getCompatibility()->setooxmlVersion(14);
$PHPWord->getCompatibility()->setooxmlVersion(15);
$sections = $PHPWord->getSections();
$section = $sections[0];
// get all headers
$headers = $section->getHeaders();
if (empty($headers)) {
// inside when header is empty
$header = $section->addHeader();
} else {
// inside when header is not empty
$header = $headers[1];
}
$header->addWatermark(IMG.'help.png',array('marginTop' => 100,'marginLeft' => 20));
$PHPWord->save($filename,'Word2007',true);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)