当前位置:网站首页>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();
}
}
边栏推荐
- More information about M91 fast hall measuring instrument
- 线程的并行、并发、生命周期
- 下载(导出)pdf模板文件(比如:审批单),报错:Invalid nested tag *** found, expected closing tag ***
- pickle.load报错【AttributeError: Can‘t get attribute ‘Vocabulary‘ on <module ‘__main__‘】
- 【6.24-7.1】写作社区精彩技术博文回顾
- Manufacturing SRM management system supplier all-round closed-loop management, to achieve procurement sourcing and process efficient collaboration
- PostgreSQL varchar[] array type operation
- [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
- 中英说明书丨人可溶性晚期糖基化终末产物受体(sRAGE)Elisa试剂盒
- Parallelism, concurrency and life cycle of threads
猜你喜欢
Lake Shore 连续流动低温恒温器传输线
Nacos configuration file publishing failed, please check whether the parameters are correct solution
Chinese and English instructions human soluble advanced glycation end products receptor (sRAGE) ELISA Kit
Solidity - 合约结构 - 错误(error)- ^0.8.4版本新增
Supervarimag superconducting magnet system SVM series
新版国标GB28181视频平台EasyGBS如何配置WebRTC视频流格式播放?
M91快速霍尔测量仪—在更短的时间内进行更好的测量
求各种极限的方法
案例分享:QinQ基本组网配置
Solution of intelligent supply chain management platform in aquatic industry: support the digitalization of enterprise supply chain and improve enterprise management efficiency
随机推荐
Lake Shore—CRX-EM-HF 型低温探针台
Chinese and English instructions human soluble advanced glycation end products receptor (sRAGE) ELISA Kit
CDGA|从事通信行业,那你应该考个数据管理证书
Solution: you can ping others, but others can't ping me
Lumiprobe 自由基分析丨H2DCFDA说明书
The intelligent epidemic prevention system provides safety guarantee for the resumption of work and production at the construction site
求各种极限的方法
智慧防疫系统为建筑工地复工复产提供安全保障
中英说明书丨人可溶性晚期糖基化终末产物受体(sRAGE)Elisa试剂盒
Solidity - truncated and checked modes of arithmetic operations - new features of 0.8.0
Solution of digital supply chain centralized purchase platform in mechanical equipment industry: optimize resource allocation and realize cost reduction and efficiency increase
B2B e-commerce platform solution for fresh food industry to improve the standardization and transparency of enterprise transaction process
Lumiprobe cell imaging study PKH26 cell membrane labeling kit
How to redraw the header of CListCtrl in MFC
Witness the times! "The future of Renji collaboration has come" 2022 Hongji ecological partnership conference opens live broadcast reservation
241. Different Ways to Add Parentheses
Is PMP cancelled??
【Go ~ 0到1 】 第五天 7月1 类型别名,自定义类型,接口,包与初始化函数
Contos 7 set up SFTP to create users, user groups, and delete users
助力数字经济发展,夯实数字人才底座—数字人才大赛在昆成功举办