Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
10b8164a
Commit
10b8164a
authored
Apr 18, 2019
by
chase
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge 档案管理
parent
424abbe6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
TaxDocumentController.java
...va/pwc/taxtech/atms/controller/TaxDocumentController.java
+3
-2
TaxDocumentServiceImpl.java
...pwc/taxtech/atms/service/impl/TaxDocumentServiceImpl.java
+6
-3
No files found.
atms-api/src/main/java/pwc/taxtech/atms/controller/TaxDocumentController.java
View file @
10b8164a
...
...
@@ -115,8 +115,9 @@ public class TaxDocumentController {
*/
@PostMapping
(
"/previewPDF"
)
@ResponseBody
public
String
previewPDF
(
HttpServletResponse
response
,
@RequestBody
TaxDocumentDto
taxDocumentDto
)
{
return
taxDocumentService
.
previewPDF2
(
response
,
taxDocumentDto
.
getPath
());
public
void
previewPDF
(
HttpServletResponse
response
,
@RequestBody
TaxDocumentDto
taxDocumentDto
)
{
// return taxDocumentService.previewPDF2(response,taxDocumentDto.getPath());
taxDocumentService
.
previewPDF
(
response
,
taxDocumentDto
.
getPath
());
/*InputStream is = null;
ByteArrayOutputStream os = null;
try {
...
...
atms-api/src/main/java/pwc/taxtech/atms/service/impl/TaxDocumentServiceImpl.java
View file @
10b8164a
...
...
@@ -438,8 +438,10 @@ public class TaxDocumentServiceImpl {
try
{
sos
=
response
.
getOutputStream
();
PDFToImg
(
sos
,
path
,
getPDFNum
(
path
),
imageType
);
}
catch
(
IOException
e
)
{
sos
.
flush
();
}
catch
(
Exception
e
)
{
log
.
error
(
"PDF转换图片异常: "
+
e
.
getMessage
());
throw
new
RuntimeException
(
"PDF转换异常"
);
}
finally
{
try
{
sos
.
close
();
...
...
@@ -1162,7 +1164,7 @@ public class TaxDocumentServiceImpl {
* @throws IOException
* imgType:转换后的图片类型 jpg,png
*/
private
void
PDFToImg
(
OutputStream
sos
,
String
fileUrl
,
int
page
,
String
imgType
)
throws
IO
Exception
{
private
void
PDFToImg
(
OutputStream
sos
,
String
fileUrl
,
int
page
,
String
imgType
)
throws
Exception
{
PDDocument
pdDocument
=
null
;
/* dpi越大转换后越清晰,相对转换速度越慢 */
int
dpi
=
100
;
...
...
@@ -1171,12 +1173,13 @@ public class TaxDocumentServiceImpl {
PDFRenderer
renderer
=
new
PDFRenderer
(
pdDocument
);
int
pages
=
pdDocument
.
getNumberOfPages
();
if
(
page
<=
pages
&&
page
>
0
)
{
BufferedImage
image
=
renderer
.
renderImageWithDPI
(
page
,
dpi
);
BufferedImage
image
=
renderer
.
renderImageWithDPI
(
page
-
1
,
dpi
);
ImageIO
.
write
(
image
,
imgType
,
sos
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
RuntimeException
(
"PDF转换异常"
);
}
finally
{
if
(
pdDocument
!=
null
)
{
pdDocument
.
close
();
...
...
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