Browse Source

fix: 解决导出超链接url报错的问题

zhongwei
liwen 7 months ago
parent
commit
8b11c514c8
  1. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java
  2. BIN
      hzims-service/safeproduct/src/main/resources/template/培训记录表.docx

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java

@ -78,6 +78,7 @@ public class BaseUtil {
BaseUtil.exportWord(res, wordPath);
} catch (Exception e) {
log.error("文件导出异常: {}", e.getMessage());
e.printStackTrace();
}
AsposeUtil.wordToPdf(wordPath, pdfPath);
BaseUtil.readPdf(response,pdfPath);
@ -138,6 +139,7 @@ public class BaseUtil {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String name = jsonObject.getString("name");
String url = jsonObject.getString("url");
url = URLEncoder.encode(url, "UTF-8");
String id = paragraph.getDocument().getPackagePart().addExternalRelationship(url, XWPFRelation.HYPERLINK.getRelation()).getId();
CTHyperlink cLink = paragraph.getCTP().addNewHyperlink();
cLink.setId(id);
@ -146,7 +148,7 @@ public class BaseUtil {
CTR ctr = CTR.Factory.newInstance();
ctr.setTArray(new CTText[]{ctText});
cLink.setRArray(new CTR[]{ctr});
if(i<jsonArray.length()-1) {
if (i<jsonArray.length()-1) {
paragraph.createRun().addBreak();
}
}

BIN
hzims-service/safeproduct/src/main/resources/template/培训记录表.docx

Binary file not shown.
Loading…
Cancel
Save