Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vehicle-quality-review
Project
Project
Details
Activity
Releases
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
王飞
vehicle-quality-review
Commits
21b5ea80
Commit
21b5ea80
authored
Apr 03, 2024
by
盖献康
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gaixiankang' into 'dev'
企业留档文件 - bug(70966) See merge request
!265
parents
8ed11595
4e3ea177
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
3 deletions
+32
-3
PdfTemplateManagementServiceImpl.java
.../ruoyi/service/impl/PdfTemplateManagementServiceImpl.java
+32
-3
No files found.
quality-review/src/main/java/com/ruoyi/service/impl/PdfTemplateManagementServiceImpl.java
View file @
21b5ea80
...
...
@@ -202,12 +202,17 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
// 新建
PdfBaseWriter
document
=
new
PdfBaseWriter
(
outputStream
);
document
.
setMargins
(
40
,
40
,
50
,
40
);
PdfWriter
writer
=
PdfWriter
.
getInstance
(
document
,
outputStream
);
MyHeaderFooter
headerFooter
=
new
MyHeaderFooter
();
headerText
=
data
.
getInspectionCenterName
();
writer
.
setPageEvent
(
headerFooter
);
// 打开
document
.
open
();
// 内容
// 封面
document
.
setParagraph
(
data
.
getInspectionCenterName
(),
12
f
,
0
,
60
,
15
f
,
12
0
f
);
document
.
setParagraph
(
"企业留档文件"
,
30
f
,
Element
.
ALIGN_CENTER
,
0
,
15
f
,
180
f
);
document
.
setParagraph
(
" "
,
30
f
,
Element
.
ALIGN_CENTER
,
0
,
60
f
,
4
0
f
);
document
.
setParagraph
(
"企业留档文件"
,
30
f
,
Element
.
ALIGN_CENTER
,
0
,
60
f
,
180
f
);
PdfPTable
customTable
=
new
PdfPTable
(
new
float
[]{
15
,
50
});
customTable
.
setWidthPercentage
(
70
);
document
.
writeNoBorderCell
(
"检验依据:"
,
Element
.
ALIGN_LEFT
,
1
,
1
,
customTable
);
...
...
@@ -222,7 +227,6 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
document
.
setParagraph
(
data
.
getInspectionCenterName
(),
20
f
,
Element
.
ALIGN_CENTER
,
0
,
100
f
,
0
f
);
// 下一页
document
.
newPage
();
document
.
setParagraph
(
data
.
getInspectionCenterName
(),
12
f
,
0
,
30
,
15
f
,
20
f
);
// 创建表格
List
<
String
>
list
=
Arrays
.
asList
(
"文件名称"
,
"文件目录"
,
"标准章节"
,
"标准要求"
,
"审查要点"
);
float
[]
columnWidths
=
{
30
,
25
,
25
,
60
,
60
};
...
...
@@ -255,6 +259,31 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
return
uploadMinio
(
outputStream
,
"企业留档文件-"
+
getReportName
());
}
private
static
String
headerText
;
public
static
class
MyHeaderFooter
extends
PdfPageEventHelper
{
// 一页加载完成触发,写入页眉和页脚
@Override
public
void
onEndPage
(
PdfWriter
writer
,
Document
document
)
{
PdfPTable
table
=
new
PdfPTable
(
1
);
try
{
table
.
setTotalWidth
(
PageSize
.
A4
.
getWidth
()
-
80
);
table
.
setWidths
(
new
int
[]
{
40
});
table
.
setLockedWidth
(
true
);
table
.
getDefaultCell
().
setFixedHeight
(-
10
);
table
.
getDefaultCell
().
setBorder
(
Rectangle
.
NO_BORDER
);
table
.
getDefaultCell
().
setBorderWidth
(
0.5f
);
BaseFont
font
=
BaseFont
.
createFont
(
"/fonts/STSong.TTF"
,
BaseFont
.
IDENTITY_H
,
BaseFont
.
EMBEDDED
);
table
.
addCell
(
new
Paragraph
(
headerText
,
new
Font
(
font
)));
// 可以直接使用addCell(str),不过不能指定字体,中文无法显示
// 将页眉写到document中,位置可以指定,指定到下面就是页脚
table
.
writeSelectedRows
(
0
,
-
1
,
40
,
PageSize
.
A4
.
getHeight
()
-
20
,
writer
.
getDirectContent
());
}
catch
(
Exception
de
)
{
throw
new
ExceptionConverter
(
de
);
}
}
}
/**
* 获取企业留档文件数据
* @param taskId
...
...
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