当前位置:网站首页>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();
}
}
边栏推荐
- PostgreSQL varchar[] 数组类型操作
- 微信公众号开发相关流程及功能介绍
- PostgreSQL varchar[] array type operation
- SuperOptiMag 超导磁体系统 — SOM、SOM2 系列
- Lumiprobe 亚磷酰胺丨六甘醇亚磷酰胺说明书
- 精耕渠道共謀發展 福昕攜手偉仕佳傑開展新產品培訓大會
- Parallelism, concurrency and life cycle of threads
- 新版国标GB28181视频平台EasyGBS如何配置WebRTC视频流格式播放?
- 精益思想:来源,支柱,落地。看了这篇文章就懂了
- EasyGBS主子码流都为H.265时,切换出现花屏如何解决?
猜你喜欢

寶,運維100+服務器很頭疼怎麼辦?用行雲管家!

见证时代!“人玑协同 未来已来”2022弘玑生态伙伴大会开启直播预约
![Reading the paper [learning to discretely compose reasoning module networks for video captioning]](/img/a2/acdaebeb67ec4bcb01c8ff4bbd1d1e.png)
Reading the paper [learning to discretely compose reasoning module networks for video captioning]

Lumiprobe 自由基分析丨H2DCFDA说明书
使用环信提供的uni-app Demo,快速实现一对一单聊

PMP是被取消了吗??

Dlib+opencv library for fatigue detection

制造业SRM管理系统供应商全方位闭环管理,实现采购寻源与流程高效协同

智慧防疫系统为建筑工地复工复产提供安全保障

论文阅读【Learning to Discretely Compose Reasoning Module Networks for Video Captioning】
随机推荐
【pytorch记录】模型的分布式训练DataParallel、DistributedDataParallel
Supervarimag superconducting magnet system SVM series
Solution: you can ping others, but others can't ping me
智慧防疫系统为建筑工地复工复产提供安全保障
[quick application] win7 system cannot run and debug projects using Huawei ide
Bao, what if the O & M 100+ server is a headache? Use Xingyun housekeeper!
记一次 .NET 差旅管理后台 CPU 爆高分析
Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
学习笔记【gumbel softmax】
PMP是被取消了吗??
[go ~ 0 to 1] day 4 June 30 defer, structure, method
Go语言高级
Contos 7 搭建sftp之创建用户、用户组以及删除用户
[to.Net] C set class source code analysis
EasyGBS网络不稳定情况下重复请求视频拉流问题的优化
中英说明书丨人可溶性晚期糖基化终末产物受体(sRAGE)Elisa试剂盒
SuperOptiMag 超导磁体系统 — SOM、SOM2 系列
PostgreSQL varchar[] 数组类型操作
精耕渠道共謀發展 福昕攜手偉仕佳傑開展新產品培訓大會
机械设备行业数字化供应链集采平台解决方案:优化资源配置,实现降本增效