java实现在pdf文件中定位添加图片

所有文件不能存盘,获取文件的方法只有网络地址。
签名图片是前端传回来的base64字符串,使用技术有限制pdfbox,希望得到代码。

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