首页 > 学院 > 开发设计 > 正文

PDF背景灰色图片设定方法

2019-11-18 11:34:36
字体:
来源:转载
供稿:网友

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;)



发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表