freemark中插入图片

freemark文件中的图片格式是BASE64,

模板中的图片代码块,${(img)!}是图片变量

<w:pict>
	  <v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
		<v:stroke joinstyle="miter"/>
		<v:formulas>
		  <v:f eqn="if lineDrawn pixelLineWidth 0"/>
		  <v:f eqn="sum @0 1 0"/>
		  <v:f eqn="sum 0 0 @1"/>
		  <v:f eqn="prod @2 1 2"/>
		  <v:f eqn="prod @3 21600 pixelWidth"/>
		  <v:f eqn="prod @3 21600 pixelHeight"/>
		  <v:f eqn="sum @0 0 1"/>
		  <v:f eqn="prod @6 1 2"/>
		  <v:f eqn="prod @7 21600 pixelWidth"/>
		  <v:f eqn="sum @8 21600 0"/>
		  <v:f eqn="prod @7 21600 pixelHeight"/>
		  <v:f eqn="sum @10 21600 0"/>
		</v:formulas>
		<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
		<o:lock v:ext="edit" aspectratio="t"/>
	  </v:shapetype>
	  <w:binData w:name="wordml://02000001.jpg" xml:space="preserve">${(img)!}</w:binData>                  
	<v:shape id="_x0000_i1025" type="#_x0000_t75" style="width:69pt;height:62.25pt">                    
		<v:imagedata src="wordml://02000001.jpg" o:title="timg"/>                  
	</v:shape>                
</w:pict>

生成${(img)!}图片变量(BASE64格式)

public String getEmpAutograph(String filePath) {
		String img =null;
		if(StringUtils.isNotEmpty(filePath)){
			InputStream in = null;
			byte[] picdata = null;
			try {
				in = new FileInputStream(filePath);
				picdata = new byte[in.available()];
				in.read(picdata);
			} catch (Exception e) {
				e.printStackTrace();
			}finally{
				try {
					in.close();
				} catch (IOException e) {
					
					e.printStackTrace();
				}
			}
			BASE64Encoder encoder = new BASE64Encoder();
			img = encoder.encode(picdata);
			return img;
		}else{
			return null;
		}
	}

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值