双语网站费用,找网页模板的网站,asp.net建立网站,wordpress上传视频大小Echarts图表Java后端生成请看上篇#xff0c;此篇为Base64图片插入Word文档中Java后台生成ECharts图片,并以Base64字符串返回_青冘的博客-CSDN博客 try {XWPFParagraph xwpfParagraphimage doc.createParagraph(); // 创建图片段落xwpfParagraphimage.setAlignment(Paragraph… Echarts图表Java后端生成请看上篇此篇为Base64图片插入Word文档中Java后台生成ECharts图片,并以Base64字符串返回_青冘的博客-CSDN博客 try {XWPFParagraph xwpfParagraphimage doc.createParagraph(); // 创建图片段落xwpfParagraphimage.setAlignment(ParagraphAlignment.CENTER);XWPFRun xwpfRunimage xwpfParagraphimage.createRun(); // 创建段落文本String jsonData echartsOption.getJsonDataZCRLQK();//获取OPT的Json配置EchartData echartData new Gson().fromJson(EchartData2Base64.echartToBase64(jsonData), EchartData.class);if (echartData.getCode() 1) {
// 依赖包sun.misc.BASE64DecoderBASE64Decoder decoder new BASE64Decoder();byte[] decoderBytes decoder.decodeBuffer(echartData.getData());InputStream imageis new ByteArrayInputStream(decoderBytes);BufferedImage imagebi ImageIO.read(new ByteArrayInputStream(decoderBytes));xwpfRunimage.addPicture(imageis, Document.PICTURE_TYPE_PNG, ,Units.pixelToEMU(Math.min(imagebi.getWidth(), 360)), Units.pixelToEMU(Math.min(imagebi.getHeight(), 240)));}} catch (Exception e) {throw new RuntimeException(e);}