|
|
|
@ -314,18 +314,21 @@ public class FileEntity extends BaseEntity {
|
|
|
|
|
*/
|
|
|
|
|
public static void tryConvertPDF(FileEntity fileEntity) {
|
|
|
|
|
try {
|
|
|
|
|
if (null != fileEntity && isCreatePdf(fileEntity.getAbsoluteUrl())) {
|
|
|
|
|
if (null != fileEntity && isCreatePdf(fileEntity.getUrl())) {
|
|
|
|
|
// 相对路径
|
|
|
|
|
String relativeUrl = fileEntity.getUrl();
|
|
|
|
|
// 绝对路径
|
|
|
|
|
String absoluteUrl = fileEntity.getAbsoluteUrl();
|
|
|
|
|
BufferedInputStream inputStream = FileUtil.getInputStream(absoluteUrl);
|
|
|
|
|
// 同名文件,多生成一个pdf文件
|
|
|
|
|
String pdfName = absoluteUrl.replaceAll("\\.[^\\.]+", ".pdf");
|
|
|
|
|
String relativePdfName = relativeUrl.replaceAll("\\.[^\\.]+", ".pdf");
|
|
|
|
|
FileOutputStream outputStream = new FileOutputStream(pdfName);
|
|
|
|
|
// 根据类型来转换成为pdf
|
|
|
|
|
boolean convertedSuccess = PDFConverUtil.convertToPDFByFileNameSuffix(absoluteUrl, inputStream, outputStream);
|
|
|
|
|
if(convertedSuccess) {
|
|
|
|
|
// 转换成功,则返回给前端
|
|
|
|
|
fileEntity.set("cvPDFAbsoluteUrl", pdfName);
|
|
|
|
|
fileEntity.set("cvPDFUrl", relativePdfName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch (IOException e) {
|
|
|
|
|