(转)IText导出word之页眉页脚页…

itext操作word生成目录、页码、表格、插入图片 NULL 博文链接:https://oneinit.iteye.com/blog/1529917 立即下载

原文地址:http://blog.youkuaiyun.com/cuiran/article/details/8164753


package com.cayden.web.base;

import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.cayden.web.action.qybj.QueryProducesAction;
import com.cayden.web.domain.qybj.QybjCompany;
import com.cayden.web.domain.qybj.QybjProduce;
import com.cayden.web.domain.qybj.QybjProduceDevice;
import com.cayden.web.domain.qybj.QybjProduceParam;
import com.cayden.web.dto.qybj.QybjProduceDto;
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.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.Table;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.rtf.RtfWriter2;
import com.lowagie.text.rtf.field.RtfPageNumber;
import com.lowagie.text.rtf.field.RtfTotalPageNumber;
import com.lowagie.text.rtf.headerfooter.RtfHeaderFooter;


public class WordServer {
 private static Log log = LogFactory.getLog(WordServer.class.getName());
 
 public String createRTFContext(String filename,QybjProduceDto dto) throws DocumentException,IOException {
  String path="";
  String imagepath="";
  try{
   
   QybjProduce qybjProduce=dto.getQybjProduce();
   List devices=dto.getPdevices();
   List   params=dto.getPparams();
   QybjCompany qybjCompany=dto.getQybjCompany();
   
   
   
   
   URL url=WordServer.class.getClassLoader().getResource("") ;
   path=url.getPath().replace("WEB-INF/classes/", "file/"+filename + ".rtf");
   imagepath=url.getPath().replace("WEB-INF/classes/", qybjCompany.getImagepath());
   Document document = new Document(PageSize.A4);
   
   RtfWriter2 rtfWriter2=RtfWriter2.getInstance(document, new FileOutputStream(path));
   
   
   
   document.open();
   
   
   // 设置中文字体
   
   BaseFont bfChinese = BaseFont.createFont("STSongStd-Light",
  
   "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
  
   // 标题字体风格
  
   Font titleFont = new Font(bfChinese, 12, Font.BOLD);
   
   Font titleBaoFont = new Font(bfChinese, 20, Font.BOLD);
   
   Font underLineFont = new Font(bfChinese, 12, Font.UNDERLINE);
  
   // 正文字体风格
  
   Font contextFont = new Font(bfChinese, 10, Font.NORMAL);
   
   // 正文标题1 风格
   
   Font contextTitle1Font = new Font(bfChinese, 12, Font.NORMAL);
  
   //设置加粗字体
   Font boldFont = new Font(bfChinese, 10, Font.BOLD);
   
   
  
   
//   Paragraph title = new Paragraph("标题");
//   // 设置标题格式对齐方式
//   title.setAlignment(Element.ALIGN_CENTER);
//   title.setFont(titleFont);
////   document.add(title);
//   String contextString = "iText是一个能够快速产生PDF文件的java类库。iText的java类对于那些要产生包含文本,表格,图形的只读文档是很有用的。它的类库尤其与java Servlet有很好的给合。使用iText与PDF能够使你正确的控制Servlet的输出。";
//   Paragraph context = new Paragraph(contextString);
//   // 正文格式左对齐
//   context.setAlignment(Element.ALIGN_LEFT);
//   context.setFont(contextFont);
//   // 离上一段落(标题)空的行数
//   context.setSpacingBefore(20);
//   // 设置第一行空的列数
//   context.setFirstLineIndent(20);
////   document.add(context);
   
   
   
   Paragraph producename = new Paragraph(qybjProduce.getProducename(), titleFont);
   document.add(producename);
   Paragraph  bjpriceText =  new Paragraph("    报     价:", titleFont);
   Paragraph  bjprice = new Paragraph(qybjProduce.getPrice(), underLineFont);
   Paragraph  bjdateText =   new Paragraph("     报价日期:", titleFont);
   Paragraph  bjdate = new Paragraph(qybjProduce.getBjdate(), underLineFont);
   Paragraph customerText = new Paragraph("    客户单位:", titleFont);
   Paragraph customer = new Paragraph(qybjProduce.getCompany(), underLineFont);
   Paragraph linkManText = new Paragraph("     联 系 人:", titleFont);
   Paragraph linkMan = new Paragraph(qybjProduce.getLinkman(), underLineFont);
   
   
   Paragraph faxText = new Paragraph("    传    真:", titleFont);
   Paragraph fax = new Paragraph(qybjProduce.getLinkfax(), underLineFont);
   Paragraph linkPhoneText = new Paragraph("     联系电话:", titleFont);
   Paragraph linkPhone = new Paragraph(qybjProduce.getLinkphone(), underLineFont);
   
   
   

   Paragraph bjCol=new Paragraph();
   bjCol.add(bjpriceText);
   bjCol.add(customerText);
   bjCol.add(faxText);
   
   
     Table tableProduce = new Table(4,3); 
     float[] widths = { 0.2f, 0.4f, 0.2f, 0.2f };
     tableProduce.setWidths(widths);
     tableProduce.setBorderWidth(1);
     tableProduce.setBorder(0);
     tableProduce.setBorderColor(Color.BLACK); 
     tableProduce.setPadding(0); 
     tableProduce.setSpacing(0);
     tableProduce.setWidth(100f);
   
     Cell cell0 = new Cell();//报价标签单元格
     cell0.add(bjpriceText);
//     cell0.setBorderWidth(0f);
     tableProduce.addCell(cell0);
    
     cell0 = new Cell();//报价价格单元格
     cell0.add(bjprice);
//     cell0.setBorderWidth(0f);
     tableProduce.addCell(cell0);
    
     cell0 = new Cell();//报价日期标签单元格
     cell0.add(bjdateText);
     tableProduce.addCell(cell0);
    
     cell0 = new Cell();//报价日期单元格
     cell0.add(bjdate);
     tableProduce.addCell(cell0);
    
     cell0 = new Cell();//客户单位标签 单元格
     cell0.add(customerText);
     tableProduce.addCell(cell0);
    
     cell0 = new Cell();//客户单位单元格
     cell0.add(customer);
     tableProduce.addCell(cell0);
    
    
     cell0 = new Cell();//联系人标签 单元格
     cell0.add(linkManText);
     tableProduce.addCell(cell0);
    
     cell0 = new Cell();//联系人单元格
     cell0.add(linkMan);
     tableProduce.addCell(cell0);
    
    
     cell0 = new Cell();//传真标签 单元格
     cell0.add(faxText);
     tableProduce.addCell(cell0);
    
     cell0 = new Cell();//传真单元格
     cell0.add(fax);
     tableProduce.addCell(cell0);
    
    
     cell0 = new Cell();//联系电话标签 单元格
     cell0.add(linkPhoneText);
     tableProduce.addCell(cell0);
    
     cell0 = new Cell();//联系电话单元格
     cell0.add(linkPhone);
     tableProduce.addCell(cell0);
    
    
    
   document.add(tableProduce);
   
   
   
   
   Paragraph   remarkText =    new Paragraph(qybjProduce.getRemark(), contextFont);
   
   remarkText.setAlignment(Paragraph.ALIGN_CENTER);
   document.add(remarkText);
   
   Paragraph   paramTitleText =    new Paragraph("一. 主要技术参数:", contextTitle1Font);
   
   document.add(paramTitleText);
   
   
    Table tableMainParam = new Table(3,params.size()); 
     float[] widthMainParams = { 0.08f, 0.3f, 0.62f};
     tableMainParam.setWidths(widthMainParams);
     tableMainParam.setBorderWidth(1);
     tableMainParam.setBorder(0);
     tableMainParam.setBorderColor(Color.BLACK); 
     tableMainParam.setPadding(0); 
     tableMainParam.setSpacing(0);
     tableMainParam.setWidth(100f);
    
     for(int i=0;i
      Cell cellParam = new Cell();//单元格
     
      QybjProduceParam param=params.get(i);
      Paragraph xuhaoText = new Paragraph((i+1)+".", contextFont);
      cellParam.add(xuhaoText);
      tableMainParam.addCell(cellParam);
     
      cellParam = new Cell();//参数名字
      Paragraph paramNameText = new Paragraph(param.getParamename(), contextFont);
      cellParam.add(paramNameText);
      tableMainParam.addCell(cellParam);
     
     
      cellParam = new Cell();//参数值
      Paragraph paramValueText = new Paragraph(param.getParamevalue(), contextFont);
      cellParam.add(paramValueText);
      tableMainParam.addCell(cellParam);
     
     }
     document.add(tableMainParam);
   
    
   
   Paragraph  deviceTitleText =    new Paragraph("二. 设备配置: ", contextTitle1Font);
   document.add(deviceTitleText);
   
    Table tableDevice = new Table(7,devices.size()); 
     float[] widthDevices = { 0.04f, 0.2f,0.2f,0.08f,0.08f, 0.2f,0.2f};
     tableDevice.setWidths(widthDevices);
     tableDevice.setBorderWidth(1);
     tableDevice.setBorder(0);
     tableDevice.setBorderColor(Color.BLACK); 
     tableDevice.setPadding(0); 
     tableDevice.setSpacing(0);
     tableDevice.setWidth(100f);
   
    
   Cell  cellDevice0 = new Cell(); 
     Paragraph xuhao = new Paragraph("序号", contextFont);
     xuhao.setAlignment(Paragraph.ALIGN_CENTER);
     cellDevice0.add(xuhao);
     tableDevice.addCell(cellDevice0);
    
     cellDevice0 = new Cell(); 
     xuhao = new Paragraph("设备名称", contextFont);
     xuhao.setAlignment(Paragraph.ALIGN_CENTER);
     cellDevice0.add(xuhao);
     tableDevice.addCell(cellDevice0);
    
     cellDevice0 = new Cell(); 
     xuhao = new Paragraph("规格", contextFont);
     xuhao.setAlignment(Paragraph.ALIGN_CENTER);
     cellDevice0.add(xuhao);
     tableDevice.addCell(cellDevice0);
    
     cellDevice0 = new Cell(); 
     xuhao = new Paragraph("数量", contextFont);
     xuhao.setAlignment(Paragraph.ALIGN_CENTER);
     cellDevice0.add(xuhao);
     tableDevice.addCell(cellDevice0);
    
     cellDevice0 = new Cell(); 
     xuhao = new Paragraph("厂牌", contextFont);
     xuhao.setAlignment(Paragraph.ALIGN_CENTER);
     cellDevice0.add(xuhao);
     tableDevice.addCell(cellDevice0);
    
     cellDevice0 = new Cell(); 
     xuhao = new Paragraph("功能", contextFont);
     xuhao.setAlignment(Paragraph.ALIGN_CENTER);
     cellDevice0.add(xuhao);
     tableDevice.addCell(cellDevice0);
    
    
     cellDevice0 = new Cell(); 
     xuhao = new Paragraph("备注", contextFont);
     xuhao.setAlignment(Paragraph.ALIGN_CENTER);
     cellDevice0.add(xuhao);
     tableDevice.addCell(cellDevice0);
    
     for(int i=0;i
      Cell cellParam = new Cell();//单元格
     
      QybjProduceDevice device=devices.get(i);
      Paragraph xuhaoText = new Paragraph((i+1)+".", contextFont);
      cellParam.add(xuhaoText);
      tableDevice.addCell(cellParam);
     
      cellParam = new Cell();//参数名字
      Paragraph deviceNameText = new Paragraph(device.getDevicename(), contextFont);
      cellParam.add(deviceNameText);
      tableDevice.addCell(cellParam);
     
     
      cellParam = new Cell();//参数值
      Paragraph sizeText = new Paragraph(device.getSize(), contextFont);
      cellParam.add(sizeText);
      tableDevice.addCell(cellParam);
     
      cellParam = new Cell();//参数值
      Paragraph amountText = new Paragraph(device.getAmount(), contextFont);
      cellParam.add(amountText);
      tableDevice.addCell(cellParam);
     
     
      cellParam = new Cell();//参数值
      Paragraph factoryText = new Paragraph(device.getFactory(), contextFont);
      cellParam.add(factoryText);
      tableDevice.addCell(cellParam);
     
      cellParam = new Cell();//参数值
      Paragraph funcText = new Paragraph(device.getFunc(), contextFont);
      cellParam.add(funcText);
      tableDevice.addCell(cellParam);
     
     
      cellParam = new Cell();//参数值
      Paragraph remark1Text = new Paragraph(device.getRemark(), contextFont);
      cellParam.add(remark1Text);
      tableDevice.addCell(cellParam);
     
     }
    
    
    
     document.add(tableDevice);
   
   Paragraph  specsTitleText =    new Paragraph("三. 设备构成规范: ", contextTitle1Font);
   
   document.add(specsTitleText);
   
   
    Table tableSpecs = new Table(2,devices.size()); 
     float[] widthSpecss = { 0.04f, 0.96f};
     tableSpecs.setWidths(widthSpecss);
     tableSpecs.setBorderWidth(1);
     tableSpecs.setBorder(0);
     tableSpecs.setBorderColor(Color.BLACK); 
     tableSpecs.setPadding(0); 
     tableSpecs.setSpacing(0);
     tableSpecs.setWidth(100f);
   
     for(int i=0;i
      Cell cellSpec = new Cell();//单元格
      QybjProduceDevice device=devices.get(i);
    
      Paragraph xuhaoText = new Paragraph((i+1)+".", contextFont);
      cellSpec.add(xuhaoText);
      cellSpec.setRowspan(2);//设置表格为2行 
      tableSpecs.addCell(cellSpec);
     
     
      cellSpec = new Cell();//规范名字
      Paragraph specNameText = new Paragraph(device.getSpecname(), contextFont);
      cellSpec.add(specNameText);
      tableSpecs.addCell(cellSpec);
     
      cellSpec = new Cell();//规范内容
      Paragraph specsText = new Paragraph(device.getSpecs(), contextFont);
      cellSpec.add(specsText);
      tableSpecs.addCell(cellSpec);
     }
    
   
     document.add(tableSpecs);
   
   
   Image headerImage = Image.getInstance(imagepath);  
   
      Paragraph headerPara2 = new Paragraph(qybjCompany.getCompanyname(), titleFont);
      headerPara2.setAlignment(HeaderFooter.ALIGN_CENTER);
 
   
         RtfHeaderFooter header1 = new RtfHeaderFooter(headerImage); 

   
    Paragraph headerPara1 = new Paragraph();
    headerPara1.add(headerPara2);
    headerPara1.add(header1); 
    headerPara1.setAlignment(HeaderFooter.ALIGN_CENTER);
   
    Phrase headerPara = new Phrase();  
   
   
      Table table = new Table(3,2); 
    
       table.setBorderWidth(1);
       table.setBorder(0);
       table.setBorderColor(Color.BLACK); 
       table.setPadding(0); 
       table.setSpacing(0);
//       table.setAlignment(Table.ALIGN_MIDDLE);

       table.setWidth(100f);
       Cell cell = new Cell(headerPara1);//单元格
//       cell.setBorderWidth(0f);  //设置表格没有边框
      
       cell.setHeader(true); 
       cell.setRowspan(2);//当前单元格占两行,纵向跨度 
       table.addCell(cell); 
       table.endHeaders();// 表头结束 
      
      
       Cell cellHeader = new Cell();
       Paragraph produceTitle=  new Paragraph(qybjProduce.getProducename(),titleFont);
       produceTitle.setAlignment(26nbsp;   table.addCell(cellHeader); 
      
       cellHeader = new Cell();
       Paragraph pTitle=;      cellHeader = new Cell();
     Paragraph parafooter = new Paragraph();
     parafooter.add(new Phrase("共"));
     parafooter.add(new RtfTotalPageNumber());//共几页
     parafooter.add(new Phrase("页"));
     parafooter.setAlignment(1);
     cellHeader.add(parafooter);
       table.addCell(cellHeader); 
      
       cellHeader = new Cell();
       Paragraph pTitle=  new Paragraph("报价单",titleBaoFont);
       pTitle.setAlignment(1);
       cellHeader.add(pTitle);
       cellHeader.setUseAscender(true);
       cellHeader.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中
       cellHeader.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中
       table.addCell(cellHeader); 
      
       cellHeader = new Cell();
       Paragraph para1footer = new Paragraph();
       para1footer.add(new Phrase("第"));
       para1footer.add(new RtfPageNumber());//第几页
       para1footer.add(new Phrase("页"));
       para1footer.setAlignment(1);
       cellHeader.add(para1footer);
       cellHeader.setUseAscender(true);
       cellHeader.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中
       cellHeader.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

       table.addCell(cellHeader); 
      
       headerPara.add(table);
    HeaderFooter header = new HeaderFooter(headerPara,false);
   
   header.setAlignment(HeaderFooter.ALIGN_CENTER);
   
   document.setHeader(header);

   
   Paragraph footerPara1 = new Paragraph("公司地址: "+qybjCompany.getCompanyaddr(), contextFont);  
   Paragraph footerPara2 = new Paragraph("销售热线: "+qybjCompany.getMoblephone()+"    "+qybjCompany.getLegalperson(), contextFont);  
   Paragraph footerPara3 = new Paragraph("此报价自报价之日起一个月内有效", titleFont);  
   Paragraph footerPara = new Paragraph();  
           footerPara.add(footerPara1);  
           footerPara.add(footerPara2);  
           footerPara.add(footerPara3);
   
   HeaderFooter footer = new HeaderFooter(footerPara,false);
   
   footer.setAlignment(HeaderFooter.ALIGN_LEFT);
   document.setFooter(footer);
   
  
   // //在表格末尾添加图片
  
//   Image png = Image.getInstance("c:/1.png");
 // 
//   document.add(png);
  
   document.close();
   
   
   
  }catch (Exception e) {
   // TODO: handle exception
   log.error("导出word出现异常:", e);
  }
  
  return path;
 }

 
 public static void main(String[] args) {
  // TODO Auto-generated method stub

 }

}

使用DeepSeek、MCP和AKShare实现智能金融问答系统技术方案 DeepSeek是由深度求索公司开发的大规模语言模型,最新版本DeepSeek-V3采用混合专家(MoE)架构,拥有671B参数,激活37B参数,在多项基准测试中表现优异3。要使用DeepSeek的API服务:访问DeepSeek平台注册账号获取API Key(形如AKShare是基于Python的金融数据接口库,提供股票、基金、期货、宏观经济等领域的海量数据。主要特点包括:免费开源,数据源丰富支持多种数据格式(DataFrame/JSON)持续更新维护安装命令。 阅读详情

相关推荐

Veeam Backup 13 通过UI界面高效备份VMware ESXi虚拟机的完整指南

本文提供了一份使用Veeam Backup 13图形化界面高效备份VMware ESXi虚拟机的完整指南。内容涵盖从环境准备、添加vCenter/ESXi主机、配置备份存储库,到创建备份任务、设置保留策略与计划,以及执行备份和验证成功的关键步骤。通过直观的UI操作,管理员可以轻松实现虚拟机数据的可靠保护与快速恢复。

weixin_29322553的博客 438

java导出pdf

//导出 public void ScoringAnnouncementdownLoad() throws MalformedURLException, IOException, DocumentException, FileStoreException { ActionContext act = ActionContext.getContext(); ...

aklnczz811147的博客 164

ComfyUI+minimaxh3本地部署:漫剧分镜批量生成工作流全实操

视频生成模型正从云端API向本地化部署迁移,背后的技术逻辑是将扩散模型的文本编码、潜空间采样、VAE解码等阶段拆分为可编排的独立环节。ComfyUI作为节点化管线工具,恰好能以可视化连线方式管理这些阶段,让生成过程可控、可复用、可批量执行。minimaxh3模型支持本地推理,配合LoRA微调与参数优化,能够在保证角色一致性的前提下,从分镜脚本批量产出连续剧情片段,规避云端排队、成本高、素材不可控等工程问题。这套工作流广泛应用于漫剧、短剧和动态条漫的工业化生产,尤其适合需要高频迭代分镜草稿的内容团队。文本以零

weixin_29057065的博客 365

【Itext】7步制作Itext5页眉页脚pdf实现第几页共几页

itext5页眉页脚工具类,实现page x of y 完美兼容各种格式大小文档A4/B5/B3,兼容各种文档格式自动计算页脚XY轴坐标 鉴于没人做的这么细致,自己就写了一个itext5页眉页脚工具类,实现第几页/共几页,方便各位刚进入itext的童鞋调用。2013年9月16日 14:51:01 背景:网上流传的都是一些简单的demo,直接扔个A4文档就说实现了,其实...

246

SATA硬件电路设计实战:从接口规范到高速布线技巧

本文深入探讨了SATA硬件电路设计的核心要点与实战技巧。从接口物理电气规范、AC耦合电容与阻抗控制等基础,到FPGA/SoC高速收发器选型配置,再到应对6Gbps高速信号的PCB布局布线艺术,系统性地解析了SATA电路设计中的关键挑战与解决方案,助力工程师规避常见陷阱,实现稳定可靠的存储接口设计。

tech5的博客 531

快速了解GPU分布通信技术:PCIe、NVLink与NVSwitch

PCIe(Peripheral Component Interconnect Express)是一种高速串行计算机扩展总线标准,广泛用于连接计算机的各种硬件设备。PCIe4.0是目前较为先进的版本,提供了高达64GB/s的带宽。InfiniBand是一种用于高性能计算的高速互连技术,通过交换机在节点之间直接创建一个专用的受保护通道。InfiniBand适配器通过PCIe接口连接到CPU,另一端通过InfiniBand网络端口连接到InfiniBand子网。

全世界的博客 7543

java 设置对齐方式_Java如何在iText中设置段落对齐方式?

要设置段落对象的对齐方式,可以使用段落.setAlignment()方法。我们可以传递常量,例如段落左对齐, 段落.u居中对齐, 段落右对齐setAlignment()方法。packageorg.nhooo.example.itextpdf;importcom.itextpdf.text.Chunk;importcom.itextpdf.text.Document;importcom.it...

weixin_40005454的博客 1900

制造业与工业知识图谱应用

在全球数字化转型背景下,制造业面临创新周期缩短、质量管控精细化等挑战。知识图谱技术通过结构化表示工业知识,为智能制造提供关键技术支撑。工业知识图谱具有专业性强、多源异构数据融合、实时性要求高等特点,其构建流程涵盖本体设计、知识抽取与整合等环节。研究显示,知识图谱与大模型结合可提升工业场景的智能化水平,在设备故障诊断、供应链优化等领域具有显著应用价值。该技术有望成为制造业数字化转型的核心驱动力。

分享一些感兴趣的技术方面 1443

在Web上用iText和JFreeChart将图形报表导出到PDF

最近项目中需要一个将生成的图形报表导出到PDF文件的功能。在图形上面本打算采用Flash进行展示,可是没有找到怎样直接将Flash导入PDF的方法,应该只有先生成图片才可以吧?(知道怎样做的大侠可以给个方法,先谢了。)于是改用JFreeChart来画图。生成PDF方面工具也很多,iText还比较成熟,于是选用它来生成PDF。 一开始本想图个省事,直接将网页转换成PDF文件。但是了n次后发现...

绿茶的快乐生活 524

第五节 Amesim《直动型溢流阀HCD建模》HCD5 学习资料

利用HCD原则创建直动型溢流阀的界面。这可能包括图形化表示直动型溢流阀的工作原理、操作方式和调节方法。这样的界面应当直观且易于理解,使用户能够轻松了解阀门的功能和使用方法。

m0_58052642的博客 1330

灰度发布、蓝绿部署、双活架构与数据同步/备份/迁移

本文系统介绍了现代互联网系统的核心部署策略与数据管理技术体系。主要内容包括:1)三种服务发布策略(灰度发布、蓝绿发布、滚动发布)的原理、实现方式和适用场景对比;2)高可用架构设计(同城双活、异地双活、异地多活)的技术方案;3)数据同步机制、备份策略与迁移方案的设计要点。文章通过架构图、流程图和配置示例详细展示了各类技术的实施方法,并分析了不同方案的优劣及风险控制措施,为构建高可用、高可靠的分布式系统提供了完整的技术指南。

zane的博客 515

java准确读取word文件页数

由于本人在做一个网上打印网站,遇到了一个需求是“准确读取word文件页数,从而实现计费功能”,通过很长时间的学习、查资料后,终于解决了这个问题,因此把方法写出来,方便有同样需求的人少走弯路。 (本方法已在一个上线的项目中使用,经过测试没有问题,大家遇到问题欢迎留言。)

天地炫舞的博客 5万+

uniapp [全端兼容] - 实现接入使用天地图及卫星视图切换功能,在国家天地图上自由切换地图显示类型(卫星视图/地形视图/卫星混合/地形混合/普通视图)天地图切换视图显示改成卫星风格,切换地图图层

uni-app,h5移动端网页,微信小程序,支付宝小程序,Android安卓,苹果ios,app,nvue,天地图,视图,卫星,地图类型切换,uniAPP天地图,改成卫星视角,在线地图切换,来回切换卫星图,天地图如何实现来回切换卫星图,地形图,卫星视图,VUE3引入天地图卫星版,详细教程示例源码代码,天地图切换卫星用什么api,卫星视角API方法,vue3卫星天地图,能改地图的显示方式,vue3中使用天地图自定义样式切换地图图层,切换报错,加载出错,卫星图太卡,地图图层更换,vue3安装集成天地图详细示例源

