所有文件不能存盘,获取文件的方法只有网络地址。
签名图片是前端传回来的base64字符串,使用技术有限制pdfbox,希望得到代码。
java实现在pdf文件中定位添加图片
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
CSDN专家-赖老师(软件之家) 2021-08-05 10:40关注base64编码字符直接保存为文件就可以了。
/** * 将BASE64字符串恢复为二进制数据 * * @param base64String * @return */ public static byte[] decode(String base64String) { try { return Base64.decodeBase64(base64String.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { return null; } } /** * 将base64字符解码保存文件 * * @param base64Code * @param targetPath * @throws Exception */ public static void decoderBase64File(String base64Code, String targetPath) throws Exception { byte[] buffer = decode(base64Code); FileOutputStream out = new FileOutputStream(targetPath); out.write(buffer); out.close(); }解决评论 打赏 举报无用 1