Browse Source

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

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

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

@ -78,6 +78,7 @@ public class BaseUtil {
BaseUtil.exportWord(res, wordPath); BaseUtil.exportWord(res, wordPath);
} catch (Exception e) { } catch (Exception e) {
log.error("文件导出异常: {}", e.getMessage()); log.error("文件导出异常: {}", e.getMessage());
e.printStackTrace();
} }
AsposeUtil.wordToPdf(wordPath, pdfPath); AsposeUtil.wordToPdf(wordPath, pdfPath);
BaseUtil.readPdf(response,pdfPath); BaseUtil.readPdf(response,pdfPath);
@ -138,6 +139,7 @@ public class BaseUtil {
JSONObject jsonObject = jsonArray.getJSONObject(i); JSONObject jsonObject = jsonArray.getJSONObject(i);
String name = jsonObject.getString("name"); String name = jsonObject.getString("name");
String url = jsonObject.getString("url"); String url = jsonObject.getString("url");
url = URLEncoder.encode(url, "UTF-8");
String id = paragraph.getDocument().getPackagePart().addExternalRelationship(url, XWPFRelation.HYPERLINK.getRelation()).getId(); String id = paragraph.getDocument().getPackagePart().addExternalRelationship(url, XWPFRelation.HYPERLINK.getRelation()).getId();
CTHyperlink cLink = paragraph.getCTP().addNewHyperlink(); CTHyperlink cLink = paragraph.getCTP().addNewHyperlink();
cLink.setId(id); cLink.setId(id);

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

Binary file not shown.
Loading…
Cancel
Save