1,xml模版文件設(shè)定方法
<image
uri="%String_IMAGE_TEST1%"
x="0.0" y="0.3"
width="53.0" height="5.2"/>
圖片上的文字。。。
。。。
。。。
<image
uri="%String_IMAGE_TEST2%"
x="53.209" y="0.25"
width="18.258" height="5.2"/>
圖片上的文字。。。
。。。
注重點(diǎn):圖片上的文字在模版中出現(xiàn)的位置必須在圖片之后,否則灰色背景會(huì)覆蓋掉文字
2,java文件中使用方法,
String $temppath = request.getRealPath("/") + "images/";
String $picpath = $temppath + "gray.JPG";
byte[] $tempbyte = IOUtils.toByteArray(new FileInputStream($picpath));
topMap.put("IMAGE_TEST1",$tempbyte);
topMap.put("IMAGE_TEST2",$tempbyte);
簡單說明,
1。獲得server端保存image文件的目錄和文件的名稱。
2。將文件轉(zhuǎn)化成字節(jié)數(shù)組。
3。將字節(jié)數(shù)組放入到pdf的template所用的map中,即可
4.IOUtils的導(dǎo)入(import org.apache.commons.io.IOUtils;)
|
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注