bug 处理
This commit is contained in:
parent
a42ce876d9
commit
f481156d44
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user