Commit 93a66e8b by akexiu

Revert "经纪人名片4.经纪人电子名片由后端返回,支持PDF/png"

This reverts commit 7f3719dc.
parent a229b937
...@@ -5202,6 +5202,8 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -5202,6 +5202,8 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
String tmpPathPDF = PDFConfiguration.getProperty("businessCardE.pdf.temp.path"); String tmpPathPDF = PDFConfiguration.getProperty("businessCardE.pdf.temp.path");
//PDF模板输出结果文件 //PDF模板输出结果文件
String templateResultPDF = tmpPathPDF + practitionerId + "-businessCardE.pdf"; String templateResultPDF = tmpPathPDF + practitionerId + "-businessCardE.pdf";
//JPG模板输出结果文件
String templateResultPNG = tmpPathPDF + practitionerId + "-businessCardE.png";
//填充数据 //填充数据
Map<String, String> initDatas = new HashMap<>(); Map<String, String> initDatas = new HashMap<>();
Map<String, String> initImages = new HashMap<>(); Map<String, String> initImages = new HashMap<>();
...@@ -5258,40 +5260,21 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -5258,40 +5260,21 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
PDFTemplate.generatePDF(templatePDF, templateResultPDF, initDatas, initImages); PDFTemplate.generatePDF(templatePDF, templateResultPDF, initDatas, initImages);
try { try {
resp.setBusinessCardPdfUrl(putContractFileToOSS("businessCardEPDF", templateResultPDF, practitionerId)); resp.setBusinessCardPdfUrl(putContractFileToOSS("businessCardEPDF", templateResultPDF, practitionerId));
// getBusinessCardImg(resp, practitionerId, templateResultPDF, tmpPathPDF); PDDocument doc = null;
} catch (Exception e) { ByteArrayOutputStream os = null;
e.printStackTrace(); InputStream stream = null;
} OutputStream out = null;
} try {
// pdf路径
/** stream = new FileInputStream(templateResultPDF);
* 把PDF转换为图片 // 加载解析PDF文件
* @param resp doc = PDDocument.load(stream);
* @param practitionerId PDFRenderer pdfRenderer = new PDFRenderer(doc);
* @param templateResultPDF PDPageTree pages = doc.getPages();
* @param tmpPathPDF int pageCount = pages.getCount();
* @throws Exception for (int i = 0; i < pageCount; i++) {
* @throws IOException BufferedImage bim = pdfRenderer.renderImageWithDPI(i, 70);
*/ ImageIO.write(bim, "png", new File(templateResultPNG));
private void getBusinessCardImg(PractitionerBusinessCardResponseVO resp, Long practitionerId,
String templateResultPDF,String tmpPathPDF) throws Exception, IOException {
//JPG模板输出结果文件
String templateResultPNG = tmpPathPDF + practitionerId + "-businessCardE.png";
PDDocument doc = null;
ByteArrayOutputStream os = null;
InputStream stream = null;
OutputStream out = null;
try {
// pdf路径
stream = new FileInputStream(templateResultPDF);
// 加载解析PDF文件
doc = PDDocument.load(stream);
PDFRenderer pdfRenderer = new PDFRenderer(doc);
PDPageTree pages = doc.getPages();
int pageCount = pages.getCount();
for (int i = 0; i < pageCount; i++) {
BufferedImage bim = pdfRenderer.renderImageWithDPI(i, 70);
ImageIO.write(bim, "png", new File(templateResultPNG));
// os = new ByteArrayOutputStream(); // os = new ByteArrayOutputStream();
// Image image = bim.getScaledInstance(70,45,Image.SCALE_SMOOTH); //设置图像的缩放大小 // Image image = bim.getScaledInstance(70,45,Image.SCALE_SMOOTH); //设置图像的缩放大小
// AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(1,1),null); //设置图像的缩放比例 // AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(1,1),null); //设置图像的缩放比例
...@@ -5307,22 +5290,25 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -5307,22 +5290,25 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
// } // }
// out = new FileOutputStream(file); // out = new FileOutputStream(file);
// out.write(dataList); // out.write(dataList);
if(i == 0){ if(i == 0){
resp.setBusinessCardProsImg(putContractFileToOSS("businessCardEPros", templateResultPNG, practitionerId)); resp.setBusinessCardProsImg(putContractFileToOSS("businessCardEPros", templateResultPNG, practitionerId));
}else if(i == 1){ }else if(i == 1){
resp.setBusinessCardConsImg(putContractFileToOSS("businessCardECons", templateResultPNG, practitionerId)); resp.setBusinessCardConsImg(putContractFileToOSS("businessCardECons", templateResultPNG, practitionerId));
} }
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw e; throw e;
} finally { } finally {
if (doc != null) doc.close(); if (doc != null) doc.close();
if (os != null) os.close(); if (os != null) os.close();
if (stream != null) stream.close(); if (stream != null) stream.close();
if (out != null) out.close(); if (out != null) out.close();
} }
} } catch (Exception e) {
e.printStackTrace();
}
}
/** /**
* 经纪人申请开通邮箱 * 经纪人申请开通邮箱
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment