刚开始自己写的时候上网搜帖子,相信大家都看见了,千篇一律很多东西压根就不提,做了好几天,终于成形了。好了,立马分享!

好了,首先是我的js部分,这里是highchars的方法获取图片字符串直接提交到了后台

$(function(){dayTime('chooseTime');//时间插件  默认当日日期query_survey();//点击查询Highcharts.wrap(Highcharts.Chart.prototype, 'getSVG', function (proceed) {return proceed.call(this).replace(/(fill|stroke)="rgba\(([ 0-9]+,[ 0-9]+,[ 0-9]+),([ 0-9\.]+)\)"/g, '$1="rgb($2)" $1-opacity="$3"');});
});
$("#btn_word").on("click", function() {var chart_1 = $("#regist_no_service").highcharts();var chart_2 = $("#app_proto_top10").highcharts();var chart_3 = $("#hot_app_top10_one").highcharts();var chart_4 = $("#active_terminal_two").highcharts();var chart_5 = $("#regist_no_hidde").highcharts();var svg_1 = chart_1.getSVG();var svg_2 = chart_2.getSVG();var svg_3 = chart_3.getSVG();var svg_4 = chart_4.getSVG();var svg_5 = chart_5.getSVG();var svg = svg_1+"_"+svg_2+"_"+svg_3+"_"+svg_4+"_"+svg_5;$("#svg").val(svg);$("#form1").prop("action", ctx +"/surey/export?type=word").submit();
});$("#btn_pdf").on("click", function() {var chart_1 = $("#regist_no_service").highcharts();var chart_2 = $("#app_proto_top10").highcharts();var chart_3 = $("#hot_app_top10_one").highcharts();var chart_4 = $("#active_terminal_two").highcharts();var svg_1 = chart_1.getSVG();var svg_2 = chart_2.getSVG();var svg_3 = chart_3.getSVG();var svg_4 = chart_4.getSVG();var svg = svg_1+"_"+svg_2+"_"+svg_3+"_"+svg_4;$("#svg").val(svg);$("#form1").prop("action", ctx +"/surey/export?type=pdf").submit();
});

接着,是Controller层,下面传参之前调用的几个方法不要在意,大家去掉就可以了,根据自己情况需要传参

