Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
V
volunteer_service
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
licc
volunteer_service
Commits
9c18184f
Commit
9c18184f
authored
Feb 02, 2021
by
liaoanyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PC端增加我的方案导出功能---2
parent
144d592d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
SchemeRecordServiceImpl.java
...n/wisenergy/service/app/impl/SchemeRecordServiceImpl.java
+5
-3
No files found.
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/SchemeRecordServiceImpl.java
View file @
9c18184f
...
@@ -137,8 +137,10 @@ public class SchemeRecordServiceImpl extends ServiceImpl<SchemeRecordMapper, Sch
...
@@ -137,8 +137,10 @@ public class SchemeRecordServiceImpl extends ServiceImpl<SchemeRecordMapper, Sch
//调用工具生成PDF
//调用工具生成PDF
try
{
try
{
// 1.新建document对象
// 1.新建document对象
Document
document
=
new
Document
(
PageSize
.
A4
);
// 建立一个Document对象
Document
document
=
new
Document
(
PageSize
.
A4
);
//创建文件名称
Long
lon
=
System
.
currentTimeMillis
();
// 2.建立一个书写器(Writer)与document对象关联
// 2.建立一个书写器(Writer)与document对象关联
OutputStream
buffer
=
new
ByteArrayOutputStream
();
OutputStream
buffer
=
new
ByteArrayOutputStream
();
PdfWriter
writer
=
PdfWriter
.
getInstance
(
document
,
buffer
);
PdfWriter
writer
=
PdfWriter
.
getInstance
(
document
,
buffer
);
...
@@ -156,7 +158,7 @@ public class SchemeRecordServiceImpl extends ServiceImpl<SchemeRecordMapper, Sch
...
@@ -156,7 +158,7 @@ public class SchemeRecordServiceImpl extends ServiceImpl<SchemeRecordMapper, Sch
// 设置内容格式 以及 编码方式
// 设置内容格式 以及 编码方式
response
.
setContentType
(
"application/pdf"
);
response
.
setContentType
(
"application/pdf"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setHeader
(
"Content-disposition"
,
"attachment;file="
+
"text"
+
".pdf"
);
response
.
setHeader
(
"Content-disposition"
,
"attachment;file="
+
lon
.
toString
()
+
".pdf"
);
DataOutput
output
=
new
DataOutputStream
(
response
.
getOutputStream
());
DataOutput
output
=
new
DataOutputStream
(
response
.
getOutputStream
());
byte
[]
bytes
=
((
ByteArrayOutputStream
)
buffer
).
toByteArray
();
byte
[]
bytes
=
((
ByteArrayOutputStream
)
buffer
).
toByteArray
();
...
@@ -171,7 +173,7 @@ public class SchemeRecordServiceImpl extends ServiceImpl<SchemeRecordMapper, Sch
...
@@ -171,7 +173,7 @@ public class SchemeRecordServiceImpl extends ServiceImpl<SchemeRecordMapper, Sch
((
DataOutputStream
)
output
).
close
();
((
DataOutputStream
)
output
).
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
.
getLocalizedMessage
()
);
return
R
.
ok
(
1
,
false
);
}
}
return
R
.
ok
(
0
,
true
);
return
R
.
ok
(
0
,
true
);
}
}
...
...
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