利用freemarker技术,填充word模板(插入图片)

此处做简要说明:

   在模板中添加图片占位,另存时候,将图片的base64编码全部删除,附上变量。替换的时候注意图片转码问题,其他地方不变。

   

private String getImageStr(String imgFile) {
        InputStream in = null;
        byte[] data = null;
        try {
            in = new FileInputStream(imgFile);
            data = new byte[in.available()];
            in.read(data);
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        BASE64Encoder encoder = new BASE64Encoder();
        return encoder.encode(data);
    }


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章