@RequestMapping("export")public  void exportWord(HttpServletRequest request, HttpServletResponse response,String type,String chooseTime, String proto_type) throws Exception {response.setContentType("application/octet-stream; charset=UTF-8");if ("word".equals(type)) {response.setHeader("content-disposition", "attachment;filename="+ new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".doc");} else if ("pdf".equals(type)) {response.setHeader("content-disposition", "attachment;filename="+ new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss").format(new Date()) + ".pdf");}String svg1 = request.getParameter("svg");// highcharts图表svgCodeSystem.out.println(svg1);String svgCode = svg1.replaceAll("<", "<").replaceAll(">", ">");System.out.println(svgCode);String svg[] = svgCode.split("_");String path[] = new String[svg.length];OutputStream out = response.getOutputStream();ItextManager tm = ItextManager.getInstance();List<String> imageList = new ArrayList<String>();if (svg != null) {for (int k = 0; k < svg.length; k++) {UUID uuid  =  UUID.randomUUID();String picName = uuid + ".png";path[k] = request.getSession().getServletContext().getRealPath("/upload/" + picName);imageList.add(path[k]);SvgPngConverter.convertToPng(svg[k], path[k]);}}//热点应用TOP10列表chooseTime = "2015-06-23";List<Map<String,Object>> hostAppList=new ArrayList<Map<String,Object>>();hostAppList = (List<Map<String, Object>>) this.hots_app(chooseTime);//活跃终端TOP10列表List<Map<String,Object>> result=new ArrayList<Map<String,Object>>();result = (List<Map<String, Object>>) this.active_terminal_hist(chooseTime);//网络访问概况Map<String,Object>resultMap=new HashMap<String, Object>();resultMap = (Map<String, Object>) this.default_data(chooseTime);//TCP已登记服务数和未登记服务数proto_type = "tcp";Map<String,Object>resultMap1=new HashMap<String, Object>();resultMap1 = (Map<String, Object>) this.udp_tcp_num(chooseTime, proto_type);//UDP已登记服务数和未登记服务数proto_type = "udp";Map<String,Object>resultMap2=new HashMap<String, Object>();resultMap2 = (Map<String, Object>) this.udp_tcp_num(chooseTime, proto_type);tm.createRtfContext(imageList, out, type, hostAppList, result, resultMap, resultMap1, resultMap2);out.flush();out.close();}

然后是工具类

package mdstack.srvmon.util;import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.image.PNGTranscoder;/***@Description: 将svg转换为png格式的图片*/
public class SvgPngConverter {/** *@Description: 将svg字符串转换为png *@Author: *@param svgCode svg代码 *@param pngFilePath  保存的路径 *@throws IOException io异常 *@throws TranscoderException svg代码异常 */  public static void convertToPng(String svgCode,String pngFilePath) throws IOException,TranscoderException{  File file = new File (pngFilePath);  FileOutputStream outputStream = null;  try {  file.createNewFile ();  outputStream = new FileOutputStream (file);  convertToPng (svgCode, outputStream);  } finally {  if (outputStream != null) {  try {  outputStream.close ();  } catch (IOException e) {  e.printStackTrace ();  }  }  }  }  /** *@Description: 将svgCode转换成png文件,直接输出到流中 *@param svgCode svg代码 *@param outputStream 输出流 *@throws TranscoderException 异常 *@throws IOException io异常 */  public static void convertToPng(String svgCode,OutputStream outputStream) throws TranscoderException,IOException{  try {  byte[] bytes = svgCode.getBytes ("UTF-8");  PNGTranscoder t = new PNGTranscoder ();  TranscoderInput input = new TranscoderInput (new ByteArrayInputStream (bytes));  TranscoderOutput output = new TranscoderOutput (outputStream);  t.transcode (input, output);  outputStream.flush ();  } finally {  if (outputStream != null) {  try {  outputStream.close ();  } catch (IOException e) {  e.printStackTrace ();  }  }  }  }
}

最重要的部分,Itext生成部分,代码写的比较垃圾,还没有整理好,刚做出来的,见谅。其中表格占据了很大的空间,因为有需求,直接用table满足不了,所以添加了cell。刚出效果,代码还在更改。

package mdstack.srvmon.util;import java.awt.Color;
import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;import com.lowagie.text.Cell;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.HeaderFooter;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.Rectangle;
import com.lowagie.text.Table;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.rtf.RtfWriter2;
import com.lowagie.text.rtf.headerfooter.RtfHeaderFooter;
import com.lowagie.text.rtf.style.RtfParagraphStyle;/*** IText操作类* @author shyh**/
public class ItextManager {private Font font;private BaseFont bfChinese;public ItextManager() throws Exception {// 设置中文字体
//      bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", false);font = new Font(bfChinese);font.setSize(30);font.setStyle(FontFactory.HELVETICA);font.setColor(new Color(0,0,0));}public static ItextManager getInstance() throws Exception {return new ItextManager();}@SuppressWarnings({ "unused", "unchecked" })public void createRtfContext(List<String> imgList, OutputStream out,String type, List<Map<String, Object>> hostAppList, List<Map<String, Object>> result, Map<String, Object> resultMap, Map<String, Object> resultMap1, Map<String, Object> resultMap2) {Document doc = new Document(PageSize.A4.rotate(), 80, 80, 80, 80);//word横向展示try {if("word".equals(type)){RtfWriter2.getInstance(doc, out);}else if("pdf".equals(type)){PdfWriter.getInstance(doc, out);}
//              // 添加页脚
//              HeaderFooter footer = new HeaderFooter(new Phrase("footer"), false);
//              footer.setAlignment(Rectangle.ALIGN_CENTER);
//              doc.setFooter(footer);Image headerImage = Image.getInstance("D:/yemei.jpg"); // 创建有1行2列的表格  Table tables = new Table(2, 1); // 设置table的边框宽度为0  tables.setBorderWidth(1f); tables.setWidth(100);  // 设置表格右对齐,其中1为居中对齐,2为右对齐,3为左对齐  tables.setAlignment(1); // 设置各列的宽度  int[] widthss = { 300, 300 }; tables.setWidths(widthss); // 创建单元格,并且将单元格内容设置为图片  Cell cells = new Cell(); cells = new Cell(headerImage); cells.setBorder(0);tables.addCell(cells); cells.setVerticalAlignment(3);  // 设置垂直居中  cells.setHorizontalAlignment(3);  // 设置水平居中  cells = new Cell("机器数据分析平台"); cells.setBorder(0);tables.addCell(cells);cells.setVerticalAlignment(2);  // 设置垂直居中  cells.setHorizontalAlignment(2);  // 设置水平居中  RtfHeaderFooter header1 = new RtfHeaderFooter(tables);header1.setAlignment(tables.MARKED);doc.setHeader(header1);doc.open();//第一级标题样式RtfParagraphStyle rtfGsBt1 = RtfParagraphStyle.STYLE_HEADING_1;rtfGsBt1.setAlignment(Element.ALIGN_LEFT);rtfGsBt1.setStyle(Font.BOLD);rtfGsBt1.setSize(15);//第二级标题样式RtfParagraphStyle rtfGsBt2 = RtfParagraphStyle.STYLE_HEADING_2;rtfGsBt2.setAlignment(Element.ALIGN_LEFT);rtfGsBt2.setStyle(Font.BOLD);rtfGsBt2.setSize(13);//设置带有目录格式的标题(标题1格式)
//              Paragraph title = new Paragraph(titleStr);
//              // 设置标题格式对齐方式
//              title.setAlignment(elementAlign);
//              title.setFont(titleFont);  Paragraph title = new Paragraph("网络访问概况");title.setAlignment(Element.ALIGN_CENTER);title.setFont(font);doc.add(title);// 设置标题格式对齐方式
//              Paragraph title1 = new Paragraph("一、网络访问概况");
//              title.setFont(rtfGsBt1);
//              doc.add(title1);Paragraph title2 = new Paragraph("1.1网络访问数量");// 设置标题格式对齐方式  title2.setFont(rtfGsBt2);doc.add(title2);//网络访问概况:Map<String,Object>titleMap=resultMap;String t1 = titleMap.get("network_count").toString().substring(5,10);String t2 = titleMap.get("network_host_count").toString().substring(7,10);String t3 = titleMap.get("flow_fz").toString();String t4 = titleMap.get("flow_aver").toString();// 正文字体风格  Font contextFont = new Font(bfChinese, 10, Element.ALIGN_CENTER);  Paragraph context = new Paragraph("网络服务访问次数:"+t1+"次\n提供服务主机数量:"+t2+"台\n网络流量峰值:"+t3+"\n网络流量平均值:"+t4+"");  //设置行距  context.setLeading(3f);// 正文格式左对齐  context.setFont(contextFont);  // 离上一段落(标题)空的行数  context.setSpacingBefore(1);// 设置第一行空的列数  context.setFirstLineIndent(20);  doc.add(context);  //               Paragraph title3 = new Paragraph("1.2 TCP/UDP服务");
//              // 设置标题格式对齐方式
//              title.setFont(rtfGsBt2);
//              doc.add(title3);Paragraph title3 = new Paragraph("1.2 TCP/UDP服务");// 设置标题格式对齐方式  title3.setFont(rtfGsBt2);doc.add(title3);// 创建有三行的表格  Table table = new Table(2, 3); // 设置table的边框宽度为0  table.setBorderWidth(1f); table.setWidth(100);  // 设置表格右对齐,其中1为居中对齐,2为右对齐,3为左对齐  table.setAlignment(3); // 设置各列的宽度  int[] widths = { 200, 200 }; table.setWidths(widths); // table.setPadding(0);  // table.setSpacing(0); Image img = null;img = Image.getInstance(imgList.get(0));float heigth = img.getHeight();float width = img.getWidth();int percent = getPercent3(heigth, width);img.setAlignment(Image.LEFT);//图片居左显示img.scalePercent(percent + 3);// 表示是原来图像的比例;Image img4 = null;img4 = Image.getInstance(imgList.get(4));float heigth4 = img4.getHeight();float width4 = img4.getWidth();int percent4 = getPercent3(heigth4, width4);img4.setAlignment(Image.LEFT);//图片居左显示img4.scalePercent(percent4 + 3);// 表示是原来图像的比例;//已登记服务数和未登记服务数Map<String,Object>titleMap1=resultMap1;String d1 = titleMap1.get("count_service").toString().substring(7,9);String d2 = titleMap1.get("regist_service").toString().substring(7,8);Map<String,Object>titleMap2=resultMap2;String u1 = titleMap2.get("count_service").toString().substring(7,10);String u2 = titleMap2.get("regist_service").toString().substring(7,8);// 创建单元格,并且将单元格内容设置为图片  Cell cell = new Cell(); cell = new Cell("TCP"); cell.setBorder(0);table.addCell(cell); cell = new Cell("UDP"); cell.setBorder(0);table.addCell(cell);cell = new Cell("已登记服务数:"+d2); cell.setBorder(0);table.addCell(cell); cell = new Cell("已登记服务数:"+u2); cell.setBorder(0);table.addCell(cell); cell = new Cell("未登记服务数:"+d1); cell.setBorder(0);table.addCell(cell); cell = new Cell("未登记服务数:"+u1); cell.setBorder(0);table.addCell(cell); cell = new Cell(img); cell.setBorder(0);// 设置单元格边框为0  table.addCell(cell); cell.setVerticalAlignment(1);  // 设置垂直居中  cell.setHorizontalAlignment(1);  // 设置水平居中  cell = new Cell(img4); cell.setBorder(0);cell.setVerticalAlignment(1); cell.setHorizontalAlignment(1); table.addCell(cell); doc.add(table);doc.newPage();Paragraph title4 = new Paragraph("二、应用服务TOP10:");title.setFont(rtfGsBt1);doc.add(title4);Image img1 = null;img1 = Image.getInstance(imgList.get(1));float heigth1 = img1.getHeight();float width1 = img1.getWidth();int percent1 = getPercent3(heigth1, width1);img1.setAlignment(Image.ALIGN_CENTER);//图片居右显示img1.scalePercent(percent1 + 3);// 表示是原来图像的比例;doc.add(img1);Paragraph title7 = new Paragraph("2.1热点应用Top10");// 设置标题格式对齐方式  title7.setFont(rtfGsBt2);doc.add(title7);// 创建有9行的表格  Table table2 = new Table(9,10); // 设置table的边框宽度为0  table2.setBorderWidth(1f); table2.setWidth(100);  // 设置表格右对齐,其中1为居中对齐,2为右对齐,3为左对齐  table2.setAlignment(3); // 设置各列的宽度  int[] widths2 = { 5,15,10,10,10,10,10,10,10}; table2.setWidths(widths2); Cell cell2 = new Cell(); cell2 = new Cell("序号"); table2.addCell(cell2); cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1); cell2 = new Cell("资产名称"); table2.addCell(cell2);cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1); cell2 = new Cell("IP"); table2.addCell(cell2); cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1); cell2 = new Cell("TCP:端口"); table2.addCell(cell2); cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1); cell2 = new Cell("会话数"); table2.addCell(cell2); cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1); cell2 = new Cell("字节数"); table2.addCell(cell2); cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1); cell2 = new Cell("数据字节数"); table2.addCell(cell2); cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1); cell2 = new Cell("包数"); table2.addCell(cell2); cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1); cell2 = new Cell("来访IP数"); table2.addCell(cell2); cell2.setVerticalAlignment(1);  // 设置垂直居中  cell2.setHorizontalAlignment(1);  // 设置水平居中  for(int i=0; i<hostAppList.size(); i++){Map<String, Object> map = hostAppList.get(i);cell2 = new Cell(""+(i+1));table2.addCell(cell2);cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1);cell2 = new Cell((map.get("assetname")).toString());table2.addCell(cell2);cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1);cell2 = new Cell((map.get("ip")).toString());table2.addCell(cell2);cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1);cell2 = new Cell((map.get("service")).toString());table2.addCell(cell2);cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1);cell2 = new Cell((""+map.get("sessions")+""));table2.addCell(cell2);cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1);cell2 = new Cell((map.get("bytes")).toString());table2.addCell(cell2);cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1);cell2 = new Cell((map.get("dbytes")).toString());table2.addCell(cell2);cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1);cell2 = new Cell((map.get("packets")).toString());table2.addCell(cell2);cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1);cell2 = new Cell((map.get("visitor_ip")).toString());table2.addCell(cell2);cell2.setVerticalAlignment(1);  cell2.setHorizontalAlignment(1);}doc.add(table2);doc.newPage();Paragraph title5 = new Paragraph("2.2选择活跃终端TOP10展现指标");title5.setFont(rtfGsBt2);doc.add(title5);Image img2 = null;img2 = Image.getInstance(imgList.get(2));float heigth2 = img2.getHeight();float width2 = img2.getWidth();int percent2 = getPercent(heigth2, width2);img2.setAlignment(Image.MIDDLE);//图片居中显示img2.scalePercent(percent2 + 3);// 表示是原来图像的比例;doc.add(img2);doc.newPage();Paragraph title6 = new Paragraph("2.3活跃终端top10");// 设置标题格式对齐方式  title6.setFont(rtfGsBt2);doc.add(title6);Image img3 = null;// 图片img3 = Image.getInstance(imgList.get(3));float heigth3 = img3.getHeight();float width3 = img3.getWidth();int percent3 = getPercent(heigth3, width3);img3.setAlignment(Image.MIDDLE);//图片居中显示img3.scalePercent(percent3 + 3);// 表示是原来图像的比例;doc.add(img3);doc.newPage();Paragraph title8 = new Paragraph("2.4活跃终端top10");// 设置标题格式对齐方式  title8.setFont(rtfGsBt2);doc.add(title8);// 创建有三行的表格  Table table3 = new Table(8,10); // 设置table的边框宽度为0  table3.setBorderWidth(1f); table3.setWidth(100);  // 设置表格右对齐,其中1为居中对齐,2为右对齐,3为左对齐  table3.setAlignment(3); // 设置各列的宽度  int[] widths3 = { 5,15,10,15,10,10,10,10}; table3.setWidths(widths3); Cell cell3 = new Cell(); cell3 = new Cell("序号"); table3.addCell(cell3); cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1); cell3 = new Cell("资产名称"); table3.addCell(cell3);cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1); cell3 = new Cell("IP"); table3.addCell(cell3); cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1); cell3 = new Cell("所属地域"); table3.addCell(cell3); cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1); cell3 = new Cell("会话数"); table3.addCell(cell3); cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1); cell3 = new Cell("字节数"); table3.addCell(cell3); cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1); cell3 = new Cell("数据字节数"); table3.addCell(cell3); cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1); cell3 = new Cell("包数"); table3.addCell(cell3); cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1); for(int i=0; i<result.size(); i++){Map<String, Object> res = result.get(i);cell3 = new Cell(""+(i+1));table3.addCell(cell3);cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1);cell3 = new Cell((res.get("assetname")).toString());table3.addCell(cell3);cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1);cell3 = new Cell((res.get("ip")).toString());table3.addCell(cell3);cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1);cell3 = new Cell((""+res.get("coun_reg_city"+"")));table3.addCell(cell3);cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1);cell3 = new Cell((res.get("sessions").toString()));table3.addCell(cell3);cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1);cell3 = new Cell((res.get("bytes")).toString());table3.addCell(cell3);cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1);cell3 = new Cell((res.get("dbytes")).toString());table3.addCell(cell3);cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1);cell3 = new Cell((res.get("packets")).toString());table3.addCell(cell3);cell3.setVerticalAlignment(1);  cell3.setHorizontalAlignment(1);}doc.add(table3);doc.close();} catch (DocumentException e) {e.printStackTrace();} catch (MalformedURLException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}/*** 第一种解决方案 在不改变图片形状的同时,判断,如果h>w,则按h压缩,否则在w>h或w=h的情况下,按宽度压缩* * @param h* @param w* @return*/public static int getPercent(float h, float w) {int p = 0;float p2 = 0.0f;p2 = 297 / h * 100;p = Math.round(p2);return p;}/*** 第二种解决方案,统一按照宽度压缩 这样来的效果是,所有图片的宽度是相等的.* * @param args*/public static int getPercent2(float h, float w) {int p = 0;float p2 = 0.0f;p2 = 530 / w * 80;p = Math.round(p2);return p;}/*** 第三种解决方案,将图片统一按照固定的大小来压缩,只适用于个别图片* * @param args*/public static int getPercent3(float h, float w) {int p = 0; float p2 = 0.0f;p2 = 530 / w * 35;p2 = 530 / h * 35;p = Math.round(p2);return p;}
}

到这里,发张我生成的图片。

第一次发帖子,不知道怎么写,有问题的还可以加我QQ:857309275  希望可以帮你解决!

Java使用iText生成word文 表格、图片、表格里插图片、页眉、页脚、图片页脚、(学习帖)相关推荐

  1. spring使用freemarker生成word文档包含表格、图片(循环插入)

    spring使用freemarker生成word文档包含表格.图片(循环插入) 效果图 因为测试数据是重复的,所以显示都是重复的数据,替换导入map中的数据可以显示不重复的数据. 操作步骤 1,创建一 ...

  2. Java使用freemarker生成word文档并转pdf文档

    Java使用freemarker生成word文档后转pdf 先来看看效果图 进入正题 项目需求: 为订单后生成对应的pdf文档,文档内包含图片. 方案一:使用freemarker和itext把html ...

  3. Java使用poi-tl生成word文档

    Java使用poi-tl生成word文档,可以对模板文件进行文本替换,图片.表格.超链接添加.图表处理等.大概的说明都在代码注释里,只有一个地方需要注意,就是图表的替换,占位符{{barChart}} ...

  4. java itext 生成word文档

    /**       *  创建word文档 步骤:          * 1,建立文档          * 2,创建一个书写器          * 3,打开文档          * 4,向文档中 ...

  5. Java使用iText生成word文件的完美解决方案(亲测可行)

    JAVA生成WORD文件的方法目前有以下种: 一种是jacob 但是局限于windows平台 往往许多JAVA程序运行于其他操作系统 在此不讨论该方案 一种是pio但是他的excel处理很程序 wor ...

  6. Java使用iText生成word文件的完美解决方案

    Java生成WORD文件的方法目前有以下种: 一种是jacob 但是局限于windows平台 往往许多JAVA程序运行于其他操作系统 在此不讨论该方案 一种是pio但是他的excel处理很程序 wor ...

  7. java使用iText生成pdf文档的对齐方式

    一.前言 在企业的信息系统中,报表处理一直占比较重要的作用,本文将介绍一种生成PDF报表的Java组件--iText.通过在服务器端使用Jsp或JavaBean生成PDF报表,客户端采用超级连接显示或 ...

  8. Java通过freemarker生成word文档

    文档生成目录 摘要 项目预期效果 使用freemaker生成word文档并下载 一:导入所需要的maven依赖 二:根据word文档生成我们需要的ftl模板文件 三:将word需要的数据存入一个map ...

  9. JSP学习笔记(四十九):抛弃POI,使用iText生成Word文档

    POI操作excel的确很优秀,操作word的功能却不敢令人恭维.我们可以利用iText生成rtf文档,扩展名使用doc即可. 使用iText生成rtf,除了iText的包外,还需要额外的一个支持rt ...

最新文章

  1. Linux学习之系统编程篇:程序、进程、并发、并行
  2. python语言程序设计实践教程答案实验六_20192417 实验一《Python程序设计》实验报告...
  3. java 异常 过滤器_在过滤器Filter中抛出一个全局异常可以捕获的异常
  4. python开启多个端口服务_python bottle使用多个端口(多个进程)提高并发
  5. linux设置程序循环,linux shell编程学习笔记(7)流程控制之循环结构
  6. nutz 自定义sql的使用
  7. Repeater实现批量删除
  8. fedora14 安装
  9. 搭建自己的聊天室平台、公司内部聊天平台,Rocket.Chat搭建及使用
  10. 查看linux进程日志,查看linux日志_查看linux日志的方法
  11. 从游戏商业思维中分析游戏用户行为数据(主要是参考网上的一些感想)
  12. 别人都不知道的“好用”网站,让你的效率飞快
  13. 在gitee上建自己的博客
  14. mongodb之快速入门
  15. JAVA EE面试重点
  16. Machine Learning with Graphs:Part1
  17. 互联网医院源码|互联网医院软件体现智慧医疗的优势
  18. 2.8.1利用“直流扫描分析”测试基本共射放大电路电压传输特性
  19. 数据库基本概念amp;SQL简介
  20. 数据结构-16枚硬币问题

热门文章

  1. 第十七届智能车竞赛 - 磁力计角度数据处理
  2. 掌握这六步,搭建完美的机器学习项目
  3. 杂学第八篇:最近成功实现用applescript检测手机号码是否注册imessage,有需要的带价联系
  4. 香港正值流感高峰期 191间幼儿园19日起停课7日
  5. 解读《领域驱动设计 软件核心复杂性应对之道》(一)
  6. linux看视频插件,Linux系统下安装Adobe Flash Player插件观播放视频
  7. java毕业设计二手图书回收销售网站Mybatis+系统+数据库+调试部署
  8. Normalized and Geometry-Aware Self-Attention Network for Image Captioning阅读笔记
  9. Kubernetes 固定 Pod IP 地址方法
  10. 京东校招java工程师_2017年京东校招Java研发笔试编程第1题