|
@@ -1,31 +1,19 @@
|
|
//package com.simuwang;
|
|
//package com.simuwang;
|
|
-//
|
|
|
|
//import cn.hutool.core.collection.ListUtil;
|
|
//import cn.hutool.core.collection.ListUtil;
|
|
//import cn.hutool.core.date.DateUtil;
|
|
//import cn.hutool.core.date.DateUtil;
|
|
-//import com.itextpdf.text.Image;
|
|
|
|
-//import com.itextpdf.text.pdf.PdfWriter;
|
|
|
|
//import com.simuwang.base.common.conts.DateConst;
|
|
//import com.simuwang.base.common.conts.DateConst;
|
|
//import com.simuwang.base.pojo.dto.MailboxInfoDTO;
|
|
//import com.simuwang.base.pojo.dto.MailboxInfoDTO;
|
|
//import com.simuwang.daq.service.EmailParseApiService;
|
|
//import com.simuwang.daq.service.EmailParseApiService;
|
|
//import com.simuwang.daq.service.EmailParseService;
|
|
//import com.simuwang.daq.service.EmailParseService;
|
|
-//import org.apache.pdfbox.pdmodel.PDDocument;
|
|
|
|
-//import org.apache.pdfbox.rendering.ImageType;
|
|
|
|
-//import org.apache.pdfbox.rendering.PDFRenderer;
|
|
|
|
//import org.jasypt.util.text.BasicTextEncryptor;
|
|
//import org.jasypt.util.text.BasicTextEncryptor;
|
|
-//import org.apache.pdfbox.Loader;
|
|
|
|
//import org.junit.jupiter.api.Test;
|
|
//import org.junit.jupiter.api.Test;
|
|
//import org.springframework.beans.factory.annotation.Autowired;
|
|
//import org.springframework.beans.factory.annotation.Autowired;
|
|
//import org.springframework.boot.test.context.SpringBootTest;
|
|
//import org.springframework.boot.test.context.SpringBootTest;
|
|
-//import com.itextpdf.text.*;
|
|
|
|
-//import javax.imageio.ImageIO;
|
|
|
|
-//import java.awt.*;
|
|
|
|
-//import java.awt.image.BufferedImage;
|
|
|
|
//import java.io.File;
|
|
//import java.io.File;
|
|
-//import java.io.FileNotFoundException;
|
|
|
|
-//import java.io.FileOutputStream;
|
|
|
|
-//import java.io.IOException;
|
|
|
|
//import java.util.*;
|
|
//import java.util.*;
|
|
//import java.util.List;
|
|
//import java.util.List;
|
|
|
|
+//import java.util.regex.Matcher;
|
|
|
|
+//import java.util.regex.Pattern;
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//@SpringBootTest(classes = Application.class)
|
|
//@SpringBootTest(classes = Application.class)
|
|
@@ -70,7 +58,13 @@
|
|
//
|
|
//
|
|
// @Test
|
|
// @Test
|
|
// public void testReparseEmail() {
|
|
// public void testReparseEmail() {
|
|
-// emailParseApiService.reparseEmail(593);
|
|
|
|
|
|
+// String regexp = ".*_(.*?基金).*";
|
|
|
|
+// String fileName = "排排网净值及季报补充20230425_分红公告_半年添利多策略1号_璞远半年添利多策略1号私募证券投资基金_20210913_分红公告.pdf";
|
|
|
|
+// Pattern pattern = Pattern.compile(regexp);
|
|
|
|
+// Matcher matcher = pattern.matcher(fileName);
|
|
|
|
+// if(matcher.find()){
|
|
|
|
+// System.out.println(matcher.group(1));
|
|
|
|
+// }
|
|
// }
|
|
// }
|
|
//
|
|
//
|
|
// @Test
|
|
// @Test
|
|
@@ -100,67 +94,7 @@
|
|
// return emailInfoDTO;
|
|
// return emailInfoDTO;
|
|
// }
|
|
// }
|
|
//
|
|
//
|
|
-// @Test
|
|
|
|
-// public void testPdfRemoveWatermark() {
|
|
|
|
-// pdfRemoveWatermark("D:/pdf/东华期货奔牛1号7.29-8.2基金净值表.pdf");
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// public void pdfRemoveWatermark(String filePath) {
|
|
|
|
-// try {
|
|
|
|
-// //PDF转图片
|
|
|
|
-// pdfToImage(filePath);
|
|
|
|
-// List<String> fileNames = getFileNames("D:/pdf/pdfToImage");
|
|
|
|
-// List<File> fileList = new ArrayList<>();
|
|
|
|
-// for (String fileName : fileNames) {
|
|
|
|
-// fileList.add(new File("D:/pdf/pdfToImage/"+fileName));
|
|
|
|
-// }
|
|
|
|
-// //去除PDF水印
|
|
|
|
-// removePdfWatermark(fileList);
|
|
|
|
-// //去除水印后的图片转PDF
|
|
|
|
-// List<Integer> fileNamesInteger = new ArrayList<>();
|
|
|
|
-// List<String> allFiles = new ArrayList<>();
|
|
|
|
-// for (String fileName : fileNames) {
|
|
|
|
-// if(fileName.endsWith(".png")){
|
|
|
|
-// String str = fileName.substring(0, fileName.indexOf(".png"));
|
|
|
|
-// fileNamesInteger.add(Integer.valueOf(str));
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// Collections.sort(fileNamesInteger);
|
|
|
|
-// for (Integer fileName : fileNamesInteger) {
|
|
|
|
-// String str ="D:/pdf/pdfToImage/"+ fileName+".png";
|
|
|
|
-// allFiles.add(str);
|
|
|
|
-// }
|
|
|
|
-// String fileName = filePath.substring(filePath.lastIndexOf("/")+1);
|
|
|
|
-// //图片转PDF
|
|
|
|
-// imgOfPdf("D:/pdf/imgToPdf/"+fileName, allFiles);
|
|
|
|
-//
|
|
|
|
-// } catch (IOException e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
//
|
|
//
|
|
-// private void pdfToImage(String filePath) throws IOException {
|
|
|
|
-// File file = new File(filePath);
|
|
|
|
-// PDDocument doc = Loader.loadPDF(file);
|
|
|
|
-// PDFRenderer renderer = new PDFRenderer(doc);
|
|
|
|
-// int pageCount = doc.getNumberOfPages();
|
|
|
|
-// BufferedImage merge = null;
|
|
|
|
-// int curY = 0;
|
|
|
|
-// for (int i = 0; i < pageCount; i++) {
|
|
|
|
-// try {
|
|
|
|
-// BufferedImage image = renderer.renderImage(i, 2, ImageType.RGB);
|
|
|
|
-// ImageIO.write(image, "png", new File("D:/pdf/pdfToImage/" + i + ".png"));
|
|
|
|
-//// BufferedImage bufferedImage = renderer.renderImage(i, 2, ImageType.RGB);
|
|
|
|
-//// if (Objects.isNull(merge)) {
|
|
|
|
-//// merge = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight() * i, BufferedImage.TYPE_INT_ARGB);
|
|
|
|
-//// }
|
|
|
|
-//// merge.getGraphics().drawImage(bufferedImage, 0, curY, null);
|
|
|
|
-//// curY += bufferedImage.getHeight();
|
|
|
|
-// } catch (IOException e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
// /**
|
|
// /**
|
|
// * 得到文件名称
|
|
// * 得到文件名称
|
|
// *
|
|
// *
|
|
@@ -194,108 +128,7 @@
|
|
// }
|
|
// }
|
|
// return fileNames;
|
|
// return fileNames;
|
|
// }
|
|
// }
|
|
-// /**
|
|
|
|
-// * 去除文件列表里图片的水印并替换
|
|
|
|
-// *
|
|
|
|
-// * @Param fileList 文件列表
|
|
|
|
-// */
|
|
|
|
-// public static void removePdfWatermark(List<File> fileList) {
|
|
|
|
-// try {
|
|
|
|
-// for (File file : fileList) {
|
|
|
|
-// if (!file.getName().endsWith("png") && !file.getName().endsWith("jpg")) {
|
|
|
|
-// continue;
|
|
|
|
-// }
|
|
|
|
-// //用ImageIO流读取像素块
|
|
|
|
-// BufferedImage bi = ImageIO.read(file);
|
|
|
|
-// if (bi != null) {
|
|
|
|
-// removeWatermark(bi);
|
|
|
|
-// //生成的图片格式
|
|
|
|
-// String formatName = file.getName().substring(file.getName().lastIndexOf(".") + 1);
|
|
|
|
-// //用ImageIO流生成的处理图替换原图片
|
|
|
|
-// ImageIO.write(bi, formatName, file);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// } catch (IOException e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// /**
|
|
|
|
-// * 去除水印
|
|
|
|
-// */
|
|
|
|
-// private static void removeWatermark(BufferedImage bi) {
|
|
|
|
-// Color wColor = new Color(254, 254, 254);
|
|
|
|
-// Color hColor = new Color(197, 196, 191);
|
|
|
|
-// //白底水印
|
|
|
|
-// for (int i = 0; i < bi.getWidth(); i++) {
|
|
|
|
-// for (int j = 0; j < bi.getHeight(); j++) {
|
|
|
|
-// int color = bi.getRGB(i, j);
|
|
|
|
-// Color oriColor = new Color(color);
|
|
|
|
-// int red = oriColor.getRed();
|
|
|
|
-// int greed = oriColor.getGreen();
|
|
|
|
-// int blue = oriColor.getBlue();
|
|
|
|
-// if (red == 254 && greed == 254 && blue == 254) {
|
|
|
|
-// continue;
|
|
|
|
-// }
|
|
|
|
-// if (red > 220 && greed > 180 && blue > 80) {
|
|
|
|
-// bi.setRGB(i, j, wColor.getRGB());
|
|
|
|
-// }
|
|
|
|
-// if (red <= 240 && greed >= 200 && blue >= 150) {
|
|
|
|
-// bi.setRGB(i, j, wColor.getRGB());
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// public static void imgOfPdf(String filepath, List<String> imgUrl) {
|
|
|
|
//
|
|
//
|
|
-// try {
|
|
|
|
-// //输出pdf文件路径
|
|
|
|
-// String pdfUrl = filepath;
|
|
|
|
-// //生成pdf
|
|
|
|
-// File file = Pdf(imgUrl, pdfUrl);
|
|
|
|
-// file.createNewFile();
|
|
|
|
-// } catch (IOException e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// public static File Pdf(List<String> imageUrllist, String mOutputPdfFileName) {
|
|
|
|
-// //new一个pdf文档
|
|
|
|
-// Document doc = new Document(PageSize.A4, 0, 0, 0, 0);
|
|
|
|
-// try {
|
|
|
|
-// //pdf写入
|
|
|
|
-// PdfWriter.getInstance(doc, new FileOutputStream(mOutputPdfFileName));
|
|
|
|
-// //打开文档
|
|
|
|
-// doc.open();
|
|
|
|
-// //循环图片List,将图片加入到pdf中
|
|
|
|
-// for (int i = 0; i < imageUrllist.size(); i++) {
|
|
|
|
-// //在pdf创建一页
|
|
|
|
-// doc.newPage();
|
|
|
|
-// //通过文件路径获取image
|
|
|
|
-// Image png1 = Image.getInstance(imageUrllist.get(i));
|
|
|
|
-// float height = png1.getHeight();
|
|
|
|
-// float width = png1.getWidth();
|
|
|
|
-// int percent = getPercent2(height, width);
|
|
|
|
-// png1.setAlignment(Image.MIDDLE);
|
|
|
|
-// // 表示是原来图像的比例;
|
|
|
|
-// png1.scalePercent(percent + 3);
|
|
|
|
-// doc.add(png1);
|
|
|
|
-// }
|
|
|
|
-// doc.close();
|
|
|
|
-// } catch (FileNotFoundException e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// } catch (DocumentException e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// } catch (IOException e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// //输出流
|
|
|
|
-// File mOutputPdfFile = new File(mOutputPdfFileName);
|
|
|
|
-// if (!mOutputPdfFile.exists()) {
|
|
|
|
-// mOutputPdfFile.deleteOnExit();
|
|
|
|
-// return null;
|
|
|
|
-// }
|
|
|
|
-// //反回文件输出流
|
|
|
|
-// return mOutputPdfFile;
|
|
|
|
-// }
|
|
|
|
// public static int getPercent2(float h, float w) {
|
|
// public static int getPercent2(float h, float w) {
|
|
// int p = 0;
|
|
// int p = 0;
|
|
// float p2 = 0.0f;
|
|
// float p2 = 0.0f;
|