🏆 前端领域优质创作者 1万+

导出word的实例,包括页眉页脚还有图片

package com.lt.java; import java.awt.Color; import java.io.FileOutputStream; import com.lowagie.text.Cell; import com.lowagie.text.Chunk; import com.lowagie.text.Document; import com.lowagie.text.El

piesuit(小熊饼干) 5670

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

itext导出word

import java.io.FileOutputStream; import java.io.IOException; import java.util.Date; import com.lowagie.text.Cell; import com.lowagie.text.Document; import com.lowagie.text.DocumentException; import co...

qq_36725627的博客 851

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

IText导出word之页眉页脚页码

本文主要通过Itext jar包对已有数据进行封装并导出rtf文档。rtf也可以用office打开。代码中包含了设置页眉页脚、添加table等详细见源码:内含注释说明/** * WordServer.java * 版权所有(C) 2012 * 创建:cuiran 2012-11-07 13:20:40 */ package com.cayden.web.base; imp

小崔的博客 8808

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

itext操作word,设置页眉页脚,html转word

itext操作word方法设置页眉页脚标题内容图片及html转word

qq_33923326的博客 903

[转]IText导出word之页眉页脚页码

本文主要通过Itext jar包对已有数据进行封装并导出rtf文档。rtf也可以用office打开。 代码中包含了设置页眉页脚、添加table等 详细见源码:内含注释说明 /** * WordServer.java * 版权所有(C) 2012 * 创建:cuiran 2012-11-07 13:20:40 */ www.2cto.com package com.

