From b9248c039eee2318129e128ad959c6f2e6e46846 Mon Sep 17 00:00:00 2001 From: linzhijie <19970921lzj> Date: 星期一, 16 八月 2021 16:27:46 +0800 Subject: [PATCH] 1、事中提示语权限开关优化 2、分配用户搜索优化 --- src/main/java/com/ots/project/tool/PdfUtil.java | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/ots/project/tool/PdfUtil.java b/src/main/java/com/ots/project/tool/PdfUtil.java index ff31931..7745ebd 100644 --- a/src/main/java/com/ots/project/tool/PdfUtil.java +++ b/src/main/java/com/ots/project/tool/PdfUtil.java @@ -1,23 +1,38 @@ package com.ots.project.tool; -import com.aspose.words.Document; -import com.aspose.words.SaveFormat; +import com.aspose.words.*; import lombok.extern.slf4j.Slf4j; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; @Slf4j public class PdfUtil { + public static void setFont(){ + String userfontsfoloder = "C:\\Users\\澶уご\\AppData\\Local\\Microsoft\\Windows\\Fonts\\"; + log.info("font璺緞:{}",userfontsfoloder); + List<FontSourceBase> fontSources = new ArrayList(Arrays.asList(FontSettings.getDefaultInstance().getFontsSources())); + FolderFontSource folderFontSource = new FolderFontSource(userfontsfoloder,true); + fontSources.add(folderFontSource); + FontSourceBase[] fontSourceBases = fontSources.toArray(new FontSourceBase[fontSources.size()]); + FontSettings.getDefaultInstance().setFontsSources(fontSourceBases); + } + public static void convertPDF(String input){ try { + //setFont(); + Document pres = null; + FontSettings.getDefaultInstance().setFontsFolder("C:\\Users\\澶уご\\AppData\\Local\\Microsoft\\Windows\\Fonts", true); //鎵嬪姩鏇挎崲杈撳嚭pdf鍚嶇О String output = input.replaceAll(".docx", ".pdf"); long old = System.currentTimeMillis(); FileInputStream fileInput = new FileInputStream(input); - Document pres = new Document(fileInput); + pres = new Document(fileInput); FileOutputStream out = new FileOutputStream(new File(output)); pres.save(out, SaveFormat.PDF); out.close(); @@ -29,7 +44,8 @@ } public static void main(String[] args) { - convertPDF("D:\\娴嬭瘎绯荤粺\\home\\鏋梍PAQ_IA_CN.docx"); + //convertPDF("D:\\娴嬭瘎绯荤粺\\home\\鏋梍PAQ_GS_TH.docx"); + convertPDF("D:\\home\\PAQ绠�鏄撶増銆愭嘲鏂囥��.docx"); } } -- Gitblit v1.9.1