Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
Y
yn-health-science
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐俊
yn-health-science
Commits
591a74a6
Commit
591a74a6
authored
Apr 24, 2025
by
wangxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
8e46a719
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
4 deletions
+30
-4
ProjectInfoToPDF.java
...main/java/com/yiboshi/science/utils/ProjectInfoToPDF.java
+30
-4
No files found.
science-admin/src/main/java/com/yiboshi/science/utils/ProjectInfoToPDF.java
View file @
591a74a6
...
...
@@ -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 字节数组
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment