Commit 591a74a6 authored by wangxl's avatar wangxl

1

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