当前位置:网站首页>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();
}
}
边栏推荐
- B2B e-commerce platform solution for fresh food industry to improve the standardization and transparency of enterprise transaction process
- 241. Different Ways to Add Parentheses
- 3. "Create your own NFT collections and publish a Web3 application to show them" cast NFT locally
- Contos 7 搭建sftp之创建用户、用户组以及删除用户
- 组队学习! 14天鸿蒙设备开发“学练考”实战营限时免费加入!
- 线程的并行、并发、生命周期
- Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
- Redis 实现限流的三种方式
- Lake Shore—CRX-EM-HF 型低温探针台
- Specification of lumiprobe reactive dye indocyanine green
猜你喜欢

一次SQL优化,数据库查询速度提升 60 倍

Once the SQL is optimized, the database query speed is increased by 60 times

Cdga | if you are engaged in the communication industry, you should get a data management certificate

M91快速霍尔测量仪—在更短的时间内进行更好的测量

Lake Shore 连续流动低温恒温器传输线

The intelligent epidemic prevention system provides safety guarantee for the resumption of work and production at the construction site

论文阅读【Discriminative Latent Semantic Graph for Video Captioning】

Games202 operation 0 - environment building process & solving problems encountered

XML syntax, constraints

白盒加密技术浅理解
随机推荐
从零开始学 MySQL —数据库和数据表操作
论文泛读【FiLM: Visual Reasoning with a General Conditioning Layer】
Detailed explanation of JUnit unit test framework
[to.Net] C set class source code analysis
精耕渠道共谋发展 福昕携手伟仕佳杰开展新产品培训大会
Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
[quick application] win7 system cannot run and debug projects using Huawei ide
物联网平台thingsboard搭建学习记录
PostgreSQL varchar[] array type operation
Lumiprobe 细胞成像研究丨PKH26细胞膜标记试剂盒
[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
Solidity - truncated and checked modes of arithmetic operations - new features of 0.8.0
Lake Shore - crx-em-hf low temperature probe station
学习笔记【gumbel softmax】
3. "Create your own NFT collections and publish a Web3 application to show them" cast NFT locally
Specification of lumiprobe reactive dye indocyanine green
Lumiprobe cell imaging study PKH26 cell membrane labeling kit
More information about M91 fast hall measuring instrument
web开发常用的开源框架的开源协议整理
Lumiprobe 活性染料丨吲哚菁绿说明书