fdz2004的专栏 962

使用ITEXT导出PDF、WORD,APACHE POI导出EXCEL报表文件

    描述: 最近在项目开发中,需要导出对账单报表信息为PDF、WORD和EXCEL,经过资料收集导出文件的实现方式很多,也有许多可使用的开源jar包。经选择,使用IText导出PDF和Word、POI导出excel比较实用,且功能强大,能满足需求。下面将代码和jar包分享出来,希望对大家有帮助: package com.szkingdom.kfit.util; import ja...

yanqiang19900602的博客 577

java itext word操作_iText操作Word工具类

packagecom.loongtao.report.util;importjava.io.FileNotFoundException;importjava.io.FileOutputStream;importjava.io.IOException;importjava.net.MalformedURLException;importcom.lowagie.text.BadElemen...

weixin_35214204的博客 603

java生成word两种_java生成word文档【一】

/*** expWordByFtl方法主要用于-采用模板(freemarker)的方式导出数据到word.* 优缺点-操作方便,但是设置模板有些繁杂.* 使用方法-1、建立模板文档,2、另存为xml文件,3、将格式xml改为ftl,4、采用freemarker语法编辑ftl文件.* 第三方jar-freemarker-2.3.19.jar.* import freemarker.template....

weixin_39559015的博客 423

iTEXT将html文档转PDF,spire.doc包html转word(包括样式修改和添加图片/页码等设置)

项目需求 iText介绍 spire.pdf / spire.doc 介绍 spire.pdf / spire.doc 冰蓝科技 中文文档 html转pdf 引入jar包 引入itext仓库 <repository> <id>itext</id> <name>iText Reposito...

weixin_43179501的博客 3730

linux下word模板操作及PDF处理笔记

最近尝试在linux下处理word文档模板,并转为PDF进行处理,网上搜罗不少资料,记录下来备忘。   业务需求:有一批WORD文档模板,通过系统将其中的某些信息动态替换,包括表格动态生成,然后合并成一份文档,添加页眉页脚及水印,页眉和水印为动态内容,页眉需要添加logo图片,完成后转换为PDF。 方案:最初想当然的考虑jacob,但考虑到系统需要部署在linux环境中,被否定,最终选择...

vPq5kkJ4CJvlUMDjpLc的博客 721

java如何生成word文档_java生成word文档【一】

/*** expWordByFtl方法主要用于-采用模板(freemarker)的方式导出数据到word.* 优缺点-操作方便,但是设置模板有些繁杂.* 使用方法-1、建立模板文档,2、另存为xml文件,3、将格式xml改为ftl,4、采用freemarker语法编辑ftl文件.* 第三方jar-freemarker-2.3.19.jar.* import freemarker.template....

weixin_35949064的博客 687

itext生成、导出word(springmvc)

import java.io.FileOutputStream;   import java.io.IOException;      import com.lowagie.text.Document;   import com.lowagie.text.DocumentException;   import com.lowagie.text.Font;   import com....

Java让你与众不同 391

java 导出word

目前来看,java导出word大致有6种解决方案:  1:Jacob是Java-COM Bridge的缩写,使用Jacob自带的DLL动态链接库,并通过JNI的方式实现了在Java平台上对COM程序的调用。DLL动态链接库的生成需要windows平台的支持。该方案只能在windows平台实现,是其局限性。  2:Apache POI包括一系列的API,他的excel处理很强大,对于word还局限于...

qq_40562912的博客 6449
上一篇: Java开发Web程序中修改类文件和配…
下一篇: JDK1.5~1.7新特性
jarry.liu
博客等级 码龄16年 36粉丝 304原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jarry.liu

如果对您有帮助,鼓励下博主吧

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值