当前位置:网站首页>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();
}
}
边栏推荐
- The intelligent epidemic prevention system provides safety guarantee for the resumption of work and production at the construction site
- 机械设备行业数字化供应链集采平台解决方案:优化资源配置,实现降本增效
- 线程的并行、并发、生命周期
- Lumiprobe 细胞成像研究丨PKH26细胞膜标记试剂盒
- Lake shore optimag superconducting magnet system om series
- 物联网平台thingsboard搭建学习记录
- 论文泛读【FiLM: Visual Reasoning with a General Conditioning Layer】
- Solution: you can ping others, but others can't ping me
- Parallelism, concurrency and life cycle of threads
- sql查询去重统计的方法总结
猜你喜欢

SuperOptiMag 超导磁体系统 — SOM、SOM2 系列

【To .NET】C#集合类源码解析

混沌工程平台 ChaosBlade-Box 新版重磅发布

3. "Create your own NFT collections and publish a Web3 application to show them" cast NFT locally

XML语法、约束

前4A高管搞代运营,拿下一个IPO

Today, with the popularity of micro services, how does service mesh exist?

有关 M91 快速霍尔测量仪的更多信息

Chinese and English instructions human soluble advanced glycation end products receptor (sRAGE) ELISA Kit

微信公众号开发相关流程及功能介绍
随机推荐
实现一个Prometheus exporter
Love business in Little Red Book
Specification of lumiprobe reactive dye indocyanine green
Games202 operation 0 - environment building process & solving problems encountered
Three ways for redis to realize current limiting
[quick application] there are many words in the text component. How to solve the problem that the div style next to it will be stretched
Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
记一次 .NET 差旅管理后台 CPU 爆高分析
241. Different Ways to Add Parentheses
Supervarimag superconducting magnet system SVM series
Lumiprobe 亚磷酰胺丨六甘醇亚磷酰胺说明书
【To .NET】C#集合类源码解析
Contos 7 set up SFTP to create users, user groups, and delete users
案例分享:QinQ基本组网配置
【org.slf4j.Logger中info()方法】
Lake Shore 连续流动低温恒温器传输线
sql查询去重统计的方法总结
Nacos configuration file publishing failed, please check whether the parameters are correct solution
6月刊 | AntDB数据库参与编写《数据库发展研究报告》 亮相信创产业榜单
Redis 实现限流的三种方式