diff --git a/ruoyi-admin/src/main/java/com/ruoyi/script/util/Word2PdfUtil.java b/ruoyi-admin/src/main/java/com/ruoyi/script/util/Word2PdfUtil.java index 66af859..7edd884 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/script/util/Word2PdfUtil.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/script/util/Word2PdfUtil.java @@ -1,8 +1,6 @@ package com.ruoyi.script.util; -import com.aspose.words.Document; -import com.aspose.words.License; -import com.aspose.words.SaveFormat; +import com.aspose.words.*; import java.io.*; @@ -51,8 +49,34 @@ public class Word2PdfUtil { public static void wordConvertPdfFile(String wordPath, OutputStream outputStream) { try { setLicense(); + Document doc = new Document(wordPath); - doc.save(outputStream, SaveFormat.PDF); + // 调整页边距 + PageSetup pageSetup = doc.getFirstSection().getPageSetup(); + pageSetup.setLeftMargin(72); // 1 英寸 + pageSetup.setRightMargin(72); // 1 英寸 + pageSetup.setTopMargin(72); // 1 英寸 + pageSetup.setBottomMargin(72); // 1 英寸 + + // 调整行间距 + ParagraphCollection paragraphs = doc.getFirstSection().getBody().getParagraphs(); + // 指定字体和字号 + for (Paragraph paragraph : paragraphs) { + for (Run run : paragraph.getRuns()) { + Font font = run.getFont(); + font.setName("Arial"); + + } + } + + PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); + pdfSaveOptions.setEmbedFullFonts(false); // 不嵌入完整字体 + pdfSaveOptions.setEmbedStandardWindowsFonts(true); // 嵌入标准Windows字体 + pdfSaveOptions.setTextCompression(PdfTextCompression.FLATE); // 使用FLATE压缩文本 + pdfSaveOptions.setJpegQuality(100); // 设置JPEG图像质量为90 + pdfSaveOptions.setImageCompression(PdfImageCompression.JPEG); // 使用JPEG压缩图像 + + doc.save(outputStream, pdfSaveOptions); } catch (Exception e) { e.printStackTrace(); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/overdue/OverdueController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/overdue/OverdueController.java index c32353d..f060010 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/overdue/OverdueController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/overdue/OverdueController.java @@ -73,7 +73,7 @@ public class OverdueController { private static final String SECRET_KEY = "jinanshandongdianliangxinxijishu"; public static void main(String[] args) throws Exception { - String data = "山东点亮20250311175500信息技术"; + String data = "山东点亮20290311175500信息技术"; SecretKeySpec keySpec = generateKey(); Cipher cipher = Cipher.getInstance(ALGORITHM); cipher.init(Cipher.ENCRYPT_MODE, keySpec); diff --git a/ruoyi-admin/src/main/resources/static/mriTemp.docx b/ruoyi-admin/src/main/resources/static/mriTemp.docx index a7d4a66..bbac985 100644 Binary files a/ruoyi-admin/src/main/resources/static/mriTemp.docx and b/ruoyi-admin/src/main/resources/static/mriTemp.docx differ