Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fill-system
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
廖旭伟
fill-system
Commits
2b8b3268
Commit
2b8b3268
authored
Feb 17, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改热门词汇
parent
7f67592b
Pipeline
#2471
canceled with stages
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
fill-manager/src/main/java/com/mortals/xhx/common/utils/WordUtil.java
.../src/main/java/com/mortals/xhx/common/utils/WordUtil.java
+12
-9
No files found.
fill-manager/src/main/java/com/mortals/xhx/common/utils/WordUtil.java
View file @
2b8b3268
...
...
@@ -14,6 +14,7 @@ import com.mortals.framework.util.DateUtils;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
import
lombok.extern.apachecommons.CommonsLog
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.pdfbox.pdmodel.PDDocument
;
import
org.apache.pdfbox.rendering.PDFRenderer
;
...
...
@@ -26,7 +27,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.Map
;
@
CommonsLog
@
Slf4j
public
class
WordUtil
{
private
Configuration
configure
=
null
;
...
...
@@ -77,7 +78,7 @@ public class WordUtil {
public
static
String
convertWordToJPEG
(
String
inputFile
,
String
jpegPath
)
{
try
{
log
.
info
(
String
.
format
(
"word to jpg文件转换开始:%s"
,
DateUtils
.
getCurrStrDateTime
()
));
log
.
info
(
"word to jpg文件转换开始,inputFile:{},jepgPath:{}:{}"
,
inputFile
,
jpegPath
,
DateUtils
.
getCurrStrDateTime
(
));
// 转换开始前时间
long
old
=
System
.
currentTimeMillis
();
// 新建的PDF文件路径
...
...
@@ -85,10 +86,8 @@ public class WordUtil {
//FileOutputStream os = new FileOutputStream(file);
// 要转换的word文档的路径
Document
doc
=
new
Document
(
inputFile
);
// 全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF 相互转换
//doc.save(os, SaveFormat.JPEG);
ImageSaveOptions
options
=
new
ImageSaveOptions
(
SaveFormat
.
JPEG
);
options
.
setPrettyFormat
(
true
);
options
.
setUseAntiAliasing
(
true
);
...
...
@@ -104,10 +103,12 @@ public class WordUtil {
}
BufferedImage
mergeImage
=
mergeImage
(
false
,
imageList
);
ImageIO
.
write
(
mergeImage
,
"png"
,
file
);
ImageIO
.
write
(
mergeImage
,
"jpg"
,
file
);
// 转换结束后时间
/* doc.save(jpegPath);*/
doc
.
cleanup
();
long
now
=
System
.
currentTimeMillis
();
//os.close();
log
.
info
(
"文件转换结束,共耗时:"
+
((
now
-
old
)
/
1000.0
)
+
"秒"
);
return
jpegPath
;
}
catch
(
Exception
e
)
{
...
...
@@ -234,11 +235,12 @@ public class WordUtil {
}
public
static
void
main
(
String
[]
args
)
{
/* String docPath = "E:\\pic\\doc\\附件1-四川省危险废物经营许可证申请表(补办)空白
.docx";
String
docPath
=
"E:\\pic\\doc\\2
.docx"
;
String
pdfPath = "E:\\pic\\pdf\\附件1-四川省危险废物经营许可证申请表(补办)空白
.jpg";
String
jpgPath
=
"E:\\pic\\doc\\2
.jpg"
;
WordUtil.convertWordToJPEG(docPath, jpgPath);*/
WordUtil
.
convertWordToJPEG
(
docPath
,
jpgPath
);
/*
String pdfPath = "E:\\pic\\pdf\\1.pdf";
...
...
@@ -246,6 +248,7 @@ public class WordUtil {
WordUtil.pdfToImages(pdfPath, jpgPath);
*/
}
...
...
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