Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pdf2pptx
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guanzixin
pdf2pptx
Commits
5815c54d
Commit
5815c54d
authored
5 years ago
by
guanguan1009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加日志配置
parent
151cb447
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
51 deletions
+70
-51
src/main/java/com/jtyjy/pdf2pptx/converter/Pdf2Pptx.java
+6
-51
src/main/resources/logback-spring.xml
+64
-0
No files found.
src/main/java/com/jtyjy/pdf2pptx/converter/Pdf2Pptx.java
View file @
5815c54d
...
@@ -22,60 +22,16 @@ public class Pdf2Pptx {
...
@@ -22,60 +22,16 @@ public class Pdf2Pptx {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
//读取指定文件夹下所有文件并转换为图片
//读取指定文件夹下所有文件并转换为图片
List
<
String
>
allFilePathName
=
new
ArrayList
<>();
// conver(Constant.SOURCE_PATH);
FileUtil
.
getAllFilePathNameRe
(
Constant
.
SOURCE_PATH
,
allFilePathName
);
for
(
String
filePathName
:
allFilePathName
)
{
File
file
=
new
File
(
filePathName
);
if
(
file
.
getName
().
endsWith
(
".pdf"
))
{
//判断图片是否存在
List
<
String
>
allDirPathName
=
new
ArrayList
<>();
FileUtil
.
getAllDirPathNameRe
(
Constant
.
SOURCE_PATH
,
allDirPathName
);
if
(!
allDirPathName
.
contains
(
file
.
getAbsolutePath
().
replace
(
".pdf"
,
"_图片"
)))
{
logger
.
info
(
"转换pdf:{} 为图片开始"
,
file
.
getAbsolutePath
());
long
begin
=
System
.
currentTimeMillis
();
Pdf2Png
.
pdf2Image
(
file
.
getAbsolutePath
(),
file
.
getParent
(),
350
);
long
end
=
System
.
currentTimeMillis
();
logger
.
info
(
"转换pdf:{} 为图片完成,耗时{}ms"
,
file
.
getAbsolutePath
(),
end
-
begin
);
}
else
{
logger
.
info
(
"文件:{} 已经转换"
,
file
.
getName
());
}
}
}
logger
.
info
(
"======== pdf转图片已完成,准备生成pptx ========"
);
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
//将图片插入PPT
List
<
String
>
allDirPathName
=
new
ArrayList
<>();
FileUtil
.
getAllDirPathNameRe
(
Constant
.
SOURCE_PATH
,
allDirPathName
);
for
(
String
dirPathName
:
allDirPathName
)
{
File
dir
=
new
File
(
dirPathName
);
//判断ppt是否存在
if
(
dir
.
getName
().
endsWith
(
"_图片"
))
{
List
<
String
>
allPptPathFileName
=
new
ArrayList
<>();
FileUtil
.
getAllFilePathNameRe
(
Constant
.
SOURCE_PATH
,
allPptPathFileName
);
if
(!
allPptPathFileName
.
contains
(
dir
.
getAbsolutePath
().
replace
(
"_图片"
,
".pptx"
)))
{
List
<
String
>
filePathNames
=
FileUtil
.
getAllFilePathName
(
dir
.
getAbsolutePath
());
//转换
logger
.
info
(
"开始转换图片:{} 为pptx"
,
dir
.
getName
());
long
begin
=
System
.
currentTimeMillis
();
Png2Pptx
.
createPicturePptx
(
filePathNames
,
dir
);
long
end
=
System
.
currentTimeMillis
();
logger
.
info
(
"转换图片:{} 为pptx完成,耗时:{}ms"
,
dir
.
getName
(),
end
-
begin
);
}
else
{
logger
.
info
(
"文件:{} 已经存在"
,
dir
.
getName
()
+
".pptx"
);
}
}
}
}
}
public
void
converte
(
String
path
){
public
void
converte
(
String
path
){
conver
(
path
);
}
private
static
void
conver
(
String
path
)
{
//读取指定文件夹下所有文件并转换为图片
//读取指定文件夹下所有文件并转换为图片
/*
List<String> allFilePathName = new ArrayList<>();
List
<
String
>
allFilePathName
=
new
ArrayList
<>();
FileUtil
.
getAllFilePathNameRe
(
path
,
allFilePathName
);
FileUtil
.
getAllFilePathNameRe
(
path
,
allFilePathName
);
for
(
String
filePathName
:
allFilePathName
)
{
for
(
String
filePathName
:
allFilePathName
)
{
...
@@ -124,7 +80,6 @@ public class Pdf2Pptx {
...
@@ -124,7 +80,6 @@ public class Pdf2Pptx {
}
}
}
}
*/
}
}
}
}
This diff is collapsed.
Click to expand it.
src/main/resources/logback-spring.xml
0 → 100644
View file @
5815c54d
<?xml version="1.0" encoding="UTF-8"?>
<configuration
scan=
"true"
scanPeriod=
"30 seconds"
debug=
"false"
>
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property
name=
"LOG_HOME"
value=
"/home/javaLog"
/>
<!--<property name="appName" value="${elk.jty.app.name}" />-->
<!--<property name="serverId" value="${elk.jty.app.serverId}" />-->
<!--<property name="logstashHost" value="192.168.242.8" />-->
<!--<property name="logstashPort" value="9601" />-->
<!--<springProperty scope="context" name="appName" source="elk.jty.app.name" />-->
<!-- 该配置将作为存入ES索引名称的一部分,所以不能含有大写字母 -->
<springProperty
scope=
"context"
name=
"appName"
source=
"spring.application.name"
/>
<property
name=
"outFormat"
value=
"%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n"
/>
<property
name=
"outFormatFile"
value=
"[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%X{sessionId}] [%X{servlet_path}] [%X{username}] [%X{res_status}] [%X{execution_time}] [%thread] %-5level %logger{50} - %msg%n"
/>
<contextName>
${APP_Name}
</contextName>
<!--控制台日志, 控制台输出 -->
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度,%msg:日志消息,%n是换行符-->
<pattern>
${outFormat}
</pattern>
</encoder>
</appender>
<!--文件日志, 按照每天生成日志文件 -->
<appender
name=
"FILE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${LOG_HOME}/TestWeb.log
</file>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<fileNamePattern>
${LOG_HOME}/%d{yyyy-MM}/TestWeb.%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<maxFileSize>
10MB
</maxFileSize>
<maxHistory>
30
</maxHistory>
</rollingPolicy>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>
${outFormat}
</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制 -->
<logger
name=
"org.hibernate.type.descriptor.sql.BasicBinder"
level=
"TRACE"
/>
<logger
name=
"org.hibernate.type.descriptor.sql.BasicExtractor"
level=
"DEBUG"
/>
<logger
name=
"org.hibernate.SQL"
level=
"DEBUG"
/>
<logger
name=
"org.hibernate.engine.QueryParameters"
level=
"DEBUG"
/>
<logger
name=
"org.hibernate.engine.query.HQLQueryPlan"
level=
"DEBUG"
/>
<!--myibatis log configure-->
<!--<logger name="com.apache.ibatis" level="TRACE"/>-->
<!--<logger name="java.sql.Connection" level="DEBUG"/>-->
<!--<logger name="java.sql.Statement" level="DEBUG"/>-->
<!--<logger name="java.sql.PreparedStatement" level="DEBUG"/>-->
<!-- 日志输出级别 -->
<root
level=
"INFO"
>
<appender-ref
ref=
"STDOUT"
/>
<appender-ref
ref=
"FILE"
/>
</root>
</configuration>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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