当前位置: 首页 > news >正文

杨和网站设计做任务打字赚钱的网站

杨和网站设计,做任务打字赚钱的网站,官方网站弹幕怎么做,东方网络律师团队一、免费方式 优点:1、免费;2、在众多免费中挑选出的转换效果相对较好,并且不用像openOffice那样安装服务 缺点:1、对字体支持没有很好,需要安装字体库或者使用宋体(对宋体支持很好)2、对于使…

一、免费方式

优点:1、免费;2、在众多免费中挑选出的转换效果相对较好,并且不用像openOffice那样安装服务

缺点:1、对字体支持没有很好,需要安装字体库或者使用宋体(对宋体支持很好)2、对于使用freeMarker模板转化过来的doc无法读取转换

第一步:

        <dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>3.17</version></dependency><dependency><groupId>fr.opensagres.xdocreport</groupId><artifactId>fr.opensagres.poi.xwpf.converter.pdf-gae</artifactId><version>2.0.1</version></dependency>

第二步:

public static void main(String[] args) throws Exception {FileInputStream fileInputStream = new FileInputStream("D:\\test\\研判报告docx.docx");XWPFDocument xwpfDocument = new XWPFDocument(fileInputStream);
// 将word中字体转化为宋体,防止其他字体无法正常显示setFontType(xwpfDocument);FileOutputStream fileOutputStream = new FileOutputStream("D:\\test\\研判报告11.docx");PdfConverter.getInstance().convert(xwpfDocument,fileOutputStream,pdfOptions);fileInputStream.close();fileOutputStream.close();}/**** 将文档的文字设置为宋体 防止其他字体转pdf不显示* @Description:* @param xwpfDocument* @return:*/private static void setFontType(XWPFDocument xwpfDocument) {//转换文档中文字字体List<XWPFParagraph> paragraphs = xwpfDocument.getParagraphs();if(paragraphs != null && paragraphs.size()>0){for (XWPFParagraph paragraph : paragraphs) {List<XWPFRun> runs = paragraph.getRuns();if(runs !=null && runs.size()>0){for (XWPFRun run : runs) {run.setFontFamily("宋体");}}}}//转换表格里的字体 我也不想俄罗斯套娃但是不套真不能设置字体List<XWPFTable> tables = xwpfDocument.getTables();for (XWPFTable table : tables) {List<XWPFTableRow> rows = table.getRows();for (XWPFTableRow row : rows) {List<XWPFTableCell> tableCells = row.getTableCells();for (XWPFTableCell tableCell : tableCells) {List<XWPFParagraph> paragraphs1 = tableCell.getParagraphs();for (XWPFParagraph xwpfParagraph : paragraphs1) {List<XWPFRun> runs = xwpfParagraph.getRuns();for (XWPFRun run : runs) {run.setFontFamily("宋体");}}}}}}

二、收费方式:

除了收费没啥缺点

1、freemarker生成word模板

①、自己新建一个word文档,内容就按照需要的格式内容

②、word文档另存为,选择xml格式

③、修改xml后缀为ftl放在如图位置

 ④代码:

    public static void main(String[] args) throws Exception {//1.创建配置类Configuration configuration=new Configuration(Configuration.getVersion());//2.设置模板所在的目录configuration.setDirectoryForTemplateLoading(new File(".\\template"));//3.设置字符集configuration.setDefaultEncoding("utf-8");//4.加载模板Template template = configuration.getTemplate("研判报告docx.ftl");//5.创建数据模型Map map=new HashMap();map.put("name","姓名姓名");map.put("idCard","身份证号码");map.put("age","36");map.put("sex","男");Map<String, Object> data1 = new HashMap<>();data1.put("item",map);Writer out =new FileWriter(new File(".\\template\\研判报告docx.docx"));//7.输出template.process(data1, out);//8.关闭Writer对象out.close();}

2、word转pdf

①、新建asposeLicense.xml放到如图位置

 asposeLicense.xml内容:

<License><Data><Products><Product>Aspose.Total for Java</Product><Product>Aspose.Words for Java</Product></Products><EditionType>Enterprise</EditionType><SubscriptionExpiry>20991231</SubscriptionExpiry><LicenseExpiry>20991231</LicenseExpiry><SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber></Data><Signature>sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=</Signature>
</License>

②、代码

public static void main(String[] args) {String docPath = ".\\template\\研判报告docx.docx";String savePath = ".\\template\\研判报告docx4.pdf";word2pdf(docPath, savePath);}public static void word2pdf(String docPath, String savePath) {try {ClassPathResource resource = new ClassPathResource("asposeLicense.xml");InputStream inputStream = resource.getInputStream();License license = new License();license.setLicense(inputStream);com.aspose.words.Document document = new com.aspose.words.Document(docPath);document.save(new FileOutputStream(new File(savePath)), SaveFormat.PDF);} catch (Exception e) {e.printStackTrace();}}

http://www.yayakq.cn/news/161319/

相关文章:

  • 设计的网站源代码怎么做自己建设网站流程
  • 进一步网站建设做基金哪个网站好
  • 网站后台发布文章莱芜都市网二手
  • 网站自适应手机代码wordpress 公司建站
  • 泉州网站建设qzdzi建电影网站赚钱挣钱吗
  • 免费可商用的素材网站做电子请帖网站有哪些
  • 潮动九州网站建设网络营销工具及其特点
  • 网站建设策划书提纲有趣的网站官网
  • 网站建设与维护中国出版社小说阅读网站开发源码
  • 做移动端网站软件系统优化大师官方下载
  • 网站开发需要的学历wordpress怎么固定导航栏
  • 成都网站建设网络公司各种资源都有的搜索引擎
  • 网站备案 新闻审批号wordpress的登录页面模板
  • 网站开发实战wordpress降低数据库查询时间
  • 网站模版 百度云网站备案 接入商名称
  • 网站seo入门企业网站制作公司盈利
  • 网站优化搜索网站运营一般做那些分析
  • dw可以做网站吗国家林业建设工程协会网站
  • 重庆大足网站制作公司哪家专业天津塘沽爆炸
  • 做竞猜网站犯法吗中国icp备案网站
  • 怎么做网站策划中国网新山东
  • 常德政务网站阿里云的虚拟主机用什么做网站
  • 什么做网站的公司好高大上网站
  • 潍坊做电商的网站wordpress分享有图片
  • 网站建设咨询哪家性价比高网站建设费用详细表
  • 合理规划网站结构wordpress 小米商城模板
  • 网站开发工具教程免费网站app下载
  • 中小学网站建站模板石家庄抖音推广公司
  • 外发加工网站网站后台网址后缀
  • 如何实现网站开发手机验证码租用大型服务器多少钱