当前位置:网站首页>Download (export) PDF template file (such as approval form), and report error: invalid nested tag * * * found, expected closing tag***
Download (export) PDF template file (such as approval form), and report error: invalid nested tag * * * found, expected closing tag***
2022-07-01 19:28:00 【Yunnan wuxiaohei】
- Preface , Next to the last one ( download ( export )pdf Template file ( such as : Approval form ));
- Error reason :html Wrong format , End tag missing ( Maybe according to the actual situation , confirm html It's also true , But I still report this mistake );
- Solutions : Get the html Content time , adopt jsoup format html Content ;
- pom introduce jsoup package
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.3</version>
</dependency>
- stay java In the code html format
/** * take html Transform into strict XHTML */
public class Html2Xhtml {
/** * Transformation class * * @param htmlPath html File input path ( With file name ) * @param xhtmlPath xhtml File input path ( With file name ) * @return */
public static String html2Xhtml(String htmlPath, String xhtmlPath) {
if (StringUtils.isEmpty(htmlPath)) {
return null;
}
String path = null;
try (FileInputStream fin = new FileInputStream(htmlPath)) {
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
int data = -1;
while ((data = fin.read()) != -1) {
byteArrayOut.write(data);
}
fin.close();
String html = byteArrayOut.toString("UTF-8");
//System.out.println(" original HTML:" + html);
String newHtml = formatHtml(html);
//System.out.println(" After the formatting HTML:" + newHtml);
byte[] htmlFileData = newHtml.getBytes(StandardCharsets.UTF_8);
byteArrayOut.close();
ByteArrayInputStream tidyInput = new ByteArrayInputStream(htmlFileData);
ByteArrayOutputStream tidyOut = new ByteArrayOutputStream();
Tidy tidy = new Tidy();
tidy.setInputEncoding("UTF-8");
tidy.setOutputEncoding("UTF-8");
tidy.setShowWarnings(false);
tidy.setIndentContent(true);
tidy.setSmartIndent(true);
tidy.setIndentAttributes(false);
tidy.setMakeClean(true);
tidy.setQuiet(true);
tidy.setWord2000(true);
tidy.setXHTML(true);
tidy.setErrout(new PrintWriter(System.out));
tidy.parse(tidyInput, tidyOut);
tidyInput.close();
tidyOut.writeTo(new FileOutputStream(xhtmlPath));
tidyOut.flush();
tidyOut.close();
path = xhtmlPath;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
path = null;
}
return path;
}
/** * format html * * Error code :Invalid nested tag *** found, expected closing tag *** * Error reason :html turn xhtml In the process , The label is not closed * Solutions : adopt jsoup format html * @param html * @return */
private static String formatHtml(String html) {
Document document = Jsoup.parse(html);
document.outputSettings().syntax(Document.OutputSettings.Syntax.xml);
document.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
return document.html();
}
}
边栏推荐
- 组队学习! 14天鸿蒙设备开发“学练考”实战营限时免费加入!
- 6月刊 | AntDB数据库参与编写《数据库发展研究报告》 亮相信创产业榜单
- 【森城市】GIS数据漫谈(一)
- 【org.slf4j.Logger中info()方法】
- The use of subplot function in MATLAB
- M91 fast hall measuring instrument - better measurement in a shorter time
- Junit单元测试框架详解
- 一次SQL优化,数据库查询速度提升 60 倍
- 中英说明书丨人可溶性晚期糖基化终末产物受体(sRAGE)Elisa试剂盒
- MySQL常用图形管理工具 | 黑马程序员
猜你喜欢
Lake Shore 连续流动低温恒温器传输线
SuperOptiMag 超导磁体系统 — SOM、SOM2 系列
Lake Shore—OptiMag 超导磁体系统 — OM 系列
XML syntax, constraints
小红书上的爱情买卖
The best landing practice of cave state in an Internet ⽹⾦ financial technology enterprise
Once the SQL is optimized, the database query speed is increased by 60 times
一次SQL优化,数据库查询速度提升 60 倍
Lake Shore continuous flow cryostat transmission line
ubuntu14安装MySQL并配置root账户本地与远程访问
随机推荐
Specification of lumiprobe reactive dye indocyanine green
见证时代!“人玑协同 未来已来”2022弘玑生态伙伴大会开启直播预约
Case sharing: basic networking configuration of QinQ
The best landing practice of cave state in an Internet ⽹⾦ financial technology enterprise
Once the SQL is optimized, the database query speed is increased by 60 times
sql查询去重统计的方法总结
Contos 7 set up SFTP to create users, user groups, and delete users
Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
Solidity - contract structure - error - ^0.8.4 NEW
C端梦难做,科大讯飞靠什么撑起10亿用户目标?
Lake Shore M91快速霍尔测量仪
English grammar_ Adjective / adverb Level 3 - precautions
Dlib+opencv library for fatigue detection
The use of subplot function in MATLAB
组队学习! 14天鸿蒙设备开发“学练考”实战营限时免费加入!
混沌工程平台 ChaosBlade-Box 新版重磅发布
Netease games, radical going to sea
Bao, que se passe - t - il si le serveur 100 + O & M a mal à la tête? Utilisez le majordome xingyun!
从零开始学 MySQL —数据库和数据表操作
Three ways for redis to realize current limiting