Commit 591a74a6 authored by wangxl's avatar wangxl

1

parent 8e46a719
...@@ -20,6 +20,7 @@ public class ProjectInfoToPDF { ...@@ -20,6 +20,7 @@ public class ProjectInfoToPDF {
/** /**
* 生成项目申请书和合同书PDF * 生成项目申请书和合同书PDF
*
* @param project 项目信息 * @param project 项目信息
* @return 生成的PDF文件字节数组 * @return 生成的PDF文件字节数组
*/ */
...@@ -77,12 +78,17 @@ public class ProjectInfoToPDF { ...@@ -77,12 +78,17 @@ public class ProjectInfoToPDF {
// 项目经费预算表 // 项目经费预算表
addProjectBudgetTable(document, project, bfChinese, fsChinese); addProjectBudgetTable(document, project, bfChinese, fsChinese);
if (Objects.nonNull(project.getDownloadUrl())) {
String fileExtName = project.getDownloadUrl().substring(project.getDownloadUrl().lastIndexOf(".") + 1);
if (fileExtName.toLowerCase().equals("pdf")) {
// 插入申请书正文PDF // 插入申请书正文PDF
InsertPdfContent(document, "申请书正文", System.getProperty("user.dir") + project.getDownloadUrl(), writer);
} else {
if (null != project.getConvertUrl() && !project.getConvertUrl().trim().isEmpty()) { if (null != project.getConvertUrl() && !project.getConvertUrl().trim().isEmpty()) {
InsertPdfContent(document, "申请书正文", System.getProperty("user.dir") + project.getConvertUrl(), writer); InsertPdfContent(document, "申请书正文", System.getProperty("user.dir") + project.getConvertUrl(), writer);
} }
}
}
// 加载项目组成员简历 // 加载项目组成员简历
List<ComProjectMembersDTO> MemberList = project.getMembers(); List<ComProjectMembersDTO> MemberList = project.getMembers();
if (null != MemberList && MemberList.size() > 0) { if (null != MemberList && MemberList.size() > 0) {
...@@ -122,6 +128,7 @@ public class ProjectInfoToPDF { ...@@ -122,6 +128,7 @@ public class ProjectInfoToPDF {
/** /**
* 加载中文字体 * 加载中文字体
*
* @param fontName 字体文件名 * @param fontName 字体文件名
* @return BaseFont 中文字体 * @return BaseFont 中文字体
* @throws RuntimeException 加载字体失败时抛出异常 * @throws RuntimeException 加载字体失败时抛出异常
...@@ -161,6 +168,7 @@ public class ProjectInfoToPDF { ...@@ -161,6 +168,7 @@ public class ProjectInfoToPDF {
/** /**
* 首页项目信息 * 首页项目信息
*
* @param document * @param document
* @param project * @param project
* @param bfChinese * @param bfChinese
...@@ -236,6 +244,7 @@ public class ProjectInfoToPDF { ...@@ -236,6 +244,7 @@ public class ProjectInfoToPDF {
/** /**
* 添加首页项目表格信息 * 添加首页项目表格信息
*
* @param table * @param table
* @param label * @param label
* @param value * @param value
...@@ -285,6 +294,7 @@ public class ProjectInfoToPDF { ...@@ -285,6 +294,7 @@ public class ProjectInfoToPDF {
/** /**
* 项目基本信息 * 项目基本信息
*
* @param document * @param document
* @param project * @param project
* @param bfChinese * @param bfChinese
...@@ -405,6 +415,7 @@ public class ProjectInfoToPDF { ...@@ -405,6 +415,7 @@ public class ProjectInfoToPDF {
/** /**
* 添加基本信息表格单元格 * 添加基本信息表格单元格
*
* @param table * @param table
* @param label * @param label
* @param value * @param value
...@@ -429,6 +440,7 @@ public class ProjectInfoToPDF { ...@@ -429,6 +440,7 @@ public class ProjectInfoToPDF {
/** /**
* 添加项目组主要成员表格 * 添加项目组主要成员表格
*
* @param document PDF文档 * @param document PDF文档
* @param project 项目信息 * @param project 项目信息
* @param bfChinese 宋体字体 * @param bfChinese 宋体字体
...@@ -539,6 +551,7 @@ public class ProjectInfoToPDF { ...@@ -539,6 +551,7 @@ public class ProjectInfoToPDF {
/** /**
* 添加项目绩效目标表 * 添加项目绩效目标表
*
* @param document PDF文档 * @param document PDF文档
* @param project 项目信息 * @param project 项目信息
* @param bfChinese 宋体字体 * @param bfChinese 宋体字体
...@@ -765,6 +778,7 @@ public class ProjectInfoToPDF { ...@@ -765,6 +778,7 @@ public class ProjectInfoToPDF {
/** /**
* 项目经费预算表 * 项目经费预算表
*
* @param document * @param document
* @param project * @param project
* @param bfChinese * @param bfChinese
...@@ -936,8 +950,8 @@ public class ProjectInfoToPDF { ...@@ -936,8 +950,8 @@ public class ProjectInfoToPDF {
float yStep = height / 3; // 垂直间距 float yStep = height / 3; // 垂直间距
// 在页面上添加多个水印 // 在页面上添加多个水印
for (float y = yStep/2; y < height; y += yStep) { for (float y = yStep / 2; y < height; y += yStep) {
for (float x = xStep/2; x < width; x += xStep) { for (float x = xStep / 2; x < width; x += xStep) {
canvas.showTextAligned(Element.ALIGN_CENTER, canvas.showTextAligned(Element.ALIGN_CENTER,
watermarkText, watermarkText,
x, x,
...@@ -977,6 +991,7 @@ public class ProjectInfoToPDF { ...@@ -977,6 +991,7 @@ public class ProjectInfoToPDF {
/** /**
* 插入PDF文件到指定位置 * 插入PDF文件到指定位置
*
* @param document 目标文档 * @param document 目标文档
* @param titleName 标题名称 * @param titleName 标题名称
* @param pdfPath 要插入的PDF文件路径 * @param pdfPath 要插入的PDF文件路径
...@@ -1021,6 +1036,7 @@ public class ProjectInfoToPDF { ...@@ -1021,6 +1036,7 @@ public class ProjectInfoToPDF {
/** /**
* 加载项目组成员简历 * 加载项目组成员简历
*
* @param document PDF文档 * @param document PDF文档
* @param MemberList 成员列表 * @param MemberList 成员列表
* @param writer PDF写入器 * @param writer PDF写入器
...@@ -1029,13 +1045,23 @@ public class ProjectInfoToPDF { ...@@ -1029,13 +1045,23 @@ public class ProjectInfoToPDF {
// 遍历每个成员的简历 // 遍历每个成员的简历
for (ComProjectMembersDTO member : MemberList) { for (ComProjectMembersDTO member : MemberList) {
if (Objects.nonNull(member.getFileId())) { if (Objects.nonNull(member.getFileId())) {
if (Objects.nonNull(member.getDownloadUrl())) {
String fileExtName = member.getDownloadUrl().substring(member.getDownloadUrl().lastIndexOf(".") + 1);
if (fileExtName.toLowerCase().equals("pdf")) {
InsertPdfContent(document, "", System.getProperty("user.dir") + member.getDownloadUrl(), writer);
} else {
if (null != member.getConvertUrl() && !member.getConvertUrl().trim().isEmpty()) {
InsertPdfContent(document, "", System.getProperty("user.dir") + member.getConvertUrl(), writer); InsertPdfContent(document, "", System.getProperty("user.dir") + member.getConvertUrl(), writer);
} }
} }
} }
}
}
}
/** /**
* 读取PDF文件并返回字节数组 * 读取PDF文件并返回字节数组
*
* @param pdfPath PDF文件路径 * @param pdfPath PDF文件路径
* @return 字节数组 * @return 字节数组
*/ */
......
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