From 02f5cf18aca44e268b8219870d50c65f8142e63e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E5=B5=A9?= Date: Tue, 16 Apr 2024 17:18:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=B9=E6=8E=A5=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/OnlyOfficeController.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java index 410312f..a118a6b 100644 --- a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java +++ b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java @@ -563,7 +563,26 @@ public class OnlyOfficeController { String attFileId = createTimeLatestOnlineFileLog.getAttFileId(); OSSFile ossFile = ossFileService.getById(attFileId); File file = new File(filePath + ossFile.getUrl()); - FileSystemResource fileResource = new FileSystemResource(file); + + // 加载文档 + Document doc = new Document(filePath + ossFile.getUrl()); + doc.getSections().get(0).getPageSetup().setPageNumberStyle(PageNumberStyle.Roman_Upper); + doc.getSections().get(0).getPageSetup().setOrientation(PageOrientation.Portrait);//纵向 + doc.getSections().get(1).getPageSetup().setOrientation(PageOrientation.Portrait);//纵向 + + String downloadDocxFileTempUrl = filePath + "/downloadDocxFileTemp"; + File downloadDocxFileTempUrlFile = new File(downloadDocxFileTempUrl); + + if (!downloadDocxFileTempUrlFile.exists()) { + downloadDocxFileTempUrlFile.mkdirs(); + } + String newFileName = UUID.randomUUID().toString().replace("-", "") + ".docx"; + String newFileUrl = downloadDocxFileTempUrl + "/" + newFileName; + + //保存文档 + doc.saveToFile(newFileUrl); + + FileSystemResource fileResource = new FileSystemResource(newFileUrl); params2.add("file", fileResource); // 使用HttpEntity对象包装请求体和请求头