|
@@ -2,6 +2,7 @@ package com.qmth.distributed.print.business.util;
|
|
|
|
|
|
import com.itextpdf.text.Document;
|
|
|
import com.itextpdf.text.pdf.*;
|
|
|
+import com.qmth.boot.tools.models.ByteArray;
|
|
|
import com.qmth.distributed.print.business.bean.dto.PdfDto;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.enums.PageSizeEnum;
|
|
@@ -46,7 +47,7 @@ public class PdfUtil {
|
|
|
StringJoiner dirName = null;
|
|
|
try {
|
|
|
if (Objects.nonNull(files) && files.length > 0) {
|
|
|
- document = new Document(new PdfReader(files[0]).getPageSize(1));
|
|
|
+ document = new Document(new PdfReader(ByteArray.fromFile(new File(files[0])).value()).getPageSize(1));
|
|
|
if (Objects.isNull(outputPath)) {
|
|
|
LocalDateTime nowTime = LocalDateTime.now();
|
|
|
StringJoiner stringJoiner = new StringJoiner("").add(SystemConstant.PDF_TEMP_FILES_DIR).add(File.separator);
|
|
@@ -61,7 +62,7 @@ public class PdfUtil {
|
|
|
copy = new PdfSmartCopy(document, new FileOutputStream(outputPath));
|
|
|
document.open();
|
|
|
for (int i = 0; i < files.length; i++) {
|
|
|
- PdfReader reader = new PdfReader(files[i]);
|
|
|
+ PdfReader reader = new PdfReader(ByteArray.fromFile(new File(files[i])).value());
|
|
|
int numberOfPages = reader.getNumberOfPages();
|
|
|
for (int j = 1; j <= numberOfPages; j++) {
|
|
|
document.newPage();
|
|
@@ -98,7 +99,7 @@ public class PdfUtil {
|
|
|
int pageCount = 0;
|
|
|
try {
|
|
|
if (Objects.nonNull(pdfFile)) {
|
|
|
- reader = new PdfReader(pdfFile.getPath());
|
|
|
+ reader = new PdfReader(ByteArray.fromFile(pdfFile).value());
|
|
|
pageCount = reader.getNumberOfPages();
|
|
|
if (Math.abs(pageCount % 2) == 1) {//取偶
|
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
@@ -134,7 +135,7 @@ public class PdfUtil {
|
|
|
PdfReader reader = null;
|
|
|
try {
|
|
|
if (Objects.nonNull(pdfFile)) {
|
|
|
- reader = new PdfReader(pdfFile.getPath());
|
|
|
+ reader = new PdfReader(ByteArray.fromFile(pdfFile).value());
|
|
|
return reader.getNumberOfPages();
|
|
|
}
|
|
|
} catch (Exception e) {
|