1. 需求
ftl模板文件 也就是freemark
2. 实现
<#if (image != "")><w:pict><w:binData w:name=${image1}>${image}
</w:binData><v:shape id="_x0000_s1027" o:spt="75" alt="" type="#_x0000_t75" style="height:25.5pt;width:92pt;" filled="f" o:preferrelative="t" stroked="f" coordsize="21600,21600"><v:path/><v:fill on="f" focussize="0,0"/><v:stroke on="f"/><v:imagedata src="wordml://1.png" o:title="wordml://03000001.png"/><o:lock v:ext="edit" aspectratio="t"/><w10:wrap type="none"/><w10:anchorlock/></v:shape></w:pict></#if>
<#if (image != "")>
pic的标签内容
</#if>
这里的image是个变量,把所有的图片标签判断一下即可。
freemark 的模板语言也是支持if判断的~
今天解决了这个问题也算是长见识了。(之前生成WPS 打开ok 但是word打开会出现图片是一个X的情况)
本文详细介绍了如何使用Freemarker模板语言在文档中条件性地插入图片,解决了图片在不同文档编辑软件中显示的问题,如WPS与Word之间的兼容性。

8113

被折叠的 条评论
为什么被折叠?



