main
黄海 10 months ago
parent 94b0ba2526
commit 63bce8608e

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 798 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 539 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 268 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 894 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 539 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 275 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 377 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 377 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 532 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 370 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 657 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 519 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 546 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 539 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 741 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 972 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 469 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 608 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 573 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 669 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 644 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 377 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 669 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 KiB

@ -27,28 +27,6 @@
</repository>
</repositories>
<dependencies>
<!--引用本地jar包-->
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>20.12</version>
<scope>system</scope> <!--system类似provided需要显式提供依赖的jar以后Maven就不会在Repository中查找它-->
<systemPath>${project.basedir}/ExtendJar/aspose-words-20.12-jdk17-crack.jar</systemPath>
</dependency>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cells</artifactId>
<version>23.4</version>
<scope>system</scope>
<systemPath>${project.basedir}/ExtendJar/aspose-cells-23.4.jar</systemPath>
</dependency>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose.slides</artifactId>
<version>19.3</version>
<scope>system</scope>
<systemPath>${project.basedir}/ExtendJar/aspose.slides-19.3.jar</systemPath>
</dependency>
<!--https://rstyro.github.io/blog/2022/08/12/%E7%A0%B4%E8%A7%A3Aspose-PDF%E7%9A%84Jar%E5%8C%85/-->
<dependency>
<groupId>com.aspose</groupId>
@ -61,13 +39,13 @@
<dependency>
<groupId>com.jfinal</groupId>
<artifactId>jfinal</artifactId>
<version>5.1.9</version>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>com.jfinal</groupId>
<artifactId>jfinal-undertow</artifactId>
<version>3.5</version>
<version>3.6</version>
</dependency>
<dependency>

