1,xml模版文件設定方法
<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"/>
圖片上的文字。。。
。。。
注重點:圖片上的文字在模版中出現的位置必須在圖片之后,否則灰色背景會覆蓋掉文字
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。將文件轉化成字節數組。
3。將字節數組放入到pdf的template所用的map中,即可
4.IOUtils的導入(import org.apache.commons.io.IOUtils;)
新聞熱點
疑難解答