Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
535d9d7e
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
535d9d7e
编写于
3月 18, 2022
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
html转图片接口优化
上级
361dea6f
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
60 addition
and
17 deletion
+60
-17
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionHtmlToImage.java
.../assemble/surface/jaxrs/attachment/ActionHtmlToImage.java
+58
-16
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/AttachmentAction.java
...m/assemble/surface/jaxrs/attachment/AttachmentAction.java
+2
-1
未找到文件。
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionHtmlToImage.java
浏览文件 @
535d9d7e
...
...
@@ -78,11 +78,12 @@ class ActionHtmlToImage extends BaseAction {
workHtml
=
"无内容"
;
}
if
(
workHtml
.
toLowerCase
().
indexOf
(
"<html"
)
==
-
1
)
{
workHtml
=
"<html><head></head><body>"
+
workHtml
+
"</body></html>"
;
workHtml
=
"<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head>"
+
"<body>"
+
workHtml
+
"</body></html>"
;
}
String
name
=
StringUtils
.
split
(
effectivePerson
.
getDistinguishedName
(),
"@"
)[
0
]
+
DateTools
.
compact
(
new
Date
())
+
".
jp
g"
;
String
name
=
StringUtils
.
split
(
effectivePerson
.
getDistinguishedName
(),
"@"
)[
0
]
+
DateTools
.
compact
(
new
Date
())
+
".
pn
g"
;
if
(
StringUtils
.
isNotEmpty
(
wi
.
getTitle
()))
{
name
=
wi
.
getTitle
()
+
".
jp
g"
;
name
=
wi
.
getTitle
()
+
".
pn
g"
;
}
byte
[]
bytes
=
null
;
try
(
Playwright
playwright
=
Playwright
.
create
())
{
...
...
@@ -102,16 +103,16 @@ class ActionHtmlToImage extends BaseAction {
page
.
setContent
(
workHtml
);
Page
.
ScreenshotOptions
screenshotOptions
=
new
Page
.
ScreenshotOptions
();
screenshotOptions
.
setFullPage
(
true
);
if
(
wi
.
getHtmlWidth
()
!=
null
&&
wi
.
getHtmlHeight
()
!=
null
)
{
screenshotOptions
.
setClip
(
wi
.
getStartX
(),
wi
.
getStartY
(),
wi
.
getHtmlWidth
(),
wi
.
getHtmlHeight
());
}
if
(
BooleanUtils
.
isTrue
(
wi
.
getOmitBackground
())){
screenshotOptions
.
setOmitBackground
(
wi
.
getOmitBackground
());
}
File
tempDir
=
Config
.
dir_local_temp
();
FileTools
.
forceMkdir
(
tempDir
);
File
file
=
new
File
(
tempDir
,
name
);
//screenshotOptions.setPath(Paths.get("/Users/chengjian/dev/tmp/screenshot-" + browserType.name() + ".png"));
screenshotOptions
.
setPath
(
file
.
toPath
());
if
(
wi
.
getQuality
()!=
null
&&
wi
.
getQuality
()>
20
){
screenshotOptions
.
setQuality
(
wi
.
getQuality
());
}
else
{
screenshotOptions
.
setQuality
(
80
);
}
page
.
screenshot
(
screenshotOptions
);
bytes
=
FileUtils
.
readFileToByteArray
(
file
);
break
;
...
...
@@ -173,8 +174,16 @@ class ActionHtmlToImage extends BaseAction {
private
String
workHtml
;
@FieldDescribe
(
"图片标题"
)
private
String
title
;
@FieldDescribe
(
"图片质量,默认80,值越大越清晰"
)
private
Integer
quality
;
@FieldDescribe
(
"html正文宽度,允许为空."
)
private
Double
htmlWidth
;
@FieldDescribe
(
"html正文高度,允许为空."
)
private
Double
htmlHeight
;
@FieldDescribe
(
"html的X轴开始位置,允许为空."
)
private
Double
startX
;
@FieldDescribe
(
"html的Y轴开始位置,允许为空."
)
private
Double
startY
;
@FieldDescribe
(
"背景是否透明,默认为false."
)
private
Boolean
omitBackground
;
@FieldDescribe
(
"工作标识,把图片保存到工单的附件中,非必填"
)
private
String
workId
;
@FieldDescribe
(
"位置,工作标识不为空的时候必填"
)
...
...
@@ -212,12 +221,44 @@ class ActionHtmlToImage extends BaseAction {
this
.
site
=
site
;
}
public
Integer
getQuality
()
{
return
quality
;
public
Double
getStartX
()
{
return
startX
==
null
?
0
D
:
startX
;
}
public
void
setStartX
(
Double
startX
)
{
this
.
startX
=
startX
;
}
public
Double
getStartY
()
{
return
startY
==
null
?
0
D
:
startX
;
}
public
void
setStartY
(
Double
startY
)
{
this
.
startY
=
startY
;
}
public
Double
getHtmlWidth
()
{
return
htmlWidth
;
}
public
void
setHtmlWidth
(
Double
htmlWidth
)
{
this
.
htmlWidth
=
htmlWidth
;
}
public
Double
getHtmlHeight
()
{
return
htmlHeight
;
}
public
void
setHtmlHeight
(
Double
htmlHeight
)
{
this
.
htmlHeight
=
htmlHeight
;
}
public
Boolean
getOmitBackground
()
{
return
omitBackground
;
}
public
void
set
Quality
(
Integer
quality
)
{
this
.
quality
=
quality
;
public
void
set
OmitBackground
(
Boolean
omitBackground
)
{
this
.
omitBackground
=
omitBackground
;
}
}
...
...
@@ -240,10 +281,11 @@ class ActionHtmlToImage extends BaseAction {
try
(
Browser
browser
=
browserType
.
launch
(
options
))
{
BrowserContext
context
=
browser
.
newContext
();
Page
page
=
context
.
newPage
();
page
.
navigate
(
"file:///Users/chengjian/
dev/temp/test
.html"
);
page
.
navigate
(
"file:///Users/chengjian/
Downloads/test11
.html"
);
Page
.
ScreenshotOptions
screenshotOptions
=
new
Page
.
ScreenshotOptions
();
screenshotOptions
.
setFullPage
(
true
);
screenshotOptions
.
setClip
(
0
,
0
,
800
,
2310
);
screenshotOptions
.
setOmitBackground
(
true
);
//screenshotOptions.setQuality(2);
screenshotOptions
.
setPath
(
Paths
.
get
(
"/Users/chengjian/dev/temp/screenshot-"
+
browserType
.
name
()
+
".png"
));
page
.
screenshot
(
screenshotOptions
);
...
...
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/AttachmentAction.java
浏览文件 @
535d9d7e
...
...
@@ -1348,7 +1348,8 @@ public class AttachmentAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"html转图片工具类,转换后如果工作不为空通过downloadWithWork接口下载,为空downloadTransfer接口下载."
,
action
=
ActionHtmlToImage
.
class
)
@JaxrsMethodDescribe
(
value
=
"html转图片工具类,通过微软playwright工具以截图方式生成图片,"
+
"转换后如果工作不为空通过downloadWithWork接口下载,为空downloadTransfer接口下载."
,
action
=
ActionHtmlToImage
.
class
)
@POST
@Path
(
"html/to/image"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录