Browse Source

平台模板问题,目录问题

aQiu 3 months ago
parent
commit
e773645815

+ 5 - 4
src/main/java/org/example/mybatisplus/Controller/IndexController.java

@@ -28,12 +28,12 @@ import java.util.*;
 public class IndexController {
     public static void main(String[] args) throws IOException {
 
-        String wordExportpath = System.getProperty("user.dir")+File.separator+ "jijinhui1.docx";
+        String wordExportpath = System.getProperty("user.dir")+File.separator+ "jijinhui1.xml";
         String pdfFilePath =System.getProperty("user.dir")+File.separator+  "download.pdf";
 
         ServiceProviderInfo serviceProviderInfo=new ServiceProviderInfo();
-        serviceProviderInfo.setName("海潮基金会");
-        serviceProviderInfo.setType("基金会");
+        serviceProviderInfo.setName("海潮平台");
+        serviceProviderInfo.setType("平台");
         serviceProviderInfo.setReportDate("2025-03-11");
         AuditResult auditResult=new AuditResult();
         auditResult.setAuditDate("2025-03-11");
@@ -182,6 +182,7 @@ public class IndexController {
                 "哈哈哈",
                 "测试"
         ));
+        registrationInfo.setRelatedEntitiesImage(attachments);
         platformReport.setRegistrationInfo(registrationInfo);
         platformReport.setPublicRecord(publicRecord);
         financialInfo.setAntiBribery(new PublicRecordScore());
@@ -209,7 +210,7 @@ public class IndexController {
             //平台模板platform_template.xml
             //学协会模板association_template.xml
             // 生成Word文档
-            DocxGenerator.init(report,"foundation_template.xml",wordExportpath);
+            DocxGenerator.init(platformReport,"platform_template.xml",wordExportpath);
             // 将Word文档转换为PDF
             WordToPdfUtil.wordToPdf(wordExportpath,pdfFilePath);
         } catch (Exception e) {

+ 1 - 0
src/main/java/org/example/mybatisplus/tools/DocxGenerator.java

@@ -30,6 +30,7 @@ public class DocxGenerator {
                 template.process(report, out);
                 System.out.println("XML file generated successfully: " + outputFile.getAbsolutePath());
             } catch (Exception e) {
+                e.printStackTrace();
                 throw new RuntimeException(e);
             }
         } catch (IOException | TemplateException e) {

+ 10 - 0
src/main/java/org/example/mybatisplus/tools/WordToPdfUtil.java

@@ -44,6 +44,16 @@ public class WordToPdfUtil {
             // 创建一个Document对象,指定要转换的Word文档路径。
             //要转换的word文件
             Document doc = new Document(wordPath);
+            // 获取目录样式,例如 "TOC 1"
+            Style tocStyle = doc.getStyles().getByStyleIdentifier(StyleIdentifier.TOC_1);
+// 设置字体加粗
+            tocStyle.getFont().setBold(true);
+            tocStyle.getFont().setSize(9); // 可以设置其他字体属性,如大小
+            Style tocStyle1 = doc.getStyles().getByStyleIdentifier(StyleIdentifier.TOC_2);
+// 设置字体加粗
+            tocStyle1.getFont().setBold(true);
+            tocStyle1.getFont().setSize(9); // 可以设置其他字体属性,如大小
+
             doc.updateFields();//更新目录
             doc.save(wordPath, SaveFormat.DOCX);
             // 将Word文档保存为PDF格式,写入到之前创建的PDF文件中。

File diff suppressed because it is too large
+ 0 - 5810
src/main/resources/platform_template.xml


Some files were not shown because too many files changed in this diff