Commit c25e9b2d by wenyang Committed by akexiu

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

parent 57478241
......@@ -5203,7 +5203,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
//PDF模板输出结果文件
String templateResultPDF = tmpPathPDF + practitionerId + "-businessCardE.pdf";
//JPG模板输出结果文件
String templateResultJPG = tmpPathPDF + practitionerId + "-businessCardE.jpg";
String templateResultPNG = tmpPathPDF + practitionerId + "-businessCardE.png";
//填充数据
Map<String, String> initDatas = new HashMap<>();
Map<String, String> initImages = new HashMap<>();
......@@ -5259,6 +5259,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
//按模板填充数据生成结果PDF
PDFTemplate.generatePDF(templatePDF, templateResultPDF, initDatas, initImages);
try {
resp.setBusinessCardPdfUrl(putContractFileToOSS("businessCardEPDF", templateResultPDF, practitionerId));
PDDocument doc = null;
ByteArrayOutputStream os = null;
InputStream stream = null;
......@@ -5272,29 +5273,27 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
PDPageTree pages = doc.getPages();
int pageCount = pages.getCount();
for (int i = 0; i < pageCount; i++) {
BufferedImage bim = pdfRenderer.renderImageWithDPI(i, 92);
os = new ByteArrayOutputStream();
Image image = bim.getScaledInstance(92,58,Image.SCALE_SMOOTH); //设置图像的缩放大小
AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(1,1),null); //设置图像的缩放比例
image = op.filter(bim,null);
ImageIO.write((BufferedImage)image, "jpg", os);
byte[] dataList = os.toByteArray();
// jpg文件转出路径
File file = new File(templateResultJPG);
if (!file.getParentFile().exists()) {
// 不存在则创建父目录及子文件
file.getParentFile().mkdirs();
file.createNewFile();
}
out = new FileOutputStream(file);
out.write(dataList);
BufferedImage bim = pdfRenderer.renderImageWithDPI(i, 70);
ImageIO.write(bim, "png", new File(templateResultPNG));
// os = new ByteArrayOutputStream();
// Image image = bim.getScaledInstance(70,45,Image.SCALE_SMOOTH); //设置图像的缩放大小
// AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(1,1),null); //设置图像的缩放比例
// image = op.filter(bim,null);
// ImageIO.write((BufferedImage)image, "png", os);
// byte[] dataList = os.toByteArray();
// // png文件转出路径
// File file = new File(templateResultPNG);
// if (!file.getParentFile().exists()) {
// // 不存在则创建父目录及子文件
// file.getParentFile().mkdirs();
// file.createNewFile();
// }
// out = new FileOutputStream(file);
// out.write(dataList);
if(i == 0){
resp.setBusinessCardProsUrl(putContractFileToOSS("businessCardEPros", templateResultJPG, practitionerId));
resp.setBusinessCardProsImg(putContractFileToOSS("businessCardEPros", templateResultPNG, practitionerId));
}else if(i == 1){
resp.setBusinessCardConsUrl(putContractFileToOSS("businessCardECons", templateResultJPG, practitionerId));
resp.setBusinessCardConsImg(putContractFileToOSS("businessCardECons", templateResultPNG, practitionerId));
}
}
} catch (Exception e) {
......
......@@ -26,8 +26,9 @@ public class PractitionerBusinessCardResponseVO {
private String mobileNo;//手机号
private String email;//电子邮件
private Integer emailIsActive;//经纪人邮箱是否开通(0=No, 1=Yes)
private String businessCardProsUrl;//电子名片正面Url
private String businessCardConsUrl;//电子名片反面Url
private String businessCardPdfUrl;//电子名片PDF
private String businessCardProsImg;//电子名片正面Url
private String businessCardConsImg;//电子名片反面Url
private CommonResult commonResult;
}
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