|
|
|
@ -23,13 +23,18 @@ import com.jfinal.kit.StrKit;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Page;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
import com.jfinal.upload.UploadFile;
|
|
|
|
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
|
|
|
import org.apache.pdfbox.pdmodel.PDDocumentInformation;
|
|
|
|
|
import org.apache.poi.openxml4j.util.ZipSecureFile;
|
|
|
|
|
import org.apache.poi.ss.usermodel.IndexedColors;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
@ -800,6 +805,7 @@ public class CollectController extends Controller {
|
|
|
|
|
|
|
|
|
|
//文件名称
|
|
|
|
|
String excel_filename = job_name + "【" + bureau_name + "】.xlsx";
|
|
|
|
|
String pdfName = job_name + "【" + bureau_name + "】";
|
|
|
|
|
|
|
|
|
|
//1、找到upload_excel_filename_user
|
|
|
|
|
Record record = cm.viewFilledJob(job_id, bureau_id);
|
|
|
|
@ -827,13 +833,20 @@ public class CollectController extends Controller {
|
|
|
|
|
if (type_id == 2) {
|
|
|
|
|
String pdfPath = excelPath.replace(".xlsx", ".pdf");
|
|
|
|
|
AsposeUtil.xls2pdf(excelPath, pdfPath);
|
|
|
|
|
/**
|
|
|
|
|
* 解决java.io.IOException: UT010029: Stream is closed报错
|
|
|
|
|
* 由于HttpServlet的request和response里的流都只能读写一次,关掉就没有了, 所以不能使用该方法
|
|
|
|
|
*/
|
|
|
|
|
OutputStream outputStream = getResponse().getOutputStream();
|
|
|
|
|
outputStream.write(FileUtil.readBytes(pdfPath));
|
|
|
|
|
outputStream.flush();
|
|
|
|
|
|
|
|
|
|
//提供带中文文件名的pdf流
|
|
|
|
|
HttpServletResponse response = getResponse();
|
|
|
|
|
response.reset();
|
|
|
|
|
response.setContentType("application/pdf;charset=UTF-8");
|
|
|
|
|
response.setHeader("Content-Disposition", "inline;filename=" + URLEncoder.encode(pdfName, "UTF-8"));//这里的名字并不起作用
|
|
|
|
|
OutputStream out = response.getOutputStream();
|
|
|
|
|
PDDocument document = PDDocument.load(FileUtil.readBytes(pdfPath)); //加载pdf
|
|
|
|
|
PDDocumentInformation info = document.getDocumentInformation(); //获得文档属性对象
|
|
|
|
|
info.setTitle(pdfName); //修改标题属性 这个标题会被展示
|
|
|
|
|
document.setDocumentInformation(info);
|
|
|
|
|
document.save(out); //修改完直接输出到响应体中
|
|
|
|
|
document.close();
|
|
|
|
|
out.close();
|
|
|
|
|
renderNull();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|