@ -1,224 +0,0 @@
package com.dsideal.QingLong.Util;
import com.aspose.cells.*;
import com.aspose.cells.BorderType;
import com.aspose.cells.Cell;
import com.aspose.cells.Color;
import com.aspose.cells.License;
import com.aspose.cells.PdfSaveOptions;
import com.aspose.cells.Row;
import com.aspose.cells.Style;
import com.aspose.pdf.Image;
import com.aspose.pdf.Page;
import com.aspose.pdf.facades.PdfFileEditor;
import com.aspose.words.*;
import com.aspose.words.SaveFormat;
import com.jfinal.kit.StrKit;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.List;
public class AsposeUtil {
public static void doc2pdf(String sourcePath, String targetPath) throws Exception {
File f1 = new File(targetPath);
FileOutputStream os = new FileOutputStream(f1);
Document doc = new Document(sourcePath);
doc.save(os, SaveFormat.PDF);
}
public static void xls2pdf(String sourcePath, String targetPath) throws Exception {
//注册信息
getLicense();
Workbook wb = new Workbook(sourcePath);// 原始excel路径
FileOutputStream fileOS = new FileOutputStream(targetPath);
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setOnePagePerSheet(true);
wb.save(fileOS, pdfSaveOptions);
fileOS.flush();
fileOS.close();
}
/**
* PDF
*
* @param sourcePath
* @param targetPath
* @param imgType
* @throws IOException
*/
public static void image2pdf(String sourcePath, String targetPath, String imgType) throws Exception {
//创建文档
com.aspose.pdf.Document doc = new com.aspose.pdf.Document();
//新增一页
Page page = doc.getPages().add();
//设置页边距
page.getPageInfo().getMargin().setBottom(0);
page.getPageInfo().getMargin().setTop(0);
page.getPageInfo().getMargin().setLeft(0);
page.getPageInfo().getMargin().setRight(0);
//创建图片对象
Image image = new Image();
BufferedImage bufferedImage = ImageIO.read(new File(sourcePath));
//获取图片尺寸
int height = bufferedImage.getHeight();
int width = bufferedImage.getWidth();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bufferedImage, imgType, baos);
baos.flush();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
image.setImageStream(bais);
//设置pdf页的尺寸与图片一样
page.getPageInfo().setHeight(height);
page.getPageInfo().setWidth(width);
//添加图片
page.getParagraphs().add(image);
//保存
doc.save(targetPath, com.aspose.pdf.SaveFormat.Pdf);
}
public static void MergePdf(List<String> convertPdfFiles, String targetPath) {
String[] array = convertPdfFiles.toArray(new String[0]);
PdfFileEditor fileEditor = new PdfFileEditor();
fileEditor.concatenate(array, targetPath);
}
/**
* AsposeCells
*
* @return
*/
public static void getLicense() throws IOException {
InputStream is = com.aspose.cells.License.class.getResourceAsStream("/com.aspose.cells.lic.xml");
License asposeLicense = new License();
asposeLicense.setLicense(is);
is.close();
}
/**
* AsposeCells Color
*
* @param colorString
* @return
*/
public static Color getColor(String colorString) {
int red = Integer.parseInt(colorString.substring(1, 3), 16);
int green = Integer.parseInt(colorString.substring(3, 5), 16);
int blue = Integer.parseInt(colorString.substring(5, 7), 16);
Color color = Color.fromArgb(red, green, blue);
return color;
}
/**
*
*
* @param colorString
*/
public static void addColumnByHead(Workbook wb, int sheetIdx, String colorString, int headFirstRow, int headTotalRows, String addColumnText, int addColumnWidth, int dataRowCount) {
Worksheet sheet = wb.getWorksheets().get(sheetIdx);
//添加列
Cells cells = sheet.getCells();
//插入一列
cells.insertColumns(0, 1);
// 设置列宽
cells.setColumnWidthPixel(0, addColumnWidth);//列宽
//第一行表头的前两个单元格合并
cells.unMerge(0, 1, 1, 1); // 取消单元格合并
cells.merge(0, 0, 1, cells.getMaxDataColumn() + 1); // 合并第一行
// 设置水平和垂直居中
cells.get(0, 0).getStyle().setHorizontalAlignment(TextAlignmentType.CENTER);
cells.get(0, 0).getStyle().setVerticalAlignment(TextAlignmentType.CENTER);
// 合并表头所在所有行的第一列
sheet.getCells().merge(headFirstRow, 0, headTotalRows, 1);
//表头
cells.get(headFirstRow, 0).setValue(addColumnText);
//设置样式
Style style = wb.createStyle();
style.getFont().setBold(true);// 设置字体
style.getFont().setName("宋体");
style.getFont().setSize(12);
style.setForegroundColor(getColor(colorString)); //处理背景色
style.setPattern(BackgroundType.SOLID);
style.setHorizontalAlignment(TextAlignmentType.CENTER); // 设置水平居中
style.setVerticalAlignment(TextAlignmentType.CENTER); // 设置垂直居中
style.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, Color.getBlack()); //边框
style.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, Color.getBlack());
style.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, Color.getBlack());
style.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, Color.getBlack());
//需要逐个给上样式
for (int i = headFirstRow; i < headFirstRow + headTotalRows; i++) {
Cell cell = sheet.getCells().get(i, 0);
cell.setStyle(style);
cell = sheet.getCells().get(i, 1);
cell.setStyle(style);
}
style.setForegroundColor(getColor("#FFFFFF")); //处理背景色
style.setPattern(BackgroundType.SOLID);
for (int i = headFirstRow + headTotalRows; i < dataRowCount; i++) {
sheet.getCells().get(i, 0).setStyle(style);
}
}
/**
*
*
* @param startCell
* @param endCell
* @param table
*/
public static void mergeCells(com.aspose.words.Cell startCell, com.aspose.words.Cell endCell, Table table) {
Point startCellPos = new Point(startCell.getParentRow().indexOf(startCell), table.indexOf(startCell.getParentRow()));
Point endCellPos = new Point(endCell.getParentRow().indexOf(endCell), table.indexOf(endCell.getParentRow()));
Rectangle mergeRange = new Rectangle(Math.min(startCellPos.x,
endCellPos.x), Math.min(startCellPos.y, endCellPos.y),
Math.abs(endCellPos.x - startCellPos.x) + 1,
Math.abs(endCellPos.y - startCellPos.y) + 1);
for (com.aspose.words.Row row : table.getRows()) {
for (com.aspose.words.Cell cell : row.getCells()) {
Point currentPos = new Point(row.indexOf(cell), table.indexOf(row));
if (mergeRange.contains(currentPos)) {
if (currentPos.x == mergeRange.x) {
cell.getCellFormat().setHorizontalMerge(CellMerge.FIRST);
cell.getCellFormat().setVerticalAlignment(CellVerticalAlignment.CENTER);
} else {
cell.getCellFormat().setHorizontalMerge(CellMerge.PREVIOUS);
}
if (currentPos.y == mergeRange.y) {
cell.getCellFormat().setVerticalMerge(CellMerge.FIRST);
} else {
cell.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);
}
}
}
}
}
/**
* Sheet
*
* @param sheet
* @return
*/
public static int getDataRowsCount(Worksheet sheet) {
// 获取工作表中的最后一行索引0-based
int lastRowIndex = sheet.getCells().getMaxDataRow();
//从这一行向上找如果连续8列都是空的说明无效继续向上
while (true) {
Row row = sheet.getCells().getRows().get(lastRowIndex);
boolean flag = false;
for (int i = 0; i < 8; i++) {
if (!StrKit.isBlank(row.get(i).getStringValue())) {
flag = true;
break;
}
}
if (flag) break;
lastRowIndex--;
}
return lastRowIndex + 1;
}
}

@ -1,25 +0,0 @@
package com.dsideal.QingLong.Util;
import com.aspose.words.*;
public class ReplaceAndInsertImage implements IReplacingCallback {
public String url;
public ReplaceAndInsertImage(String url) {
this.url = url;
}
@Override
public int replacing(ReplacingArgs e) throws Exception {
//获取当前节点
Node node = e.getMatchNode();
//获取当前文档
Document document = (Document) node.getDocument();
DocumentBuilder builder = new DocumentBuilder(document);
// //将光标移动到指定节点
builder.moveTo(node);
// //插入图片
builder.insertImage(url);
return ReplaceAction.REPLACE;
}
}
Loading…
Cancel
Save