Compare commits

...

855 Commits

Author SHA1 Message Date
kl
3d0b14515f test(e2e): align preview URL encoding and docs 2026-03-04 17:24:27 +08:00
kl
e845846d30 test(e2e): guard E2E_MAX_PREVIEW_MS against sub-second values 2026-03-04 15:39:35 +08:00
kl
a7ad4b4fe4 test(e2e): follow-up fixes for post-merge copilot review feedback 2026-03-04 15:16:49 +08:00
kl
68d4d23a4b test(e2e): phase-3 add nightly full run and perf smoke checks (#717)
* test(e2e): phase-3 add nightly workflow and perf smoke suite

* test(e2e): address copilot review for phase-3 fixture and readiness flow
2026-03-04 15:06:15 +08:00
kl
bb457924cd test(e2e): phase-2 add Office and zip smoke automation (#714)
* test(e2e): phase-2 add office and zip smoke coverage

* test(e2e): address copilot review for fixture stability and CI python setup

* test(e2e): fix preflight fixture scope and path handling

* test(e2e): harden fixture preflight and remove duplicate generation

* test(e2e): remove redundant zip install and cleanup temp zip dir

* test(e2e): ensure zip dependency and unify python command in docs

* docs(e2e): align README with npm gen scripts and python3 usage
2026-03-04 14:34:32 +08:00
kl
a0d78c57e3 test(e2e): add MVP end-to-end automation suite and CI workflow (#713)
* test(e2e): add mvp playwright suite and PR workflow

* ci(e2e): use JDK 21 for kkFileView build
2026-03-04 10:46:41 +08:00
kl
7f16243270 chore(github): add accelerated support notice for urgent issues (#712)
* chore(github): add support acceleration notice to issue templates and auto-comments

* chore(actions): make copilot auto-comment bilingual and single-message
2026-03-03 19:28:23 +08:00
kl
36a75e86ac chore(github): add bilingual feature request issue template (#711)
* chore(github): add bilingual feature request issue template

* chore(github): refine feature template wording and split intake path
2026-03-03 19:10:05 +08:00
kl
7c41200028 chore(actions): auto-close >1y issues and trigger copilot triage comments 2026-03-03 18:57:59 +08:00
kl
3da0c523e8 chore(github): add bilingual required issue template 2026-03-03 18:26:39 +08:00
kl
8c3bc81e08 fix(security): support wildcard/cidr host pattern matching (#710)
* fix(security): support wildcard/cidr host pattern matching

* fix(security): harden host matching against null and DNS rebinding

* fix(security): handle ipv4 unsigned range and deny template fallback

* test(security): verify CIDR matching for IPv4 upper boundary

* fix(security): set UTF-8 deny response and use Locale.ROOT

* fix(security): enforce whitelist with blacklist and harden wildcard rules
2026-03-03 15:26:35 +08:00
陈精华
92ca92bee6 支持Java25环境 2025-12-03 18:46:23 +08:00
kailing
64c82a2406 !334 update docker/kkfileview-base/Dockerfile.
Merge pull request !334 from 云上小朱/N/A
2025-11-17 00:53:58 +00:00
云上小朱
e44ef813a1 update docker/kkfileview-base/Dockerfile.
在文件docker/kkfileview-base/Dockerfile中
我看到POM里写的Java21,但是Dockerfile写的JDK8. 是否应改为JDK21,我在本地测试,改为JDK21可正常打包代码并正常运行。

Signed-off-by: 云上小朱 <13077784+ysxz2025@user.noreply.gitee.com>
2025-11-14 01:04:31 +00:00
kl
9f3b45a4c7 安全:强制用户配置可访问域名的白名单或者黑名单,提高安全性 (#692)
* 安全:强制用户配置可访问域名的白名单或者黑名单,提高安全性

* 安全:强制用户配置可访问域名的白名单或者黑名单,提高安全性

* CI:修复 CI 问题

* CI:修复 CI 问题
2025-10-20 14:29:05 +08:00
kl
b1af0c7d72 优化:日志输出重构 (#689) 2025-10-13 11:14:54 +08:00
kl
421640221b Kl (#688)
* 升级: JDK1.8 升级到 JDK21 ,spring-boot 版本从 2.4.2 升级到 3.5.6

* 优化:启动日志新增 java version 输出信息
2025-10-11 20:14:39 +08:00
kl
f6c6e22b0d 升级: JDK1.8 升级到 JDK21 ,spring-boot 版本从 2.4.2 升级到 3.5.6 (#687) 2025-10-11 20:05:43 +08:00
kl
51653483b9 Kl json (#686)
* 新增:JSON 文件格式化预览功能

* 优化:优化 JSON 文件格式化预览效果
2025-10-11 17:54:17 +08:00
kl
a9787b0add 新增:JSON 文件格式化预览功能 (#685) 2025-10-11 11:52:49 +08:00
kl
6cdbf92fb0 优化:完善文件上传禁用功能的用户体验 (#684) 2025-10-11 10:41:34 +08:00
kl
fdb40680d3 安全:禁用文件上传接口 (#656)
- 从配置文件中移除file.upload.disable配置项
- 删除FileController中的文件上传相关代码
- 移除/fileUpload POST接口
- 删除文件上传校验逻辑
- 增强系统安全性,防止恶意文件上传

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-30 17:57:45 +08:00
陈精华
6746325bf2 update Github workflow 2025-04-14 16:10:29 +08:00
陈精华
05a8bff1e0 优化:调整单元测试 2025-03-31 15:56:50 +08:00
陈精华
874ff5b3f6 优化:解决部分场景下, 页面元素变化导致水印覆盖不全问题 2025-03-31 15:28:36 +08:00
陈精华
2230cfa52b update README.cn.md 2025-01-22 11:08:28 +08:00
陈精华
83c581364d update README.cn.md 2025-01-22 11:04:40 +08:00
陈精华
1d39360c60 4.4.0版本发布 2025-01-16 10:44:41 +08:00
陈精华
8c763599fe !312 update server/src/main/resources/web/main/record.ftl.
Merge pull request !312 from 高雄/N/A
2025-01-15 03:28:17 +00:00
高雄
9632f6070c update server/src/main/resources/web/main/record.ftl.
更新日志文档

Signed-off-by: 高雄 <admin@cxcp.com>
2025-01-14 01:23:13 +00:00
陈精华
cc63659650 Merge pull request #593 from zp96324511/patch-1
容易引起歧义的环境变量命名
2024-09-30 16:05:29 +08:00
阿鹏
177f389814 容易引起歧义的环境变量命名 2024-09-14 12:09:24 +08:00
陈精华
406e9ea6ee Merge pull request #584 from gitchenjh/master
docker基础镜像调整为kkfileview-base
2024-08-27 10:36:59 +08:00
陈精华
bb461cd74a docker基础镜像调整为kkfileview-base 2024-08-26 10:29:27 +08:00
陈精华
782509376c Merge pull request #581 from wayne-cheng/optimize-dockerfile
优化Dockerfile,支持真正的跨平台构建镜像
2024-08-22 14:41:17 +08:00
郑威
63dc58d088 :construction_worker:优化Dockerfile,支持真正的跨平台构建镜像 2024-08-21 11:12:38 +08:00
陈精华
77f5adb19f !299 修复压缩获取路径错误,图片合集路径错误,水印问题等BUG
Merge pull request !299 from 高雄/yashuoba
2024-07-02 02:20:08 +00:00
陈精华
7abfb67451 !289 修复前端解析xlsx 包含emf格式文件错误
Merge pull request !289 from 高雄/lockkkk
2024-06-25 02:05:43 +00:00
gaoxiongzaq
c8dc638c29 修复压缩获取路径错误,图片合集路径错误,水印问题等BUG 2024-05-27 14:30:31 +08:00
gaoxiongzaq
48ac926289 修复压缩获取路径错误,图片合集路径错误,水印问题等BUG 2024-05-27 14:21:11 +08:00
陈精华
0a4ae41b0c !296 新增PDF线程管理,超时管理,内存缓存管理,更新PDF解析组件版本
Merge pull request !296 from 高雄/pdfddd
2024-05-27 03:32:27 +00:00
gaoxiongzaq
bb0139bee6 新增PDF线程管理,超时管理,内存缓存管理,更新PDF解析组件版本 2024-05-20 10:12:11 +08:00
陈精华
7bf07cb64c !286 修复远程文件,文件名带有穿越的BUG
Merge pull request !286 from 高雄/chuanyue
2024-04-17 02:40:52 +00:00
陈精华
ab370e66a5 Merge pull request #554 from kekingcn/kl
重构解压缩逻辑,fix  #553
2024-04-17 10:32:19 +08:00
kl
421a2760d5 重构解压缩逻辑,fix #553 2024-04-16 20:04:50 +08:00
陈精华
42f0e079f0 4.4.0-beta版本 2024-04-15 09:19:13 +08:00
gaoxiongzaq
9150346926 修复前端解析xlsx 包含emf格式文件错误 2024-03-28 11:26:25 +08:00
gaoxiongzaq
b65a04857c 修复远程文件文件名带有穿越漏洞的BUG 2024-03-27 08:55:28 +08:00
陈精华
59315c3200 maven-assembly插件区分Linux和Windows的assembly-id, 解决maven构建warning 2024-03-26 16:56:11 +08:00
陈精华
08e5a15424 移除@Nullable注解,解决编译warning:未知的枚举常量 javax.annotation.meta.When.MAYBE 2024-03-26 16:47:21 +08:00
陈精华
b8c283f602 !282 升级预览图片组件 修复ecs退出黑屏功能
Merge pull request !282 from 高雄/master
2024-03-26 08:29:41 +00:00
gaoxiongzaq
11f7ee34de 升级预览图片组件 修复ecs退出黑屏功能 2024-03-25 13:49:53 +08:00
陈精华
5be0d60caf !281 修复前端解析csv 某些文件解码错误问题
Merge pull request !281 from 高雄/N/A
2024-03-25 02:27:08 +00:00
高雄
6504ae2f45 !280 优化CAD转换
* 调整输出日志信息
* 统一错误提示规范
* 修复 转义后 流接入方法错误的问题
* 修复 转义后 流接入方法错误的问题
* CAD报错调整
* 优化CAD转换 调整CAD中断进程
2024-03-25 02:26:50 +00:00
高雄
c3155204eb 修复前端解析csv 某些文件解码错误问题
修复前端解析csv 某些文件解码错误问题

Signed-off-by: 高雄 <admin@cxcp.com>
2024-03-21 06:43:58 +00:00
陈精华
ebd35803c6 !279 更新记录文档
Merge pull request !279 from 高雄/N/A
2024-03-20 02:24:59 +00:00
陈精华
55bda80d33 !277 修复 压缩包特殊符文无法访问问题 调整统一url输出为url编码解决特殊符号问题 调整跨域方法和下载方法为一样 支持重定向
Merge pull request !277 from 高雄/master
2024-03-20 02:24:47 +00:00
gaoxiongzaq
3886e62e8e 恢复支持 普通浏览器方法 2024-03-18 13:40:56 +08:00
gaoxiongzaq
07edf77ba8 优化压缩包判断字符串方法 2024-03-15 11:49:14 +08:00
gaoxiongzaq
ddefeb630a 恢复原来格式 2024-03-15 11:17:26 +08:00
高雄
f050701d64 更新记录文档
更新记录文档

Signed-off-by: 高雄 <admin@cxcp.com>
2024-03-14 04:02:00 +00:00
gaoxiongzaq
5a50327f8f 调整pom 2024-03-14 08:29:38 +08:00
gaoxiongzaq
b4cd038c86 修复 压缩包特殊符文无法访问问题 调整统一url输出为url编码解决特殊符号问题 调整跨域方法和下载方法为一样 支持重定向 2024-03-14 08:16:24 +08:00
kailing
9b22f9a412 !259 更新版本升级记录
Merge pull request !259 from 高雄/N/A
2024-03-13 11:37:06 +00:00
kailing
99aeeb5faa !276 升级CAD转换组件、优化CAD转换方法
Merge pull request !276 from 高雄/master
2024-03-13 11:36:23 +00:00
gaoxiongzaq
29b09965a3 升级CAD转换组件、优化CAD转换方法 2024-03-12 08:51:31 +08:00
kailing
312c31a426 !275 修复 url特殊符号无法下载或者输出问题 修复流接入方法 拼接字符导导致下载 或者跨域错误问题
Merge pull request !275 from 高雄/master
2024-03-11 03:21:13 +00:00
gaoxiongzaq
c54610caf6 修复 url特殊符号无法下载或者输出问题 修复流接入方法 拼接字符导导致下载或者跨域错误问题 2024-03-09 10:35:13 +08:00
陈精华
72014e1534 Merge pull request #538 from kekingcn/kl
feat: 新增预览文件 host 黑名单机制
2024-03-08 12:28:27 +08:00
kl
d407b88b67 feat: 新增预览文件 host 黑名单机制 2024-03-08 10:12:05 +08:00
kl
d1d8ffef7a feat: 新增预览文件 host 黑名单机制 2024-03-06 19:49:59 +08:00
kailing
787e9fe615 !271 调整压缩包 获取路径方法
Merge pull request !271 from 高雄/master
2024-03-06 07:39:41 +00:00
高雄
e79c53156b 调整压缩包 获取路径方法
调整压缩包 获取路径方法

Signed-off-by: 高雄 <admin@cxcp.com>
2024-03-06 07:35:37 +00:00
高雄
7dcd225cea 调整压缩包 获取路径方法
调整压缩包 获取路径方法

Signed-off-by: 高雄 <admin@cxcp.com>
2024-03-06 07:34:56 +00:00
kailing
3482ee51da !267 update server/src/main/bin/startup.sh.
Merge pull request !267 from stevenwmq/N/A
2024-02-21 03:12:01 +00:00
kailing
211df6965f !263 新增office转换 超时属性功能
Merge pull request !263 from 高雄/master
2024-02-21 03:10:58 +00:00
Moomel
448a700687 !253 修复:非法请求使过滤器失效,出现严重安全问题
* BaseUrlFilter 修改过滤全部路径,保证 BaseUrlFilter 优于UrlCheckFilter 执行
* 清除无用 html
* 非法请求过滤器: 修复请求 path 中包含 // 或者以 / 结尾导致其它过滤器失效,对请求进行重定向
* 非法请求过滤器: 替换 getRequestURI() 为 getServletPath()
* 非法请求过滤器: 截取 context-path
* 非法请求过滤器: 去除 context-path
* 非法请求过滤器: 排除首页path "/"
* 非法请求过滤器: 请求地址中包含"//"或者以"/"结尾时导致其他过滤器失效,比如 TrustHostFilter
2024-02-21 02:56:54 +00:00
stevenwmq
7d17dae1fd update server/src/main/bin/startup.sh.
获取pid时过滤grep进程本身并且筛选java程序(避免showlog影响,showlog也有kkFilePreview关键字),避免取到的pid不是真实的程序pid导致shutdown失败。


Signed-off-by: stevenwmq <stevenwmq@163.com>
2024-01-30 08:31:29 +00:00
高雄
20a5c1b494 新增office转换 超时属性功能
新增office转换 超时属性功能

Signed-off-by: 高雄 <admin@cxcp.com>
2024-01-02 03:09:03 +00:00
高雄
4852b1479b 新增office转换 超时属性功能
新增office转换 超时属性功能

Signed-off-by: 高雄 <admin@cxcp.com>
2024-01-02 03:05:53 +00:00
kailing
bef81a940e !262 修复压缩包中,中文文件被编码问题
Merge pull request !262 from 高雄/N/A
2023-12-26 09:07:24 +00:00
kailing
8441d18a7f !261 调整drawio 预览模式 ,修复预览模式切换编辑模式bug
Merge pull request !261 from 高雄/master
2023-12-26 09:06:43 +00:00
高雄
09f4400552 修复压缩包中,中文文件被编码问题
修复压缩包中,中文文件被编码问题

Signed-off-by: 高雄 <admin@cxcp.com>
2023-12-26 02:06:18 +00:00
高雄
4f422f5ef0 修复 drawio 预览模式 跳转到编辑模式 出现的bug
修复 drawio 预览模式 跳转到编辑模式 出现的bug

Signed-off-by: 高雄 <admin@cxcp.com>
2023-12-26 02:01:39 +00:00
高雄
fdd3bbd5c1 删除文件 server/src/main/resources/static/drawio/js/app.min.js 2023-12-26 02:00:00 +00:00
高雄
bb3c8a1188 修改drawio默认为预览模式
修改drawio默认为预览模式

Signed-off-by: 高雄 <admin@cxcp.com>
2023-12-26 01:59:19 +00:00
高雄
bad3db400b 更新版本升级记录
更新版本升级记录

Signed-off-by: 高雄 <admin@cxcp.com>
2023-12-21 03:25:32 +00:00
kl
8ac8cd8487 重构压缩文件判断逻辑 (#517)
* 重构压缩文件判断逻辑

* 重构压缩文件判断逻辑,移除无用的代码
2023-12-21 11:19:29 +08:00
kailing
a54cd75469 !258 修复特殊符号 转义错误
Merge pull request !258 from 高雄/N/A
2023-12-19 08:13:53 +00:00
kailing
26d8c7ab62 !257 修复二级压缩包 反代情况下获取路径错误
Merge pull request !257 from 高雄/master
2023-12-19 07:58:40 +00:00
gaoxiongzaq
6b802b6545 压缩包方法 标注路径详细说明 2023-12-19 15:55:21 +08:00
高雄
8d56923efc 修复特殊符号 转义错误
修复特殊符号 转义错误

Signed-off-by: 高雄 <admin@cxcp.com>
2023-12-19 06:38:27 +00:00
gaoxiongzaq
79b9d703dc 修复二级压缩包 反代情况下获取路径错误 2023-12-19 14:37:08 +08:00
kailing
a5d29a4e3c !250 修复CSV文件预览只显示100条的问题
Merge pull request !250 from 高雄/N/A
2023-12-19 02:12:32 +00:00
kailing
7a9b3f0b8f !255 统一命名规范,符合驼峰规则
Merge pull request !255 from 高雄/master
2023-12-19 02:03:00 +00:00
gaoxiongzaq
9de1ae8c11 统一命名规范,符合驼峰规则 2023-12-19 10:00:29 +08:00
gaoxiongzaq
218f9f0015 统一命名规范,符合驼峰规则 2023-12-19 09:06:22 +08:00
gaoxiongzaq
0c6ea7248a 统一命名规范,符合驼峰规则 2023-12-19 08:55:51 +08:00
kailing
13dfca016e !248 1.修复压缩包 二级目录无法解压问题 修改压缩包生成PDF路径 2.修复PDF 带密码缓存问题 新增PDF带密码缓存方法 userToken 3.精简OFFICE 转换代码 4.精简TIF转换代码 新增TIF转换图片缓存 修复tif错误文件不自动释放内存 等待其他修复 5.修复下载方法错 特殊符号下载错误
Merge pull request !248 from 高雄/qttiaozheng
2023-12-18 12:43:26 +00:00
陈精华
904b9497a0 自动检测已安装Office组件增加LibreOffice7.5 & 7.6 版本默认路径 2023-12-01 10:00:00 +08:00
kailing
69444a4d72 !243 解决定时清除缓存时,对于多媒体类型文件,只删除了磁盘缓存文件,导致再次预览时从缓存中获取到了一个不存在文件路径
Merge pull request !243 from zhh/master
2023-11-08 01:58:38 +00:00
kailing
7d67d0d857 !246 修复前端xlsx解析 打印问题 和其他问题
Merge pull request !246 from 高雄/xlsx
2023-11-06 03:56:14 +00:00
kailing
a95dda6c20 !249 tif解析更加智能化 支持被修改的图片格式
Merge pull request !249 from 高雄/N/A
2023-11-06 03:55:59 +00:00
高雄
148046f105 修复CSV文件预览只显示100条的问题
修复CSV文件预览只显示100条的问题

Signed-off-by: 高雄 <admin@cxcp.com>
2023-11-02 01:42:32 +00:00
高雄
6d01caee50 修复excel多sheet页预览时只能查看第一个sheet页 的问题
修复excel多sheet页预览时只能查看第一个sheet页 的问题

Signed-off-by: 高雄 <admin@cxcp.com>
2023-10-27 01:55:46 +00:00
gaoxiongzaq
9f9790d4fd 修复特殊符号 转义的问题 2023-10-25 11:35:08 +08:00
gaoxiongzaq
fdb5325e02 修复压缩包中的 cad创建带文件名的文件夹 2023-10-25 10:12:08 +08:00
gaoxiongzaq
be4080c80d 修复 视频格式 转换模式和预览模式 特征码通用的问题 修复压缩包创建带文件名的文件夹 2023-10-25 10:05:51 +08:00
gaoxiongzaq
a057808624 修复 压缩包 office 文件转换成jpg格式 路径获取错误问题 2023-10-24 17:56:44 +08:00
高雄
355a69b4fc tif解析更加智能化 支持被修改的图片格式
tif解析支持 伪格式的(比如jpg 修改后缀)

Signed-off-by: 高雄 <admin@cxcp.com>
2023-10-24 08:53:59 +00:00
gaoxiongzaq
7597864337 修复 下载方法 包含空格 和+转换错误的问题 调整下载方法输出报错方式 2023-10-24 16:51:26 +08:00
gaoxiongzaq
724db1936b 修复 cad 格式二级以上压缩包 不自动创建目录问题 2023-10-24 11:37:03 +08:00
gaoxiongzaq
75061d843a 修复 视频格式获取错误 不输出问题 2023-10-24 11:27:23 +08:00
gaoxiongzaq
502b21147d 修复 视频转换方式 在压缩包里面 不自动创建文件路径而导致的报错 2023-10-24 09:42:47 +08:00
gaoxiongzaq
deb91728d4 1.修复压缩包 二级目录无法解压问题 修改压缩包生成PDF路径
2.修复PDF 带密码缓存问题 新增PDF带密码缓存方法 userToken
3.精简OFFICE 转换代码
4.精简TIF转换代码 新增TIF转换图片缓存 修复tif错误文件不自动释放内存 等待其他修复
5.修复下载方法错 特殊符号下载错误
6.调整文件名 统一方法在FileHandlerService
7.新增判断文件名是否被URL转义
2023-10-23 17:06:05 +08:00
陈精华
790c29c205 !244 更新CAD转换组件版本
Merge pull request !244 from 高雄/cad23.7
2023-10-20 10:06:44 +00:00
gaoxiongzaq
b1bfd81a97 修复前端xlsx解析 打印问题 和其他问题 2023-10-20 15:43:45 +08:00
gaoxiongzaq
a056c9c6c9 更新CAD转换组件版本 2023-10-20 14:39:57 +08:00
陈精华
c559efcceb Merge pull request #498 from baboon-king/master
fix: duplicate query param of tifPreviewType on url
2023-10-20 11:34:52 +08:00
陈精华
8d5c987fe7 更新xlsx预览样式 2023-10-19 11:29:33 +08:00
BaboonKing
fa034d54b6 fix: duplicate query param of tifPreviewType on url 2023-10-18 13:46:50 +08:00
陈精华
e39e8bd907 更新xlsx预览样式 2023-10-17 18:15:20 +08:00
kailing
693b13e818 !241 修复video跨域配置导致视频无法预览问题
Merge pull request !241 from lujiaming/master
2023-10-13 06:34:40 +00:00
zhanghh
6cd22e0975 fix: 清除多媒体类型文件的缓存 2023-10-13 11:03:44 +08:00
lujiaming
22c881bbaa [fix] 修复video跨域配置导致视频无法预览问题 2023-10-07 20:36:05 +08:00
gitchenjh
3cfc51a4d7 Merge pull request 'fix: 增大小文本文件检测字符编码的正确率;处理并发隐患' (#3) from asiawu/kkFileView:master into master 2023-10-07 13:37:47 +08:00
“yaya”
3e08deb50e fix: 将解决并发问题的方式由锁改为局部变量 2023-10-07 12:48:02 +08:00
“yaya”
42cf6b2955 fix: 增大小文本文件检测字符编码的正确率;处理并发隐患 2023-10-06 16:22:32 +08:00
陈精华
02c64977cb index page delete file captcha dialog align center 2023-09-27 09:44:21 +08:00
kailing
32b0a46574 !239 update main pages
Merge pull request !239 from 陈精华/main-pages
2023-09-25 11:11:30 +00:00
陈精华
94a76a72a4 update index page 2023-09-25 14:32:54 +08:00
陈精华
bcb278dd0b update main pages 2023-09-25 10:38:19 +08:00
kl
8eab415430 sponsor update (#492) 2023-09-21 11:50:14 +08:00
陈精华
aa3108fe98 !236 修复图片预览不居中问题修复
Merge pull request !236 from lujiaming/master
2023-09-21 03:04:44 +00:00
kailing
56965b4ff4 !235 一个通用的文件服务器认证访问的设计,解决 https://www.gitlink.org.cn/kk-open/kkFileView/issues/3 的问题
Merge pull request !235 from YiwenXia/http
2023-09-20 15:03:36 +00:00
陈精华
6eaf04aa71 Merge remote-tracking branch 'origin/master' into origin-master 2023-09-20 22:19:27 +08:00
YiwenXia
5fe0dd3d29 调整 kk-proxy-authorization 参数从 header 头里获取,增强认证参数获取的安全性 2023-09-20 21:23:31 +08:00
kl
091c955363 微宏科技捐助 (#491) 2023-09-20 19:57:32 +08:00
lujiaming
f09d0d8279 [fix] 修复图片预览不居中问题 2023-09-20 14:23:43 +08:00
YiwenXia
713edcfb8d 一个通用的文件服务器认证访问的设计,解决 https://www.gitlink.org.cn/kk-open/kkFileView/issues/3 的问题 2023-09-19 23:32:45 +08:00
kailing
7e0f7f6608 !231 修复txt文本类 分页二次加载问题
Merge pull request !231 from 高雄/N/A
2023-09-18 10:28:52 +00:00
高雄
e4c29bf57f 修复txt文本类 分页二次加载问题
修复txt文本类 分页二次加载问题

Signed-off-by: 高雄 <admin@cxcp.com>
2023-09-11 07:03:18 +00:00
kailing
b2d0d50507 !226 更新tif解析文件 更加自能错误提醒
Merge pull request !226 from 高雄/tiff
2023-09-08 05:48:33 +00:00
高雄
8c480208df 更新tif解析文件 更加自能错误提醒
更新tif解析文件 更加自能错误提醒 

Signed-off-by: 高雄 <admin@cxcp.com>
2023-09-07 10:32:14 +00:00
高雄
b010e13de2 更新tif解析文件 更加自能错误提醒
更新tif解析文件 更加自能错误提醒 

Signed-off-by: 高雄 <admin@cxcp.com>
2023-09-07 08:26:48 +00:00
kailing
c2bfba865a !225 csv格式前端解析
Merge pull request !225 from 高雄/csv
2023-09-07 02:37:22 +00:00
高雄
b02debfc59 修改csv命名规范
修改csv命名规范 

Signed-off-by: 高雄 <admin@cxcp.com>
2023-09-07 02:34:13 +00:00
高雄
978aa0dd68 修改csv命名规范
修改csv命名规范

Signed-off-by: 高雄 <admin@cxcp.com>
2023-09-07 02:31:23 +00:00
高雄
14ecf66c70 重命名 server/src/main/resources/web/officecsv.ftl 为 server/src/main/resources/web/csv.ftl 2023-09-07 02:29:36 +00:00
高雄
0563fde951 修改csv命名规范
修改csv命名规范

Signed-off-by: 高雄 <admin@cxcp.com>
2023-09-07 02:29:05 +00:00
gaoxiongzaq
8f37e85aa6 更新tif解析文件 更加自能错误提醒 2023-09-06 13:53:42 +08:00
gaoxiongzaq
0c4e5bc420 csv格式前端解析 2023-09-06 09:34:38 +08:00
kailing
8b6e7dcbdc !222 更换视频播放插件为ckplayer,新增mpd,m3u8,ts,mpeg,m4a格式支持
Merge pull request !222 from 高雄/vode
2023-09-04 09:49:27 +00:00
高雄
48fe534e77 修复误加3gp格式
修复误加3gp格式

Signed-off-by: 高雄 <admin@cxcp.com>
2023-09-04 09:23:15 +00:00
gaoxiongzaq
6da291e6e3 更换视频播放插件为ckplayer,新增mpd,m3u8,ts,mpeg,3gp,m4a格式支持 2023-09-02 13:43:24 +08:00
陈精华
d49b444462 update github workflow script 2023-09-01 16:09:38 +08:00
kl
692bb8f964 重构下载文件的代码,修复文件重新下载的问题 (#485)
* 重构下载文件的代码,修复文件重新下载的问题

* fix: 修复可能得空指针问题
2023-08-31 10:47:41 +08:00
陈精华
c2abe2f34c update Dockerfile_arm64 2023-08-29 16:20:31 +08:00
陈精华
133973c987 Merge pull request #484 from asiaWu3/master
feat: 新增arm64下的dockerfile
2023-08-24 09:15:58 +08:00
陈精华
8a35eb5d3e !220 更新bootstrap组件 并精简掉不需要的文件
Merge pull request !220 from 高雄/bootstrap
2023-08-23 08:54:48 +00:00
陈精华
b1fbeb52a5 !219 首页新增 搜索 定位页码 定义显示多少内容
Merge pull request !219 from 高雄/heom
2023-08-23 08:54:10 +00:00
gaoxiongzaq
674cbb9bf5 更新bootstrap组件 并精简掉不需要的文件 2023-08-22 10:22:18 +08:00
gaoxiongzaq
6f53b41baf 首页新增 搜索 定位页码 定义显示多少内容 2023-08-22 10:16:02 +08:00
kailing
381e1d6b43 !218 配置文件分类调整,按照模块分类调整 以后更加直观找到需要的功能
Merge pull request !218 from 高雄/peizhi
2023-08-22 02:01:48 +00:00
gaoxiongzaq
779c7c77b7 配置文件分类调整,按照模块分类调整 以后更加直观找到需要的功能 2023-08-22 09:02:26 +08:00
kailing
096426b8e2 !217 [fixed] getRelFilePath 返回null 导致KkFileUtils.isAllowedUpload的空指针异常修复
Merge pull request !217 from lujiaming/master
2023-08-21 15:39:30 +00:00
lujiaming
d8146f0495 [fixed] getRelFilePath 返回null 导致KkFileUtils.isAllowedUpload的空指针异常 2023-08-21 14:44:20 +08:00
“yaya”
be4f3d06e8 feat: 新增arm64下的dockerfile 2023-08-19 20:07:36 +08:00
lujiaming
da784aea84 [fixed] getRelFilePath 返回null 导致KkFileUtils.isAllowedUpload的空指针异常 2023-08-17 13:56:59 +08:00
kailing
bb3b5b3dff !210 [hotfix] 修复容器中仍有几率因生命周期,getCadThread = 0导致线程池创建失败问题
Merge pull request !210 from lujiaming/master
2023-08-16 02:09:50 +00:00
kailing
ad3e38285f !214 更新PDF.JS解析组件 新增:控制签名/绘图/插图控制方法
Merge pull request !214 from 高雄/pdf22
2023-08-16 02:08:43 +00:00
gaoxiongzaq
60dfefd37c 更新PDF.JS解析组件 新增:控制签名/绘图/插图控制方法 2023-08-16 09:38:47 +08:00
gaoxiongzaq
8268fc796e 更新PDF.JS解析组件 新增:控制签名/绘图/插图控制方法 2023-08-16 09:04:12 +08:00
gaoxiongzaq
98f83d9be1 升级 DCM解析组件 2023-08-16 08:49:27 +08:00
gaoxiongzaq
c39a205cea ofd 增加支持jp2、tiff图片渲染处理;优化双层OFD文本渲染效果;优化文本复制功能;提升OFD解析兼容性. 2023-08-16 08:44:44 +08:00
lujiaming
1671fc3572 [hotfix] 修复容器中仍有几率因生命周期,getCadThread = 0导致线程池创建失败问题 2023-08-14 20:19:28 +08:00
kailing
e550df3e8b !207 更新epub版本,优化epub显示效果
Merge pull request !207 from 高雄/N/A
2023-08-14 11:27:29 +00:00
kailing
930cd2b09b !208 更新epub版本,优化epub显示效果
Merge pull request !208 from 高雄/N/A
2023-08-14 11:26:30 +00:00
kailing
36672da026 !209 优化OFD 移动端预览 页面不自适应
Merge pull request !209 from 高雄/N/A
2023-08-14 11:26:12 +00:00
kl
5f1e5c8f4b 重构验证码生成方法 (#481) 2023-08-14 13:20:33 +08:00
陈精华
b71442543d !206 [hotfix] 修复因生命周期,getCadThread = 0导致线程池创建失败问题
Merge pull request !206 from lujiaming/master
2023-08-14 03:49:49 +00:00
高雄
146920496e 优化OFD 移动端预览 页面不自适应
优化OFD 移动端预览 页面不自适应

Signed-off-by: 高雄 <admin@cxcp.com>
2023-08-14 03:40:03 +00:00
高雄
cfa5771b8e 更新epub版本,优化epub显示效果
更新epub版本,优化epub显示效果 

Signed-off-by: 高雄 <admin@cxcp.com>
2023-08-14 03:35:39 +00:00
高雄
25e77448d1 更新epub版本,优化epub显示效果
更新epub版本,优化epub显示效果

Signed-off-by: 高雄 <admin@cxcp.com>
2023-08-14 03:34:44 +00:00
lujiaming
4a0409953a [hotfix] 修复因生命周期,getCadThread = 0导致线程池创建失败问题 2023-08-11 19:19:55 +08:00
kailing
fa2a5d3e35 !205 修复bpmn不支持跨域的问题
Merge pull request !205 from 高雄/N/A
2023-08-11 09:09:07 +00:00
kailing
7c1c8a43e8 !204 修复drawio缺少base64组件的问题
Merge pull request !204 from 高雄/N/A
2023-08-11 09:08:50 +00:00
kl
0a8be8ac95 重构验证码删除文件的实现逻辑 (#479)
* 重构验证码删除文件的实现逻辑

* 移除未使用的依赖

* 微调描述信息
2023-08-11 16:39:07 +08:00
高雄
0732344e79 修复bpmn不支持跨域的问题
修复bpmn不支持跨域的问题

Signed-off-by: 高雄 <admin@cxcp.com>
2023-08-11 06:15:56 +00:00
高雄
c8a7371e07 修复drawio缺少base64组件的问题
修复drawio缺少base64组件的问题

Signed-off-by: 高雄 <admin@cxcp.com>
2023-08-11 06:15:15 +00:00
kailing
aa49cc6ac0 !195 升级相关组件
Merge pull request !195 from 高雄/N/A
2023-08-10 03:07:54 +00:00
kailing
cc01769f8f !202 删除不必要的判断
Merge pull request !202 from qinfen180/dev-test
2023-08-10 03:07:12 +00:00
chezhuang
8a613513aa refactor: Remove unnecessary 'password==null" condition 2023-08-09 21:53:40 +08:00
陈精华
c249f68972 !201 修复epub 跨域报错问题
Merge pull request !201 from 高雄/N/A
2023-08-06 14:14:47 +00:00
陈精华
5ecfb39a9e !199 升级markdown组件 修复markdown被转义问题
Merge pull request !199 from 高雄/N/A
2023-08-06 14:14:16 +00:00
陈精华
f8039102bf !198 更新markdown组件
Merge pull request !198 from 高雄/N/A
2023-08-06 14:13:29 +00:00
陈精华
88fc5910e9 !197 更新 更新记录文档
Merge pull request !197 from 高雄/N/A
2023-08-06 14:13:17 +00:00
陈精华
41e8042bc7 !196 修改说明文档
Merge pull request !196 from 高雄/N/A
2023-08-06 14:12:39 +00:00
高雄
a45a592a39 修复epub 跨域报错问题
修复epub 跨域报错问题

Signed-off-by: 高雄 <admin@cxcp.com>
2023-08-03 07:16:00 +00:00
高雄
53cc923f1e 更新markdown组件 添加转义方法
更新markdown组件 添加转义方法

Signed-off-by: 高雄 <admin@cxcp.com>
2023-08-01 07:16:46 +00:00
高雄
e653eeb5c6 更新markdown组件
更新markdown组件

Signed-off-by: 高雄 <admin@cxcp.com>
2023-08-01 07:15:08 +00:00
高雄
6e7559577c 更新 更新记录文档
更新 更新记录文档

Signed-off-by: 高雄 <admin@cxcp.com>
2023-07-31 09:10:19 +00:00
高雄
7455f8279e 修改说明文档
修改说明文档

Signed-off-by: 高雄 <admin@cxcp.com>
2023-07-31 09:08:08 +00:00
高雄
149e7de7fc 升级相关组件
升级相关组件

Signed-off-by: 高雄 <admin@cxcp.com>
2023-07-31 08:18:39 +00:00
kailing
824dbb4e45 !194 【轻量级 PR】:修复 由于疏忽导致的多余的 }符号
Merge pull request !194 from 高雄/N/A
2023-07-28 23:47:35 +00:00
高雄
8fef5c595d 修复 由于疏忽导致的多余的 }符号
修复 由于疏忽导致的多余的 }符号

Signed-off-by: 高雄 <admin@cxcp.com>
2023-07-28 14:32:49 +00:00
陈精华
017a7dccb8 !193 跨域方法 支持重定向
Merge pull request !193 from 高雄/N/A
2023-07-28 09:02:03 +00:00
陈精华
079fe5e7b0 !190 下载方法 支持重定向
Merge pull request !190 from 高雄/N/A
2023-07-28 09:01:51 +00:00
陈精华
1e03307657 !188 优化后台 接入BASE64报错信息
Merge pull request !188 from 高雄/N/A
2023-07-28 09:01:06 +00:00
高雄
ccaba78e8d 跨域方法 支持重定向
跨域方法 支持重定向

Signed-off-by: 高雄 <admin@cxcp.com>
2023-07-28 06:42:13 +00:00
高雄
75fe682433 下载方法 支持重定向
下载方法 支持重定向 

Signed-off-by: 高雄 <admin@cxcp.com>
2023-07-28 06:36:23 +00:00
高雄
fb6320a244 update server/src/main/java/cn/keking/utils/WebUtils.java.
优化后台 接入BASE64报错信息

Signed-off-by: 高雄 <admin@cxcp.com>
2023-07-28 00:56:14 +00:00
陈精华
3da330341f !187 优化 pdf转换图片 报错信息
Merge pull request !187 from 高雄/pdf3
2023-07-26 05:46:40 +00:00
asiawu
31c7b2dfb8 重构了EncodingDetectors#getJavaEncode(String filePath)方法,并附带部分测试数据
重构了EncodingDetectors#getJavaEncode(String filePath)方法,并附带部分测试数据
Co-authored-by: asiawu <asiawu3@qq.com>
Co-committed-by: asiawu <asiawu3@qq.com>
2023-07-24 17:15:07 +08:00
陈精华
d2a8ca2cdd !186 新增xbrl格式
Merge pull request !186 from 高雄/xbrl
2023-07-24 03:30:59 +00:00
陈精华
16fca7ec61 !185 修复PDF解密加密文件 转换成功后台报错问题
Merge pull request !185 from 高雄/pdf2
2023-07-24 03:30:26 +00:00
陈精华
39d8d38ee9 !184 修复office转换加密文档 PDF不生成密码问题
Merge pull request !184 from 高雄/pdf
2023-07-24 03:30:09 +00:00
陈精华
99982f07f7 !183 调整 验证码 样式 为弹窗显示
Merge pull request !183 from 高雄/N/A
2023-07-24 03:29:33 +00:00
gaoxiongzaq
1246a853b5 优化 pdf转换图片 报错信息 2023-07-24 10:18:09 +08:00
gaoxiongzaq
6382453327 新增xbrl格式 2023-07-24 09:47:04 +08:00
gaoxiongzaq
4ebee74f70 修复PDF解密加密文件 转换成功后台报错问题 2023-07-24 09:41:00 +08:00
gaoxiongzaq
54750f4e06 修复转换加密文档 PDF不生成密码问题 2023-07-24 09:39:20 +08:00
高雄
1225362c90 调整 验证码 样式 为弹窗显示
调整 验证码 样式 为弹窗显示

Signed-off-by: 高雄 <admin@cxcp.com>
2023-07-24 01:10:29 +00:00
陈精华
fe5ad49008 !175 验证码方法 代码优化
Merge pull request !175 from 高雄/code1
2023-07-22 06:35:37 +00:00
陈精华
586561ec5a fix some typo 2023-07-22 14:33:02 +08:00
陈精华
cad2d58f44 CAD默认预览模式调整为svg 2023-07-22 14:31:22 +08:00
陈精华
4f86a56f59 !180 优化 CAD转换功能 新增CAD线程控制和CAD超时限制
Merge pull request !180 from 陈精华/cad
2023-07-22 06:26:13 +00:00
gaoxiongzaq
c86ca0d8cf 优化 CAD转换功能 新增CAD线程控制和CAD超时限制 2023-07-22 14:22:31 +08:00
陈精华
ec633cc0e1 !179 验证码方法 代码优化
Merge pull request !179 from 陈精华/captcha
2023-07-22 06:14:33 +00:00
陈精华
fa2a2b4342 !178 office 功能调整 支持批注 转换页码限制 生成水印等等
Merge pull request !178 from 陈精华/office1
2023-07-22 06:14:24 +00:00
gaoxiongzaq
2b456c9934 验证码方法 代码优化
(cherry picked from commit da5dac73ab)
2023-07-22 14:01:56 +08:00
陈精华
7965d52f29 office 功能调整 支持批注 转换页码限制 生成水印等等 2023-07-22 13:42:29 +08:00
陈精华
ad322c2e10 !173 升级 CAD转换组件
Merge pull request !173 from 高雄/cad1
2023-07-22 04:27:36 +00:00
gaoxiongzaq
da5dac73ab 验证码方法 代码优化 2023-07-22 08:53:50 +08:00
gaoxiongzaq
b5e711bf87 office 功能调整 支持批注 转换页码限制 生成水印等等 2023-07-22 08:51:23 +08:00
gaoxiongzaq
535d2baf0b 升级 CAD转换组件 2023-07-22 08:45:21 +08:00
高雄
294dcb1994 !170 删除功能 新增验证码方法
删除功能 新增验证码方法
2023-07-21 09:52:27 +00:00
陈精华
c54a5e9f1a !166 CAD格式新增支持 转换成svg tif 格式 CAD 转换新增 超时结束方法
Merge pull request !166 from 高雄/cad
2023-07-21 09:50:49 +00:00
陈精华
3571f2b502 !165 启用 GZIP压缩
Merge pull request !165 from 高雄/gzip
2023-07-21 09:50:05 +00:00
gaoxiongzaq
6f8416365f CAD格式新增支持 转换成svg tif 格式
CAD 转换新增 超时结束方法
2023-07-20 10:54:47 +08:00
gaoxiongzaq
778a381b5b 启用 GZIP压缩 2023-07-20 09:12:30 +08:00
gaoxiongzaq
770769ead5 启用 GZIP压缩 2023-07-20 09:06:50 +08:00
陈精华
8d49abb797 !163 更新说明文档
Merge pull request !163 from 高雄/master
2023-07-14 07:48:21 +00:00
高雄
d0568c53dc 更新说明文档
Merge pull request !1 from 陈精华/N/A
2023-07-13 06:30:06 +00:00
陈精华
276ef9d704 update README.cn.md.
Signed-off-by: 陈精华 <842761733@qq.com>
2023-07-12 07:16:58 +00:00
高雄
dd75f718aa 更新说明文档
更新说明文档

Signed-off-by: 高雄 <admin@cxcp.com>
2023-07-10 09:26:15 +00:00
陈精华
0ece6ccb51 !161 修复 forceUpdatedCache 属性设置,但是本地缓存文件不更新缺陷
Merge pull request !161 from lujiaming/N/A
2023-07-10 07:51:51 +00:00
lujiaming
bbd7530f77 修复 forceUpdatedCache 属性设置,但是本地缓存文件不更新缺陷
Signed-off-by: lujiaming <1451771613@qq.com>
2023-07-10 07:43:23 +00:00
陈精华
2cfd692171 update officeweb.ftl 2023-07-10 13:59:56 +08:00
陈精华
77f794831f !154 PdfFilePreviewImpl 中无效代码去除
Merge pull request !154 from lujiaming/N/A
2023-07-10 03:38:48 +00:00
陈精华
4ee8926d5f !155 更新xlsx前端解析组件
Merge pull request !155 from 高雄/master
2023-07-10 03:35:54 +00:00
陈精华
a850e405ed !156 ofd修复部分已知问题.
Merge pull request !156 from 高雄/ofd
2023-07-10 03:34:49 +00:00
陈精华
cac68f88df !157 v4.4.0版本迭代开启
Merge pull request !157 from 高雄/xlsx
2023-07-10 03:34:12 +00:00
gaoxiongzaq
3734a66549 更新xlsx前端解析组件 2023-07-10 11:25:17 +08:00
gaoxiongzaq
2331545369 ofd修复部分已知问题. 2023-07-10 11:19:54 +08:00
gaoxiongzaq
0ff1f2c22b v4.4.0-SNAPSHOT版本 迭代开启 2023-07-10 11:18:12 +08:00
lujiaming
61f1d6ac8b PdfFilePreviewImpl 中无效代码去除
Signed-off-by: lujiaming <1451771613@qq.com>
2023-07-05 16:18:11 +00:00
陈精华
ac6c0e93ca 4.3.0版本发布 2023-07-04 08:18:53 +08:00
陈精华
43299e80d6 update cnofd.umd.min.js 2023-07-03 21:21:11 +08:00
陈精华
a936113709 new config item support environment config 2023-07-03 14:34:40 +08:00
陈精华
bfe4f73b49 fix encodeUrlFileName method 2023-06-30 15:53:44 +08:00
陈精华
7f9f402a82 format pom.xml 2023-06-29 17:04:45 +08:00
陈精华
bc3a273edf !153 调整dcm格式预览效果 修复反代情况下缺少BASE64组件
Merge pull request !153 from 高雄/N/A
2023-06-29 08:56:14 +00:00
高雄
645ea86502 调整dcm格式预览效果 修复反代情况下缺少BASE64组件
调整dcm格式预览效果  修复反代情况下缺少BASE64组件

Signed-off-by: 高雄 <admin@cxcp.com>
2023-06-29 08:43:44 +00:00
陈精华
ed1d49782f fix issue https://t.zsxq.com/0fpHww4Gy 2023-06-29 11:12:20 +08:00
陈精华
2e9062d377 fix issue https://t.zsxq.com/0fpHww4Gy 2023-06-29 11:07:50 +08:00
陈精华
8bb0f3a066 update docker image kkfileview-jdk tag to latest 2023-06-28 14:46:12 +08:00
陈精华
c8feb20259 !149 update server/src/main/resources/web/main/index.ftl.
Merge pull request !149 from 高雄/N/A
2023-06-25 09:05:26 +00:00
陈精华
a5d98b00a0 !150 update server/src/main/resources/web/main/record.ftl.
Merge pull request !150 from 高雄/N/A
2023-06-25 09:05:07 +00:00
陈精华
b22ae3f98a !151 更新说明文档
Merge pull request !151 from 高雄/master
2023-06-25 07:07:18 +00:00
高雄
5d6cc4655f update server/src/main/resources/web/main/record.ftl.
更新说明文档

Signed-off-by: 高雄 <admin@cxcp.com>
2023-06-19 08:23:45 +00:00
高雄
0f2af7f54d update server/src/main/resources/web/main/index.ftl.
更新说明文档

Signed-off-by: 高雄 <admin@cxcp.com>
2023-06-19 08:22:54 +00:00
高雄
853ee48453 更新说明文档
更新说明文档

Signed-off-by: 高雄 <admin@cxcp.com>
2023-06-19 08:20:29 +00:00
高雄
14b77e4a0c 更新说明文档
更新说明文档

Signed-off-by: 高雄 <admin@cxcp.com>
2023-06-19 08:19:54 +00:00
陈精华
c145f4ca0e !145 优化跨域方法代码
Merge pull request !145 from 高雄/kuayu
2023-06-19 02:32:27 +00:00
陈精华
c0d9a8ebad update linux libreoffice source 2023-06-19 10:30:02 +08:00
陈精华
19227fcbab !147 压缩包预览报错
Merge pull request !147 from xiaoyinkuangxue/master
2023-06-19 01:59:38 +00:00
陈精华
f57e0bcf12 update linux libreoffice version to 7.5.3 2023-06-19 09:57:05 +08:00
陈精华
fbf70047eb update some codestyle 2023-06-19 09:42:28 +08:00
陈精华
ef8e04e767 update office and cad types 2023-06-19 09:34:46 +08:00
陈精华
ceaea6dcfc update some codestyle 2023-06-19 09:14:53 +08:00
陈精华
b93779e816 update office preview type switch ui 2023-06-18 09:59:24 +08:00
陈精华
7b19c70161 update freemarker_implicit.ftl 2023-06-18 09:58:29 +08:00
陈精华
35585580a4 update some default configuration 2023-06-18 09:50:31 +08:00
陈精华
298df02879 升级Windows内置office为 LibreOffice-7.5.3 Portable版本 2023-06-12 15:30:58 +08:00
陈精华
3b1ae77aab Merge pull request #463 from asiaWu3/master
perf: 优化FilePreviewFactory#get方法获取service bean的方式
2023-06-07 17:56:29 +08:00
刘长鸣
6e1148ffc9 预览压缩包时,如果点击的是文件目录(树节点),页面会报错。所以加上判断,只有叶子节点才去预览文件 2023-06-06 23:08:19 +08:00
“yaya”
75537be32e perf: 修改了FilePreviewFactory#get方法获取service bean的方式,由原来的先获取所有FilePreview类型的bean再根据bean name获取bean改为直接根据bean name获取单个bean 2023-06-06 18:55:21 +08:00
gaoxiongzaq
127f759f16 优化跨域方法代码 2023-06-03 14:36:06 +08:00
陈精华
3f47bb32a0 !144 美化TXT文本 分页框的显示
Merge pull request !144 from 高雄/txt
2023-06-03 05:37:15 +00:00
陈精华
7b59edcf28 !143 OFD修复部分文字未显示的问题,完善OFD兼容性处理.
Merge pull request !143 from 高雄/OFD
2023-06-03 05:36:59 +00:00
陈精华
a7d051cc47 !142 新增前端解析xlsx方法
Merge pull request !142 from 高雄/xlsx
2023-06-03 05:36:04 +00:00
gaoxiongzaq
eb3cef0222 美化TXT文本 分页框的显示 2023-06-03 10:53:10 +08:00
gaoxiongzaq
37fc736e4c OFD修复部分文字未显示的问题,完善OFD兼容性处理. 2023-06-02 17:45:26 +08:00
gaoxiongzaq
b9f438bc01 新增前端解析xlsx方法 2023-06-02 14:55:32 +08:00
陈精华
8135fce136 !140 修复部分已知Bug,提高OFD兼容性处理。
Merge pull request !140 from 高雄/master
2023-05-15 09:31:28 +00:00
高雄
1fd322eeb6 修复部分已知Bug,提高OFD兼容性处理。
修复部分已知Bug,提高OFD兼容性处理。

Signed-off-by: 高雄 <admin@cxcp.com>
2023-05-15 08:20:37 +00:00
高雄
f028eedfc1 删除文件 server/src/main/resources/static/ofd/js/cnofd.umd.min.js 2023-05-15 08:20:08 +00:00
陈精华
c222755acc fix FileHandlerService#pdf2jpg npe (github issue #455) 2023-05-12 23:14:11 +08:00
陈精华
5dbc8a4980 fix FileHandlerService#pdf2jpg npe (github issue #455) 2023-05-12 23:09:57 +08:00
kailing
ad46dd8b5b !139 优化CAD 释放资源方法
Merge pull request !139 from 高雄/master
2023-05-12 02:14:58 +00:00
kailing
15a0851743 !137 优化PDF加密文件缓存方法
Merge pull request !137 from 高雄/N/A
2023-05-12 02:14:40 +00:00
高雄
cc587adb7a 优化CAD 释放资源方法
优化CAD 释放资源方法

Signed-off-by: 高雄 <admin@cxcp.com>
2023-05-12 01:51:27 +00:00
高雄
1581fd277f 优化CAD 释放资源方法
优化CAD 释放资源方法

Signed-off-by: 高雄 <admin@cxcp.com>
2023-05-12 01:50:56 +00:00
高雄
900389160f 优化PDF加密文件缓存方法
优化PDF加密文件缓存方法

Signed-off-by: 高雄 <admin@cxcp.com>
2023-05-12 01:24:10 +00:00
陈精华
f74d93a835 fix some codestyle problem 2023-05-06 16:53:15 +08:00
陈精华
93fb40d282 fix some codestyle problem 2023-05-06 16:51:06 +08:00
陈精华
9e3d450854 !131 新增:pdf支持密码
Merge pull request !131 from 高雄/pdfPass
2023-05-06 03:47:51 +00:00
陈精华
7b52827fd0 !133 新增pages格式支持,调整SQL文件预览方式
Merge pull request !133 from 高雄/N/A
2023-05-06 03:22:44 +00:00
高雄
ca52ab7bee 新增pages格式支持,调整SQL文件预览方式
新增pages格式支持,调整SQL文件预览方式

Signed-off-by: 高雄 <admin@cxcp.com>
2023-05-04 00:50:39 +00:00
gaoxiongzaq
e41b18a4a8 新增:pdf支持密码 2023-04-28 09:48:51 +08:00
gaoxiongzaq
db3f03bda9 修复在反代情况下 压缩包获取路径的错误 2023-04-28 09:46:18 +08:00
陈精华
a59abd179f !130 新增:PDF文件生成图片的像素大小,dpi 越高,图片质量越清晰,同时也会消耗更多的计算资源。
Merge pull request !130 from 高雄/master
2023-04-27 09:40:12 +00:00
高雄
44992687f8 规范命名规则
规范命名规则

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-27 09:34:46 +00:00
高雄
350fbb3361 规范命名规则
规范命名规则

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-27 09:33:31 +00:00
gaoxiongzaq
d18677b9ed 新增:PDF文件生成图片的像素大小,dpi 越高,图片质量越清晰,同时也会消耗更多的计算资源。 2023-04-27 16:27:04 +08:00
陈精华
65af89d711 !126 修复启用反代后压缩包 解压后找不到路径
Merge pull request !126 from 高雄
2023-04-27 08:02:08 +00:00
陈精华
a655be3d36 !122 授信目录本地file协议正确使用方法
Merge pull request !122 from 高雄/master
2023-04-27 06:32:01 +00:00
高雄
f7fa8278be 修复启用反代后压缩包 解压后找不到路径
修复启用反代后压缩包 解压后找不到路径

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-27 03:06:18 +00:00
高雄
9aa08c1b20 授信目录本地file协议正确使用方法
授信目录本地file协议正确使用方法

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-25 05:37:20 +00:00
kailing
ab56253198 !121 获取aspose-cad 为官方地址
Merge pull request !121 from 高雄/master
2023-04-25 05:33:32 +00:00
kailing
ce2a966867 !120 修复获取baseUrl 方法的错误
Merge pull request !120 from 高雄/N/A
2023-04-25 05:02:13 +00:00
高雄
676f3bc1ab 删除文件 server/lib/aspose-cad-23.1.jar 2023-04-25 03:57:33 +00:00
高雄
0d0742ed20 获取aspose-cad 为官方地址
获取aspose-cad 为官方地址

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-25 03:57:13 +00:00
高雄
81936ed811 修复获取baseUrl 方法的错误
修复获取baseUrl 方法的错误

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-25 02:59:41 +00:00
kailing
e3b9df09f4 !116 调整 tif文件生成图片 添加后缀 防止同名产生 简化代码
Merge pull request !116 from 高雄/tif
2023-04-24 08:43:01 +00:00
kailing
f593b0cf24 !86 预览图片的url中如果包含&会导致.click报错儿
Merge pull request !86 from ASelince丶C/N/A
2023-04-24 08:02:02 +00:00
gaoxiongzaq
a1abdfb70a 调整 tif文件生成图片 添加后缀 防止同名产生 简化代码 2023-04-24 15:36:01 +08:00
kailing
10d5b20c81 !115 新增CAD类型 .dwf文件支持
Merge pull request !115 from 高雄/dwf
2023-04-24 06:44:06 +00:00
gaoxiongzaq
8649f20841 新增CAD类型 .dwf文件支持 2023-04-24 14:42:33 +08:00
kailing
ae55f53325 !110 功能修改:调整生成的PDF文件 文件名称添加文件后缀 防止生成同名文件
Merge pull request !110 from 高雄/rename.a.file
2023-04-24 05:59:02 +00:00
高雄
37d4a1b7c4 update server/src/main/java/cn/keking/service/impl/TiffFilePreviewImpl.java.
同名文件不同类型处理

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-24 05:51:31 +00:00
kl
2d5f5f0f23 重构 pdf2jpg 的逻辑 (#452)
* 重构 pdf2jpg 的逻辑

* 重构 pdf2jpg 的逻辑
2023-04-24 10:08:18 +08:00
kailing
06005201de !107 新增功能:添加更新缓存方法&forceUpdatedCache=true
Merge pull request !107 from 高雄/forceUpdatedCache
2023-04-23 06:18:10 +00:00
高雄
4786068521 新增功能:添加更新缓存方法&forceUpdatedCache=true
新增功能:添加更新缓存方法&forceUpdatedCache=true

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-23 06:15:09 +00:00
高雄
9aeacc6e67 新增功能:添加更新缓存方法&forceUpdatedCache=true
新增功能:添加更新缓存方法&forceUpdatedCache=true

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-23 05:59:51 +00:00
高雄
4f007e0c6e 新增功能:添加更新缓存方法&forceUpdatedCache=true
新增功能:添加更新缓存方法&forceUpdatedCache=true

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-23 05:58:25 +00:00
高雄
ace5a1898c 新增功能:添加更新缓存方法&forceUpdatedCache=true
新增功能:添加更新缓存方法&forceUpdatedCache=true

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-23 05:54:21 +00:00
高雄
832420f469 新增功能:添加更新缓存方法&forceUpdatedCache=true 可合并
新增功能:添加更新缓存方法&forceUpdatedCache=true 可合并

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-23 04:02:27 +00:00
gaoxiongzaq
98992b3d76 功能修改:调整生成的PDF文件 文件名称添加文件后缀 防止生成同名文件 2023-04-23 11:25:39 +08:00
gaoxiongzaq
f8c7ce647c 新增功能:添加更新缓存方法&force_updated_cache=true 2023-04-23 11:22:29 +08:00
kailing
e840201b1e !106 升级CAD组件为23.1版本
Merge pull request !106 from 高雄/cad23
2023-04-23 02:42:12 +00:00
gaoxiongzaq
a047d7be0d 升级CAD组件为23.1版本 2023-04-23 10:32:10 +08:00
kailing
73b51651a6 !105 恢复误删文件FileAttribute.java
Merge pull request !105 from 高雄/master
2023-04-23 02:25:42 +00:00
gaoxiongzaq
e54514fb39 恢复误删文件FileAttribute.java 2023-04-23 10:22:30 +08:00
kailing
5b6eb961cc !99 新增:删除转换后OFFICE、CAD、TIFF、压缩包源文件 默认开启 节约磁盘空间
Merge pull request !99 from 高雄/delete.source.file
2023-04-21 09:54:46 +00:00
高雄
87df3bedd0 删除文件 server/src/main/java/cn/keking/model/FileAttribute.java 2023-04-21 05:50:33 +00:00
高雄
fff3ea0e30 update server/src/main/java/cn/keking/model/FileAttribute.java.
修复删除源文件默认方法的  错误

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-21 03:36:11 +00:00
高雄
cfaa431e20 update server/src/main/java/cn/keking/config/ConfigConstants.java.
修复删除源文件默认方法的  错误

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-21 03:31:27 +00:00
gaoxiongzaq
61ae49f510 新增:删除转换后OFFICE、CAD、TIFF、压缩包源文件 默认开启 节约磁盘空间 2023-04-21 09:56:46 +08:00
kailing
079dfbbf92 !98 新增 drawio 绘图预览
Merge pull request !98 from 高雄/drawio
2023-04-20 08:51:01 +00:00
kailing
f520001863 !97 新增 dcm 等医疗数位影像预览
Merge pull request !97 from 高雄/dcm
2023-04-20 08:21:46 +00:00
gaoxiongzaq
57a9dc78ab 新增 drawio 绘图预览 2023-04-20 16:14:42 +08:00
gaoxiongzaq
83e20ac83c 新增 dcm 等医疗数位影像预览 2023-04-20 16:06:01 +08:00
kailing
76043a5b46 !94 fix: 移除checkImg全局index变量,防止变量污染引发问题
Merge pull request !94 from Frank Cheung/N/A
2023-04-20 03:01:05 +00:00
kailing
80baa4f633 !96 v4.3.0-SNAPSHOT版本 迭代开启
Merge pull request !96 from 高雄/master
2023-04-20 03:00:44 +00:00
高雄
66b68ecc82 update server/src/main/bin/startup.sh.
Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-20 02:54:26 +00:00
高雄
ec68d9b7f9 update Dockerfile.
v4.3.0-SNAPSHOT版本 迭代开启

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-20 02:48:30 +00:00
高雄
13210a7ca7 v4.3.0-SNAPSHOT版本 迭代开启
v4.3.0-SNAPSHOT版本 迭代开启

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-20 02:42:31 +00:00
高雄
c75c6c24ad v4.3.0-SNAPSHOT版本 迭代开启
v4.3.0-SNAPSHOT版本 迭代开启

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-20 02:41:38 +00:00
高雄
1faa59ae1c v4.3.0-SNAPSHOT版本 迭代开启
v4.3.0-SNAPSHOT版本 迭代开启

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-20 02:39:04 +00:00
高雄
2fc6d94e11 v4.3.0-SNAPSHOT版本 迭代开启
v4.3.0-SNAPSHOT版本 迭代开启

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-20 02:38:43 +00:00
高雄
6a6b34f5f9 v4.3.0-SNAPSHOT版本 迭代开启
v4.3.0-SNAPSHOT版本 迭代开启

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-20 02:37:56 +00:00
高雄
b0efe98785 v4.3.0-SNAPSHOT版本 迭代开启
v4.3.0-SNAPSHOT版本 迭代开启

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-20 02:36:30 +00:00
高雄
a7262cda7c v4.3.0-SNAPSHOT版本 迭代开启
v4.3.0-SNAPSHOT版本 迭代开启

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-20 02:36:01 +00:00
Frank Cheung
6834bd716c update server/src/main/resources/static/js/lazyload.js.
移除全局index变量,防止变量污染引发问题

Signed-off-by: Frank Cheung <frank.cheung.work@outlook.com>
2023-04-19 08:53:31 +00:00
kl
0aabf831ba 4.2.1 bugfix release 2023-04-18 14:48:34 +08:00
kailing
d3f92b175c !89 修复CAD文件预览错误
Merge pull request !89 from 高雄/master
2023-04-18 06:36:50 +00:00
高雄
031db0b7d5 修复CAD文件预览错误
修复CAD文件预览错误

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-18 03:50:36 +00:00
kl
523623698a 4.2.0 release 2023-04-13 14:05:36 +08:00
kl
f714dffe70 4.2.0 release 2023-04-13 10:40:01 +08:00
kailing
7a9ad7546c !85 新增备案信息,禁止上传类型,删除支持密码功能
Merge pull request !85 from 高雄/master
2023-04-13 02:32:43 +00:00
ASelince丶C
b53ad6054e 修正预览的url中包含&时会转义为&amp; 导致 document.getElementById("${currentUrl}").click 获取不到id
Signed-off-by: ASelince丶C <18331529783@163.com>
2023-04-12 05:48:16 +00:00
高雄
138e58a1e1 修改删除提示错误
修改删除提示错误

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-11 01:39:31 +00:00
高雄
55ca17203f 支持删除密码,前端限制上传大小
支持删除密码,前端限制上传大小

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-11 01:38:08 +00:00
高雄
8916bee786 修改上传提示信息
修改上传提示信息

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-11 01:19:17 +00:00
高雄
c055d3d992 新增备案信息,禁止上传类型,删除支持密码功能
新增备案信息,禁止上传类型,删除支持密码功能

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-10 09:36:09 +00:00
高雄
7b699e08fc 新增备案信息,禁止上传类型,删除支持密码功能
新增备案信息,禁止上传类型,删除支持密码功能

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-10 09:35:15 +00:00
高雄
c7367dfcec 新增备案信息,禁止上传类型,删除支持密码功能
新增备案信息,禁止上传类型,删除支持密码功能

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-10 09:34:37 +00:00
高雄
75a46a14a8 新增备案信息,禁止上传类型,删除支持密码功能
新增备案信息,禁止上传类型,删除支持密码功能

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-10 09:33:22 +00:00
高雄
181897ec5a 新增备案信息,禁止上传类型,删除支持密码功能
新增备案信息,禁止上传类型,删除支持密码功能

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-10 09:32:51 +00:00
高雄
e5e9611646 新增备案信息,禁止上传类型,删除支持密码功能
新增备案信息,禁止上传类型,删除支持密码功能

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-10 09:32:26 +00:00
高雄
78d517a16e 新增备案信息,禁止上传类型,删除支持密码功能
新增备案信息,禁止上传类型,删除支持密码功能

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-10 09:31:58 +00:00
高雄
e855c9c7ed 新增备案信息,禁止上传类型,删除支持密码功能
新增备案信息,禁止上传类型,删除支持密码功能

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-10 09:30:07 +00:00
kailing
195f56e9b9 !84 新增 支持压缩包密码 修复压缩包LINUX下中文乱码 解压支持文件目录 统一JQ文件 精简一些代码
Merge pull request !84 from 高雄/master
2023-04-10 03:32:42 +00:00
高雄
888e550453 精简压缩包解析的无用代码
精简压缩包解析的无用代码

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-10 03:26:51 +00:00
高雄
f771d361ae 精简压缩包解析的无用代码
精简压缩包解析的无用代码

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-10 03:16:55 +00:00
高雄
2cd23b06f1 TIF转换修改 1转换PDF保留缓存 代码精简优化
TIF转换修改 1转换PDF保留缓存 代码精简优化

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-08 06:07:09 +00:00
高雄
75e568e15f 新增 支持压缩包密码 修复压缩包LINUX下中文乱码 解压支持文件目录
新增 支持压缩包密码 修复压缩包LINUX下中文乱码 解压支持文件目录

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-08 05:45:17 +00:00
高雄
60b91eb79f 新增 支持压缩包密码 修复压缩包LINUX下中文乱码 解压支持文件目录
新增 支持压缩包密码 修复压缩包LINUX下中文乱码 解压支持文件目录

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-08 05:44:52 +00:00
高雄
dd7a6465aa 压缩包 编码工具类
压缩包 编码工具类

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-08 05:44:10 +00:00
高雄
4cd6a4e4b9 新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录
新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-08 05:43:02 +00:00
高雄
3942346f49 修复OFD页码只能显示10页的问题
修复OFD页码只能显示10页的问题

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-08 01:08:08 +00:00
高雄
e697c255fc 删除文件 server/src/main/resources/static/ofd/js/cnofd.umd.min.js 2023-04-08 01:07:43 +00:00
高雄
65fa326262 修复OFD页码只能显示10页的问题
修复OFD页码只能显示10页的问题

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-08 01:06:46 +00:00
高雄
81043034f9 删除文件 server/src/main/resources/static/ofd/js/cnofd.umd.min.js 2023-04-08 01:06:02 +00:00
高雄
6c5bceba41 TIF转换修改 1转换PDF保留缓存 代码精简优化
TIF转换修改 1转换PDF保留缓存 代码精简优化

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-04 01:13:03 +00:00
高雄
b524963892 删除文件 server/src/main/resources/static/xmind/js/jquery-3-c9f5aeeca3.2.1.min.js 2023-04-03 07:15:32 +00:00
高雄
dd4997cedc 删除不用的xmind组件
删除不用的xmind组件

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-03 07:15:22 +00:00
高雄
ead5505d53 支持IE的base64组件
支持IE的base64组件

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-03 07:14:33 +00:00
高雄
bf6cee4a6a 删除文件 server/src/main/resources/static/pptx/jquery-3.5.1.min.js 2023-04-03 07:13:43 +00:00
高雄
bd458bfbe9 新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录
新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-03 07:13:30 +00:00
高雄
7895597176 新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录
新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-03 07:12:51 +00:00
高雄
a44e5ba518 新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录
新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-03 07:12:05 +00:00
高雄
cc7da00001 新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录
新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-03 07:11:14 +00:00
高雄
41449aeea6 新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录
新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-03 07:10:22 +00:00
高雄
33277bc457 修复TIF转换pdf问题
修复TIF转换pdf问题

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-03 07:09:30 +00:00
高雄
f2cfb4cf4a 新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录
新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-03 07:08:33 +00:00
高雄
d646d72a26 新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录
新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-03 07:08:04 +00:00
高雄
1807dbd615 新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录
新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-03 07:07:30 +00:00
高雄
1e771ed649 新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录
新增 支持压缩包密码 修复LINUX下中文乱码 解压支持文件目录

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-03 07:06:46 +00:00
高雄
83d04ca45d 更新TIF转换PDF插件
更新TIF转换PDF插件

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-03 05:36:10 +00:00
高雄
ee2dadb40d 更新TIF转换PDF插件
更新TIF转换PDF插件

Signed-off-by: 高雄 <admin@cxcp.com>
2023-04-03 05:35:38 +00:00
kl
c9eb51213f Update README.cn.md 2023-03-31 12:25:29 +08:00
kl
81f28baabf Merge remote-tracking branch 'origin/master' 2023-03-31 12:22:39 +08:00
kl
1245e9f327 Update documentation 2023-03-31 12:22:34 +08:00
kl
007889339b Update README.md (#449) 2023-03-31 12:18:49 +08:00
kl
9cf5e8691d Update documentation 2023-03-31 12:13:13 +08:00
kl
ff1bfe5f98 Update documentation 2023-03-31 12:02:29 +08:00
kl
c2c870668b Refactoring the code for file uploads 2023-03-29 15:51:17 +08:00
kailing
b7ed284ae9 !78 修复OFD解析失败问题
Merge pull request !78 from 高雄/master
2023-03-25 02:38:05 +00:00
高雄
e33db39494 update server/src/main/resources/static/ofd/js/cnofd-view.js.
修复OFD解析失败问题

Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-25 01:00:33 +00:00
kl
f13cccf5a6 Get the file list sorted in descending order 2023-03-24 13:41:19 +08:00
kailing
c355c915f8 !77 xlsm等格式类型转换成HTML
Merge pull request !77 from 高雄/master
2023-03-21 08:16:43 +00:00
高雄
92a95db34c 更新OFD组件为最新版本
Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-21 08:10:56 +00:00
高雄
1a821706ee 删除文件 server/src/main/resources/static/ofd/js/cnofd.umd.min.js 2023-03-21 08:10:03 +00:00
高雄
604e118036 update server/src/main/resources/static/ofd/js/cnofd-view.js.
更新OFD组件

Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-21 08:06:40 +00:00
高雄
871a83e3b5 update server/src/main/resources/static/ofd/index.html.
更新OFD解析组件为1.4.1

Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-21 08:05:50 +00:00
高雄
6d3f9e7cfc update server/src/main/java/cn/keking/service/impl/OfficeFilePreviewImpl.java.
规范转换格式

Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-21 06:02:40 +00:00
kailing
b5e281a3b1 !76 修复安全限制 代码继续执行的问题
Merge pull request !76 from 高雄/master
2023-03-20 07:46:07 +00:00
高雄
60d9ef7069 update server/src/main/java/cn/keking/config/WebConfig.java.
加入安全限制

Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-20 07:39:14 +00:00
高雄
98a7217b10 update server/src/main/java/cn/keking/web/filter/TrustHostFilter.java.
修复开启信任站点 继续执行

Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-20 07:28:03 +00:00
高雄
a867effa68 update server/src/main/java/cn/keking/utils/DownloadUtils.java.
调整下载报错

Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-20 07:26:23 +00:00
kl
058ebd8274 Optimised home page UI 2023-03-17 19:43:33 +08:00
kl
784eec99de Update README.cn.md 2023-03-15 14:00:44 +08:00
kailing
3e2e330fcb !75 修复xlsx7.4以上版本 乱码
Merge pull request !75 from 高雄/master
2023-03-15 02:46:03 +00:00
高雄
e50a664e64 update server/src/main/java/cn/keking/service/FileHandlerService.java.
修复LibreOffice7.4以上版本 出现乱码

Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-15 02:40:32 +00:00
高雄
94503ddc39 update server/src/main/java/cn/keking/service/FileHandlerService.java.
修复xlsx7.4以上版本 乱码

Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-15 02:34:52 +00:00
kl
99bdeef754 Add sponsored access and remove unused codes 2023-03-14 17:42:17 +08:00
kl
e08c41baa9 Modify demo site address (#443)
* Add workflow bpmn file preview support

* Adjusting the home page

* Modify demo site address
2023-03-14 15:19:04 +08:00
kl
ca9eefb80b Adjusting the home page (#442)
* Add workflow bpmn file preview support

* Adjusting the home page
2023-03-14 14:54:40 +08:00
kailing
4962b8b3ca !74 新增dotx文件类型支持
Merge pull request !74 from 高雄/master
2023-03-11 02:22:17 +00:00
高雄
eb372686e6 update server/src/main/java/cn/keking/model/FileType.java.
新增dotx文件类型支持

Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-11 01:07:24 +00:00
高雄
daf506e1bd update README.cn.md.
Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-11 01:05:15 +00:00
高雄
b239d5b440 update README.md.
新增dotx文件支持

Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-11 01:04:35 +00:00
kl
09a3fd2db8 Add workflow bpmn file preview support (#441) 2023-03-09 21:00:03 +08:00
kailing
eb12ced77f !73 更新组件,新增dotm,ett,xlt,xltm,wpt,dot,xlam,xla 格式支持
Merge pull request !73 from 高雄/master
2023-03-09 10:00:22 +00:00
高雄
5521386781 update README.md.
Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-09 08:59:46 +00:00
高雄
24698be8be update README.cn.md.
Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-09 08:58:51 +00:00
高雄
6183e8c3e5 update server/src/main/java/cn/keking/model/FileType.java.
新增dotm,ett,xlt,xltm,wpt,dot,xlam,xla 格式支持

Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-09 08:39:43 +00:00
高雄
cdc146747b update pom.xml.
更新组件

Signed-off-by: 高雄 <admin@cxcp.com>
2023-03-09 08:37:36 +00:00
kl
ca9fcf6cf6 Update documentation 2023-03-09 13:02:46 +08:00
陈精华
daa081d46d !70 修正PDF转图片,内存无法回收导致的OOM
Merge pull request !70 from SawyerYong/N/A
2023-03-08 05:55:45 +00:00
kl
be23560ee4 Merge remote-tracking branch 'origin/master' 2023-03-08 11:27:35 +08:00
kl
134ff34c5e Disable the delete button 2023-03-08 11:27:24 +08:00
kl
f9e5fd01be Update README.cn.md 2023-03-06 22:55:37 +08:00
kl
e278d8f049 Update README.md 2023-03-06 22:55:11 +08:00
kl
7a25e0cb34 Update documentation 2023-03-06 18:09:43 +08:00
kl
e25cc2e47c Fixes an issue with xmind file preview in certain deployment scenarios (#439) 2023-03-06 14:27:36 +08:00
kl
fd10df913f Update README.md 2023-03-03 21:49:38 +08:00
kl
5d39246ef5 Update README.md 2023-03-03 21:16:19 +08:00
kl
724a0124b5 Update the installation resource address (#438)
* Update documentation

* Update the installation resource address
2023-03-03 18:58:32 +08:00
kl
976e54407e Update documentation (#437) 2023-03-03 18:42:44 +08:00
kl
b7285dc93c Update README.md (#436) 2023-03-03 17:20:20 +08:00
SawyerYong
8cb310ef93 修正PDF转图片,内存无法回收导致的OOM
Signed-off-by: SawyerYong <dev_yongs@163.com>
2023-02-18 07:27:35 +00:00
gaoxingzaq
c0cf4fcc39 修复特殊符号的文件无法删除 (#427)
* 修复特殊符号的文件无法删除

* cad 优化

Co-authored-by: gaoxiongzaq <admin@cxcp.com>
2023-01-17 22:56:51 +08:00
gaoxingzaq
5dc543db99 修复流的方法错误 ,修复跨域脚本缺少BASE64 (#423)
* 修复office下载方法中 错误

* 更新OFD解析效果,修复禁止trace请求无效问题,其他压缩包修复

* 修复压缩包 缓存BUG

* 限制某些特殊文件上传

* 修复OFFICE文件密码检查关闭流 上传文件关闭流 检查PDF文件是否存在

* 特殊符号的支持

Co-authored-by: gaoxiongzaq <admin@cxcp.com>
2023-01-11 13:26:18 +08:00
陈精华
04401ee600 修复office文件密码判断 2022-12-28 13:52:50 +08:00
陈精华
e0cc2b6a01 修复office文件密码判断 2022-12-28 13:35:34 +08:00
陈精华
2184264831 Update README.md 2022-12-28 10:47:12 +08:00
奋斗的小果
ac3b0cb652 fix:解决内部自签证书https协议url文件无法下载的问题 (#396)
Co-authored-by: 鞠玉果 <juyg5@chinaunicom.cn>
2022-12-28 10:40:56 +08:00
gaoxingzaq
69566834ea 1,优化URL报错,2,更新OFD组件 3,美化Excel 4,文本方法关闭字节流 5,新增多种类型文件预览 (#419)
1,优化URL报错
2,更新OFD组件
3,美化Excel
4,文本方法关闭字节流
5,新增xmind、eml、epub、"obj", "3ds", "stl", "ply", "off", "3dm", "fbx", "dae", "wrl", "3mf", "ifc","glb","o3dv","gltf","stp","bim","fcstd","step","iges","brep"格式

Co-authored-by: gaoxiongzaq <admin@cxcp.com>
2022-12-28 10:17:06 +08:00
陈精华
aa66173625 svg预览修复 2022-12-19 17:52:40 +08:00
陈精华
9ceb052eb4 移除前端commonHeader.ftl中多余的依赖 2022-12-19 16:46:55 +08:00
陈精华
f52169ec27 jodconverter转换带密码office文件 2022-12-19 16:38:50 +08:00
陈精华
d761d0cc88 更新windows内置office目录名, 适配jodconverter 2022-12-19 14:45:45 +08:00
陈精华
7d3a4ebc4e 移除office-plugin, 使用新版jodconverter 2022-12-17 00:02:36 +08:00
fuzi
281a9cfbab fix:issues/414 设置contextPath后演示地址未及时更新 (#415) 2022-12-16 23:58:56 +08:00
gaoxingzaq
8c6f5bf807 文本文档加入缓存,安全修复XSS,美化404、500报错等,新增SVG格式预览,ofd优化印章渲染兼容性 (#413)
1、文本文档加入缓存
2、安全修复XSS(跨站脚本攻击)
3、美化404、500报错等
5、新增 SVG格式预览
5、ofd优化印章渲染兼容性

Co-authored-by: gaoxiongzaq <admin@cxcp.com>
2022-12-16 23:58:26 +08:00
陈精华
bb63808767 报错页面更新知识星球帮助链接 2022-12-15 11:21:43 +08:00
陈精华
96d2765d64 开启v4.2.0版本迭代 2022-12-15 10:33:23 +08:00
陈精华
492ec024c4 更新kk开源社区链接 2022-12-14 11:04:32 +08:00
陈精华
eb12eb0695 4.1.0版本发布 2022-12-14 09:45:48 +08:00
陈精华
d78351f72c NULL地址不允许预览 2022-12-14 09:40:37 +08:00
陈精华
af752cfa13 修复Autowire static method 2022-12-13 18:17:20 +08:00
陈精华
f0dc845825 禁止TRACE请求 2022-12-13 18:04:22 +08:00
陈精华
5ecb5f667d 懒加载同时加载水印 2022-12-13 17:56:35 +08:00
陈精华
3dcd183171 ofd和tiff下载跨域文件接口修改 2022-12-13 17:50:28 +08:00
陈精华
167189d4e4 xml预览加上bootstrap样式 2022-12-13 17:26:50 +08:00
陈精华
d6c083fb5b 更新Office和Image文件类型 2022-12-13 17:04:40 +08:00
陈精华
1dd59cf764 更新跨域文件下载方法 2022-12-13 17:04:34 +08:00
陈精华
e7930a2442 更新tiff预览 2022-12-13 17:04:24 +08:00
陈精华
1261e6aa03 部分PDF转image报错问题修复 2022-12-13 17:04:16 +08:00
陈精华
3abcfe90bc XML文本转义 2022-12-13 17:04:09 +08:00
陈精华
cf336781d8 ODF预览组件更新 2022-12-13 17:04:00 +08:00
陈精华
4c0aa3cfc3 更新jQuery版本到3.6.1 2022-12-13 17:02:03 +08:00
陈精华
0a1fb6d983 commonHeader移除bootstrap依赖 2022-12-13 11:16:10 +08:00
陈精华
99b1f83e50 PPT预览水印 2022-12-13 09:53:28 +08:00
陈精华
4db74d0931 更新Gitee流水线脚本 2022-12-12 17:48:02 +08:00
陈精华
9860df9b6d ppt预览水印 2022-12-12 17:40:36 +08:00
陈精华
4c225b030d 修复压缩文件中文乱码 2022-12-12 16:49:41 +08:00
陈精华
9e5b9d4889 解决编译warning 2022-12-12 14:23:32 +08:00
陈精华
e9c4e134c6 修复文本文档以'~'结尾报错 2022-12-12 10:30:13 +08:00
陈精华
5704a4182e 更新Docker镜像为阿里云源 2022-12-08 16:00:32 +08:00
陈精华
489bdfbc01 csv当作excel预览 2022-12-08 13:43:01 +08:00
Bo_boom
53a840af4b 表单校验警告提示添加; (#410)
* 表单校验警告提示添加

Co-authored-by: wusongda <wusongda@keking.cn>
2022-12-05 17:38:33 +08:00
wsd7747
8c8d596c43 预览演示首页重构 (#403)
bootstrap3更新
首页重构
Co-authored-by: wusongda <wusongda@keking.cn>
2022-11-21 15:01:19 +08:00
陈精华
a3f91641dd 依赖调整 2022-11-18 23:30:43 +08:00
gitchenjh
f5754be9ff Merge pull request #401 from gitchenjh/master
Linux发行版&Docker镜像升级LibreOffice7.3、其他优化
2022-11-15 10:08:52 +08:00
陈精华
12f40b831f 更新首页说明 2022-11-14 10:50:27 +08:00
陈精华
859feff328 Docker基础镜像默认安装LibreOffice7.3 2022-11-14 09:17:05 +08:00
陈精华
bba44ca057 Linux下检测正在运行的office进程检测逻辑修正 2022-11-11 17:06:42 +08:00
陈精华
5134f7a121 Linux环境下默认安装LibreOffice7.3, 检测Office组件新增LibreOffice 7.3 7.4 版本 2022-11-11 17:00:51 +08:00
陈精华
b366d0b464 首页预览增加是否合法url判断 2022-11-11 17:00:51 +08:00
陈精华
e3fb1d7c15 更新banner 2022-11-11 17:00:50 +08:00
陈精华
883b45f201 中文URL参数解码 2022-11-11 17:00:50 +08:00
gitchenjh
8fb32e4f73 Merge pull request #400 from gitchenjh/master
修复升级poi版本后判断office是否受密码保护方法
2022-11-11 10:53:33 +08:00
陈精华
764ea702d0 修复升级poi版本后判断office是否受密码保护方法 2022-11-10 18:27:39 +08:00
kl
b225cebc95 更新相关依赖版本 (#377) 2022-08-01 15:10:30 +08:00
kl
106036d989 优化 baseURL 的获取逻辑 (#376) 2022-08-01 14:09:41 +08:00
kischn.sun
026656711d 添加通过 http header X-Base-Url 来动态传入 baseUrl 的功能 (#252)
* 将 baseUrl 拼接挪到 else 分支下消除特殊情况下(不走else)不必要的拼接处理

* 添加通过 Http Header X-Base-Url 来动态赋值 baseUrl 的功能来实现更灵活代理支持
2022-08-01 14:01:04 +08:00
gkchp
35a8c4a5a6 修复加号被转换成空格导致Base64解码出错 (#340)
* 修复url中加号被替换为空格导致的Base64解码出错

* Base64解码抽象到工具类

* #340 补充注释
2022-07-29 23:08:21 +08:00
kl
86960e3813 Fix #370 2022-07-25 18:33:57 +08:00
kl
b099d52520 优化、精简代码。使用 @GetMapping、@PostMapping 替换 @RequestMapping 2022-07-25 17:28:26 +08:00
shenghuadun
6efe15788c !43 水印其他属性不知道动态传入的问题
* 水印除文本外其他属性可通过url动态传入
2022-07-21 06:45:46 +00:00
tomhusky
3e43c2f9d0 !49 修复Linux环境中OfficePluginManager中KillProcess出现杀掉进程失败,导致二次启动失败的bug
* 修复Linux环境中OfficePluginManager中KillProcess出现杀掉已经存在进程失败,导致二次启动失败的bug
2022-07-21 03:50:09 +00:00
陈精华
f1b949865f 更新Gitee workflow文件 2022-07-21 11:38:48 +08:00
陈精华
ab439a17a3 所有页面增加favicon.ico 2022-07-21 11:29:54 +08:00
陈精华
dd65564af6 修复getCorsFile接口未加base64编码(filter中解码异常) 2022-07-21 11:27:06 +08:00
yl-yue
acffcbfe98 !51 实现预览加密的(受密码保护)office文件
* 1. 修复getCorsFile接口高危安全漏洞
* 1. 优化密码错误提示(“密码错误,请重新输入密码。”)
* 1. 修复PPT重复预览bug,此bug导致ppt每次预览会执行两次转换(请求两次onlinePreview接口),在大文件尤其耗时(双倍时…
* 1. 【加密office预览】优化受密码保护的office文件检查逻辑,提升旧文件格式的兼容性
* 1. 【加密office预览】优化office文件是否受密码保护判断逻辑,避免兼容性误判
* 1. 【加密office预览】优化重新输入密码提示。
* 1. 【加密office预览】优化当密码输入错误后,不是抛出异常,而是提示用户重新输入
* 1. 优化prompt提示框的输入密码提示样式
* 1. 实现基于userToken缓存加密文件,没有userToken的加密文件不缓存
* 1. 优化docker构建方案,使用分层构建方式,采用层级缓存解决构建慢发布慢等问题。从原本5分钟左右缩短至几秒
* 1. 加密文件暂时不缓存(后续基于用户token实现,基于用户缓存)
* 1. 优化office文件下载逻辑,跳过重复下载(大量节约带宽与磁盘空间)。
* 1. 修复预览不同类型的加密office文件bug
* 实现预览加密的(受密码保护)office文件
2022-07-21 03:19:46 +00:00
kailing
04703aa03c add pipeline-20220716.yml for Gitee Go created_at:2022-07-16 12:57:59 2022-07-16 12:57:59 +00:00
kailing
584e6b2c77 add default pipeline template yaml 2022-07-16 12:56:45 +00:00
chenkailing
82f6d3565f 优化 file:// 协议访问授信目录的代码结构 2022-05-25 19:37:29 +08:00
gitchenjh
8c68834e17 Merge pull request #342 from gitchenjh/master
修复使用http文件流下载时文件名编码异常Gitee-#I4W0TQ
2022-03-09 19:48:22 -06:00
陈精华
ba7b6eed4a 修复使用http文件流下载时文件名编码异常Gitee-#I4W0TQ 2022-03-10 09:47:05 +08:00
gitchenjh
051ad0f4ea Merge pull request #334 from NullXin/wzxdev
ppt显示问题
2022-02-21 00:10:17 -06:00
1192247166@qq.com
05935c29e1 1、左边侧边栏显示总页码显示为0
2、修改左屏幕分辨率过高,显示图片过大。
2022-01-26 11:38:12 +08:00
zhangzhen1979
6a2735ec3d tif图片预览。因无法下载jai_core包,所以去掉pom中geotoolkit仓库的设置 2021-12-20 17:31:18 +08:00
zhangzhen1979
8bc53f76eb tif图片预览。更新本地jai_core包的版本至1.1.3 2021-12-20 17:31:18 +08:00
zhangzhen1979
48f6a507dc tif图片预览。根据 @gaoxingzaq 反馈和帮助,修改tif文件的jpg、pdf模式预览功能,兼容多页tif的pdf转换、jpg转换,以及jpg在线多页预览功能。 2021-12-20 17:31:18 +08:00
BearBen
20f328906c 解压方案新版测试修复乱码Linux问题 2021-12-17 17:40:23 +08:00
gitchenjh
4d1e2eb9c6 Merge pull request #326 from gitchenjh/master
修复 #311
2021-12-17 17:38:58 +08:00
gitchenjh
97542b06fa Create maven.yml
add Github Action
2021-12-17 17:31:32 +08:00
陈精华
0c93c7e4b6 update README 2021-12-17 17:22:31 +08:00
陈精华
56d9906c74 修复ppt预览在改过context-path后出现异常 (#311) 2021-12-17 17:18:58 +08:00
gitchenjh
5cfe37433f Merge pull request #321 from gitchenjh/master
启动脚本版本更新为4.1.0-SNAPSHOT
2021-12-14 13:38:00 +08:00
陈精华
45ebef3b74 启动脚本版本更新为4.1.0-SNAPSHOT 2021-12-14 13:37:03 +08:00
gitchenjh
2ed294bd65 Merge pull request #317 from zzzhouuu/master
feat: 通过配置控制PDF.js viewer toolbar & secondaryToolbar功能按钮
2021-12-10 17:31:25 +08:00
zhangzhen1979
91f3348a2f * tif图片预览,根据反馈的意见,已经全部修改 2021-12-10 17:13:57 +08:00
zhangzhen1979
d424de5e9a * tif图片预览,根据反馈的意见,已经全部修改 2021-12-10 17:13:57 +08:00
zhangzhen1979
6387ac21c9 * tif图片预览,根据反馈的意见,已经全部修改
1、配置文件、配置项默认值已改回image、tif
2、去掉了静态工具类上的@component 注解
3、修改OnlinePreview处理,在切换image方式预览时url中加入参数previewType=image,加入对应的处理,兼容在pdf预览模式下切换到JPG方式预览
2021-12-10 17:13:57 +08:00
zhangzhen1979
6dce47e47f * tif图片预览,在application.properties中加入tif.preview.type = ${KK_TIF_PREVIEW_TYPE:tif},可以控制使用tif、jpg、pdf方式预览。
修改相应代码,加入必要的判断处理。
2021-12-10 17:13:57 +08:00
zhangzhen1979
b7760ab42a * tif图片预览,改为支持转换为jpg后预览(JAI支持);加入tif->jpg->pdf转换后,以pdf格式预览,此种模式可完美支持打印纸张自适应。 2021-12-10 17:13:57 +08:00
周游
e0405bc5f6 Merge remote-tracking branch 'upstream/master' 2021-12-09 09:32:34 +08:00
gitchenjh
14151a6c46 Merge pull request #315 from gitchenjh/master
4.1.0迭代开启
2021-12-07 16:13:01 +08:00
陈精华
00555d3544 4.1.0迭代开启 2021-12-07 16:11:50 +08:00
Nevan Chow
7b2adc3979 Merge branch 'master' into master 2021-11-30 17:53:24 +08:00
gitchenjh
0a5fc1e4a8 Merge pull request #301 from fangzhengjin/patch-1
fix: PDF/word图片模式预览时, 下翻图片时频繁请求图片资源
2021-11-28 17:05:39 +08:00
gitchenjh
304d974b38 Merge pull request #268 from kekingcn/dependabot/maven/server/org.apache.commons-commons-compress-1.21
Bump commons-compress from 1.19 to 1.21 in /server
2021-11-25 16:19:52 +08:00
gitchenjh
6792a7afa7 Merge pull request #282 from kekingcn/dependabot/maven/server/com.thoughtworks.xstream-xstream-1.4.18
Bump xstream from 1.4.17 to 1.4.18 in /server
2021-11-25 16:19:39 +08:00
gitchenjh
ded297de59 Merge pull request #310 from gitchenjh/master
修复文件名包含空格时不能预览 #294
2021-11-25 16:11:35 +08:00
陈精华
f616678d83 修复文件名包含空格时不能预览 #294 2021-11-25 16:10:33 +08:00
gitchenjh
e10273dcdd Merge pull request #289 from sanxiHsu/master
Update startup.sh
2021-11-25 15:48:06 +08:00
gitchenjh
343269670c Merge pull request #288 from sanxiHsu/patch-2
Update shutdown.sh
2021-11-25 15:47:53 +08:00
gitchenjh
8af157b848 Merge pull request #309 from gitchenjh/master
处理Issues
2021-11-25 14:07:33 +08:00
陈精华
9d65c999e5 增加配置,限制允许预览的本地文件夹 #304 2021-11-25 13:47:51 +08:00
陈精华
4fe0d0edc9 PDF.js版本更新,解决 #264 2021-11-25 10:48:56 +08:00
周游
b1aab27338 feat: 通过配置控制PDF.js viewer toolbar & secondaryToolbar功能按钮 2021-11-16 11:50:12 +08:00
ZhengJin Fang
727e9ae9ed fix: PDF/word图片模式预览时, 下翻图片时频繁请求图片资源 2021-11-10 16:27:55 +08:00
sanxiHsu
dc9df5d760 Update startup.sh
更新根据pid文件来识别后台进程是否处于运行状态,避免同时启动多个后台进程。
2021-09-18 06:10:57 +00:00
sanxiHsu
b7de791658 Update shutdown.sh
原脚本使用grep,但grep只能用于人工操作无法用于自动脚本,原因在于无论是否搜索到正确结果,都会返回该grep进程的ID号,这时候kill就报错了。
更改为pid文件方式也是业界较为稳妥的方式。
2021-09-18 05:13:30 +00:00
Yiding He
82c7b59650 在主页上添加输入URL地址来预览的表单 2021-09-13 16:00:38 +08:00
dependabot[bot]
e0b9d8f476 Bump xstream from 1.4.17 to 1.4.18 in /server
Bumps [xstream](https://github.com/x-stream/xstream) from 1.4.17 to 1.4.18.
- [Release notes](https://github.com/x-stream/xstream/releases)
- [Commits](https://github.com/x-stream/xstream/commits)

---
updated-dependencies:
- dependency-name: com.thoughtworks.xstream:xstream
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-25 15:56:05 +00:00
陈精华
db2ed3a555 修复某些版本LibreOffice本地安装了,但检测不到问题 2021-08-25 15:27:36 +08:00
xiaxiaxiaxia
6efc375066 Fix:修复install.sh安装脚本路径错误 2021-08-24 16:05:41 +08:00
Yiding He
9a4c864490 重命名 env() 2021-08-24 13:56:07 +08:00
Yiding He
a3081ef4a9 修复单元测试失败的问题 2021-08-24 13:56:07 +08:00
Yiding He
43374e02bd 让 office-plugin 项目的语言级别与父项目保持一致 2021-08-24 11:05:12 +08:00
gitchenjh
fb8a19469b Merge pull request #272 from jerrykcode/master
修复: 文件名含有特殊字符时无法预览
2021-08-21 14:19:40 +08:00
jerrykcode
f2d5f4a86c 为WebUtils.encodeUrlFileName方法添加测试用例 2021-08-20 14:15:42 +08:00
jerrykcode
2177aed64f 修复: 文件名含有特殊字符时无法预览 2021-08-19 20:26:37 +08:00
dependabot[bot]
d20ac8fafc Bump commons-compress from 1.19 to 1.21 in /server
Bumps commons-compress from 1.19 to 1.21.

---
updated-dependencies:
- dependency-name: org.apache.commons:commons-compress
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-02 17:25:07 +00:00
捏造的信仰
2395a489a3 Update startup.sh
Add `/usr/lib64/libreoffice` to search path list.
2021-07-21 15:42:11 +08:00
ypgsh
0b8eedf935 feat: add dxf file type in cad scope 2021-07-21 15:41:35 +08:00
gitchenjh
807ada0bf9 4.0.0版本
4.0.0版本
2021-07-06 11:43:11 +08:00
陈精华
216c35c0b8 4.0.0版本发布 2021-07-06 11:15:50 +08:00
陈精华
d98cd5d9a9 优化:启动Office进程改为同步执行,防止程序运行起来Office进程还没启动 2021-07-06 11:12:07 +08:00
陈精华
fb6adf316f 优化:Windows环境下没有配置office.home,查找Office组件,内置的优先 2021-07-06 09:44:49 +08:00
陈精华
0854317cc8 优化:增加Office进程关闭日志 2021-07-06 09:10:19 +08:00
陈精华
fcdefa450c 新功能点:首页文件上传功能可通过配置实时开启或禁用 2021-07-06 09:09:19 +08:00
陈精华
dc50a460e5 修复:PPT图片预览模式前端显示异常 2021-07-05 14:37:39 +08:00
陈精华
31187ccb69 修复:PPT预览使用PDF模式无效 2021-07-05 11:09:53 +08:00
陈精华
d4b72b06e9 Dockerfile 拼写错误更正 2021-06-25 10:43:01 +08:00
陈精华
922e1e6ac4 修复压缩文件目录穿越漏洞 2021-06-23 12:25:14 +08:00
陈精华
79341b2c8e 集成OpenOffice替换为LibreOffice 2021-06-23 10:26:22 +08:00
kl
8a1eebb9b0 v3.6.0 版本发布 2021-06-17 19:06:37 +08:00
kl
85e26c6d93 修复 ofd 预览功能影响 office 预览的问题 2021-06-17 18:13:31 +08:00
gaoxiong
0a1ff64d18 修复某些情况下txt文本乱码问题 2021-06-17 17:48:48 +08:00
gaoxiong
176f38070d 对txt、log内容太多文件实现html分页显示 2021-06-17 17:48:48 +08:00
gaoxiong
4f5b0f74fd 美化ppt图片显示 2021-06-17 17:48:48 +08:00
gaoxiong
c549508417 增加OFD功能 2021-06-17 17:48:48 +08:00
gaoxiong
b86515a926 增加OFD功能 2021-06-17 17:48:48 +08:00
dependabot[bot]
1ba8c31d2c Bump commons-io from 1.4 to 2.7 in /office-plugin
Bumps commons-io from 1.4 to 2.7.

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-17 17:43:54 +08:00
dependabot[bot]
06ff1d4e8f Bump pdfbox from 2.0.15 to 2.0.24 in /server
Bumps pdfbox from 2.0.15 to 2.0.24.

---
updated-dependencies:
- dependency-name: org.apache.pdfbox:pdfbox
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-17 17:43:44 +08:00
dependabot[bot]
b03a11f2b5 Bump xstream from 1.4.16 to 1.4.17 in /server
Bumps [xstream](https://github.com/x-stream/xstream) from 1.4.16 to 1.4.17.
- [Release notes](https://github.com/x-stream/xstream/releases)
- [Commits](https://github.com/x-stream/xstream/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-17 17:43:33 +08:00
gitchenjh
a362d21aa4 Merge pull request #249 from opkcloud/master
Dockerfile 中添加 openoffice / libreoffice 的配置,可动态切换部署
2021-05-28 17:19:23 +08:00
opkopk12333
cd33d80a8c Dockerfile 中添加 openoffice / libreoffice 的配置,可动态切换部署 2021-05-27 21:14:09 +08:00
dependabot[bot]
2bb0dd545d Bump xstream from 1.4.15 to 1.4.16 in /server
Bumps [xstream](https://github.com/x-stream/xstream) from 1.4.15 to 1.4.16.
- [Release notes](https://github.com/x-stream/xstream/releases)
- [Commits](https://github.com/x-stream/xstream/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-19 13:32:13 +08:00
youken9980
ac2115114c 修正Redis服务器没有设置密码,但客户端向其发送身份验证请求的问题 2021-04-19 13:31:50 +08:00
youken9980
831550d847 修正office.preview.switch.disabled引用了错误常量的问题 2021-04-19 13:31:50 +08:00
youken9980
1fa7b4a911 修正区分大小写的文件系统中,文件后缀名为大写时,系统提示该文件类型不支持的问题 2021-04-19 13:31:50 +08:00
zhangxiaoxiao9527
bcdb5ce0e6 集成视频格式转换功能1.0(基于javacv) 2021-04-19 13:29:25 +08:00
gitchenjh
a3485dd9b7 Merge pull request #230 from gitchenjh/master
3.5.1版
2021-04-06 17:47:07 +08:00
陈精华
5a28b89f46 3.5.1版 2021-04-06 16:45:18 +08:00
陈精华
58b1b50c2e 修复:pdf.js 跨域问题 2021-04-06 16:44:40 +08:00
kl
8f75df15e2 修复 tif、tiff 文件预览初始内存太小预览失败的问题 2021-03-26 10:05:58 +08:00
gitchenjh
9883d3b064 assembly打包区分windows和linux
assembly打包区分windows和linux
2021-03-19 09:47:16 +08:00
kl
e477ce7048 修复打包插件 2021-03-19 09:45:04 +08:00
陈精华
0985aed0b0 assembly打包区分windows和linux,修复windows发行包启动报找不到找不到office组件 2021-03-19 09:41:01 +08:00
kl
2ffda7a1a6 更新版本到 3.5 2021-03-18 20:20:42 +08:00
kl
5cad4aa93e 文本预览转义处理 2021-03-18 20:12:50 +08:00
gitchenjh
2a61449ce1 Merge pull request #221 from gitchenjh/master
修复:pom编译版本
2021-03-18 17:42:24 +08:00
陈精华
fe0b42c5e3 修复:pom编译版本 2021-03-18 17:38:53 +08:00
kl
6ccc724839 office plugin 转换进程、任务超时可配置 2021-03-12 21:32:01 +08:00
kl
56cdeffaa9 新增 wps 文档预览支持 2021-03-02 17:29:49 +08:00
13540823418
5633eb4111 1.优化项目目录结构之后,windows下启动报错“找不到office组件”
2.import代码错误修复
2021-02-25 15:13:07 +08:00
fengzehao
6255c8dbbc modify some bug 2021-02-19 13:36:47 +08:00
kl
1fd7d5df88 新增依赖 highlightjs 代码文件预览高亮支持 2021-02-19 10:15:20 +08:00
chenkailing
01213c5d02 移除针对 tomcat 的配置 2021-02-10 12:53:27 +08:00
chenkailing
49685e545b 移除多余的 repositories 配置 2021-02-10 01:03:19 +08:00
chenkailing
2542a24675 优化项目结构、优化 maven 结构 2021-02-10 00:58:13 +08:00
chenkailing
28d3e05ca9 简化启动脚本 2021-02-09 21:44:58 +08:00
chenkailing
00fbb5cd74 Merge branch 'master' of https://github.com/kekingcn/kkFileView 2021-02-09 21:39:21 +08:00
kl
fbafcd5c92 新增 tiff 、tif 图像文件格式预览支持 2021-02-08 18:11:43 +08:00
kl
376a90772d 新增 tiff 、tif 图像文件格式预览支持 2021-02-08 18:02:49 +08:00
kl
4f4e75859d 新增 kkFIleView 的 banner 信息 2021-02-08 15:16:24 +08:00
kl
679459f53b 更新 spring-boot 到最新的 v2.4.2 版本 2021-02-07 18:34:35 +08:00
kl
8baef0d873 gitee star增长趋势图获取增加缓存时间设置 2021-02-07 18:01:53 +08:00
kl
d01dddf9e3 动态获取演示页访问地址的端口信息 2021-02-04 11:38:45 +08:00
kl
d61e5236d0 新增启动完成,打印启动耗时、演示页访问地址 2021-02-04 11:33:56 +08:00
kl
d514e6dc0f 更新 README.md 2021-02-04 09:51:41 +08:00
kl
188d2def2d 1、新增 github stars 增长趋势图 2021-02-03 18:23:47 +08:00
kl
17d64ad963 1、补充发版信息 2、新增 stars 增长趋势图 2021-02-03 18:01:55 +08:00
kl
d95fbe02bd 简化下载文件 io 操作 2021-01-28 15:55:42 +08:00
gitchenjh
212526d989 Merge pull request #209 from gitchenjh/master
修复:jodd.io.NetUtil.downloadFile下载大于16M文件报错问题
2021-01-28 15:43:05 +08:00
陈精华
ef5052e7ea 修复:jodd.io.NetUtil.downloadFile下载大于16M文件报错问题 2021-01-28 15:42:05 +08:00
kl
3531af4a46 更新版本到 3.3.1 2021-01-28 09:29:18 +08:00
范青锋
b2f6fb3a00 修复重复编码导致文档转图片预览失败的问题&编码规范
URLEncoder.encode(URLEncoder.encode(pdfFolder, uriEncoding).replaceAll("\+", "%20"), uriEncoding);
这里encode了两次,导致图片预览失败。
2021-01-23 14:09:16 +08:00
chenkailing
996da0862c 移除 Apache-common-text 包,采用 spring 内置的 HtmlUtils 处理 xss 问题 2021-01-23 13:13:29 +08:00
chenkailing
50dd7c1b83 移除 Apache-common-text 包,采用 spring 内置的 HtmlUtils 处理 xss 问题 2021-01-23 13:12:31 +08:00
hunterale
2dd067170b escaping of dangerous characters to prevent reflected xss 2021-01-22 12:08:06 +08:00
ale
e635ca86c5 escaping of dangerous characters 2021-01-22 12:08:06 +08:00
gitchenjh
8bd36e37a3 Merge pull request #204 from gitchenjh/master
修复:dwg文件预览时无法在jpg和pdf两种类型之间切换
2021-01-21 15:48:27 +08:00
陈精华
b3b2f7c407 修复:dwg文件预览时无法在jpg和pdf两种类型之间切换 2021-01-21 15:47:13 +08:00
dependabot[bot]
f1ad3d44ff Bump poi from 3.12 to 3.17 in /server
Bumps poi from 3.12 to 3.17.

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-18 13:37:56 +08:00
kl
ee6ff50244 解码url时,默认UTF-8编码 2021-01-18 13:36:45 +08:00
chenkailing
196741d5dc 加回 apache-commons-io 包依赖,office组件中有依赖,后续再统一吧 2021-01-09 17:08:05 +08:00
chenkailing
374c06472f 移除 apache-commons-io 包依赖,采用jodd的io工具替代 2021-01-09 15:39:01 +08:00
kl
12c85c60c7 XML文件预览支持切换纯文本模式 2020-12-31 13:28:25 +08:00
kl
4747ee93b2 修复类文本类型HTML文件预览的bug 2020-12-29 18:37:50 +08:00
kl
5ec53c4b33 指定Base64转码采用Apache Commons-code中的实现,修复base64部分jdk版本下出现的异常 2020-12-29 18:32:24 +08:00
kl
ee7f7f50cc 修复大小写文件类型后缀没通用匹配的问题 2020-12-29 09:29:16 +08:00
chenkailing
92869e8d6c 文本文件编码默认UTF-8输出到页面 2020-12-28 23:56:38 +08:00
kl
c66dda239f 采用apache-common-io包简化所有的文件下载io操作 2020-12-28 18:31:12 +08:00
kl
e927760c40 调整多图连续预览上下翻图的UI 2020-12-28 16:45:11 +08:00
kl
8783f9059a 修复压缩包内多图连续预览的bug 2020-12-28 16:45:11 +08:00
kl
12e1239267 前端模板抽象出通用的header,将水印等初始化内容挪到通用header里 2020-12-28 16:45:11 +08:00
kl
7c963193ef 更新simTxT文件预览UI风格 2020-12-28 14:54:42 +08:00
kl
bce9a624d7 更新XML文件预览UI风格,调整类文本预览架构,更方便扩展 2020-12-28 14:54:42 +08:00
kl
dac3606b4e 更新markdown文件预览UI风格 2020-12-28 14:54:42 +08:00
kl
eb00385d76 更新index接入演示界面UI风格 2020-12-28 13:36:40 +08:00
kl
986f562266 引入galimatias,解决不规范文件名导致文件下载异常 2020-12-28 11:43:27 +08:00
kl
11d0441ed4 加回漏掉的pdfjs 2020-12-28 11:22:59 +08:00
kl
ef46e2c51e 增强url base64解码失败时的提示信息 2020-12-28 11:22:59 +08:00
kl
0a3c03f18b 修复发行包运行时找不到日志目录的问题 2020-12-28 11:22:59 +08:00
chenkailing
7a7e1a1855 修复导包错误以及图片预览bug 2020-12-27 19:18:52 +08:00
chenkailing
f530f441d5 更新版本到3.3.0 2020-12-27 16:54:30 +08:00
chenkailing
10160e8104 添加2020年最后的发版信息 2020-12-27 16:42:03 +08:00
chenkailing
602e80ee9e 独立flv文件预览实现 2020-12-27 15:17:35 +08:00
chenkailing
9c83860e1b 抽象通用的预览异常接口实现 2020-12-27 14:48:07 +08:00
chenkailing
1f1970232b 精简util模块,ReturenResponse重构 2020-12-27 14:07:46 +08:00
chenkailing
594bd895ec 修复压缩包里文件再次预览失败的bug 2020-12-27 12:38:05 +08:00
chenkailing
486c09b24a 文件url采用base64加encodeURI双重编码,彻底解决各种奇葩文件名导致的下载异常 2020-12-27 01:46:12 +08:00
chenkailing
aaf396fbc8 忽略log目录 2020-12-26 19:28:45 +08:00
chenkailing
4e01d6f5f3 忽略file目录 2020-12-26 19:23:00 +08:00
chenkailing
342c391a9b 引入cpdetector解决文件编码识别问题 2020-12-26 19:23:00 +08:00
chenkailing
f2d929e6fa 修改Dockerfile跟随模块变动 2020-12-26 17:42:40 +08:00
chenkailing
41cdc227b3 调整项目模块,jodconverter-core重命名为office-plugin。jdocnverter-web重命名为server 2020-12-26 17:42:40 +08:00
chenkailing
0f4f1d580b 1、抽象整理FileType的获取逻辑
2、合理设置预览消费队列的线程数
2020-12-26 16:44:57 +08:00
chenkailing
37c37868a3 Office组件启动异步化,提速应用启动速度到5秒内 2020-12-26 02:32:42 +08:00
chenkailing
01218e4a5c 设置pdfbox兼容低版本jdk 2020-12-26 02:11:29 +08:00
chenkailing
f6d54902e9 移除tomcat,采用jetty Server 2020-12-26 02:03:45 +08:00
chenkailing
5a559aa868 修复图片预览bug,移除guava 2020-12-26 01:53:30 +08:00
chenkailing
9b0f381c06 1.office预览图片模式禁用图片放大效果,达到图片和pdf预览效果一致的体验 2020-12-26 01:00:20 +08:00
kl
c1802b2487 预览逻辑重构 2020-12-26 01:00:20 +08:00
kl
d4b11a4056 优化文本类型预览逻辑 2020-12-25 21:03:19 +08:00
kl
da1553920b 增强了xml的预览效果 2020-12-25 20:44:59 +08:00
kl
d787813bc6 新增配置项office.preview.switch.disabled,控制offic文件预览切换开关 2020-12-25 18:21:15 +08:00
dependabot[bot]
4a3886e41a Bump xstream from 1.4.6 to 1.4.15 in /jodconverter-web
Bumps [xstream](https://github.com/x-stream/xstream) from 1.4.6 to 1.4.15.
- [Release notes](https://github.com/x-stream/xstream/releases)
- [Commits](https://github.com/x-stream/xstream/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-25 17:01:12 +08:00
kl
cf1f833d60 新增markdown格式预览支持 2020-12-25 17:00:15 +08:00
陈精华
cb21952155 !19 兼容本地绝对路径文件获取(win、linux)
Merge pull request !19 from zhangxiaoxiao/master
2020-12-10 14:11:06 +08:00
gitchenjh
3498df0491 Merge pull request #159 from gitchenjh/master
添加QQ群-2群
2020-12-10 12:12:46 +08:00
陈精华
e3ebf1979f 添加QQ群-2群 2020-12-10 12:10:19 +08:00
13540823418
fb09a8c00f 兼容本地绝对路径文件读取,采用file标准协议读取文件 2020-12-10 11:47:22 +08:00
13540823418
4c708f3cbd 兼容本地绝对路径文件读取 2020-12-06 01:38:16 +08:00
kailing
e1035510df !16 修复部分乱码问题
Merge pull request !16 from 隔壁邻居王师傅/N/A
2020-08-31 13:49:53 +08:00
隔壁邻居王师傅
c466d0399c 修复部分乱码问题
由于复制winodws字库会导致run异常,可以直接安装相关中文字库来解决
2020-08-17 11:58:46 +08:00
陈精华
8b33a233dd !15 2.2.1版
Merge pull request !15 from 陈精华/master
2020-08-11 17:49:37 +08:00
陈精华
9e2962bb62 2.2.1版 2020-08-11 10:42:25 +08:00
陈精华
fc73deb3fd 修复上传到demo中的压缩文件及pdf预览异常 2020-08-11 10:42:01 +08:00
陈精华
40ac4b1eb9 !14 2.2.1迭代
Merge pull request !14 from 陈精华/master
2020-06-09 16:42:56 +08:00
陈精华
3d6da5f5a0 预览接口同时支持get和post请求,重新提交gitignore影响的目录文件 2020-06-09 16:35:11 +08:00
陈精华
7c4fc42247 2.2.1迭代,docker镜像底层使用ubuntu 2020-06-09 16:22:00 +08:00
陈精华
0c2a92080e !13 【开源贡献活动】修复电子发票预览图片方式正常pdf预览出现文字缺失异常 #I1I5SZ
Merge pull request !13 from 点蚊子熏烟/master
2020-06-08 14:07:36 +08:00
chenheng
b1fd13bcbb 【开源贡献活动】解决maven打包导致pdf.js bcmap异常问题,升级pdf.js到最新版本2.4.567 2020-06-05 16:34:59 +08:00
lidan
cd37ff4b41 支持 SimText 原样格式输出 2020-06-01 10:22:42 +08:00
陈精华
215e9f0f4a 2.2.0版 2020-05-20 08:44:30 +08:00
陈精华
26e147b426 更新文档&细节调整 2020-05-20 08:44:30 +08:00
陈精华
c7318c2b17 优化:PDF文件下载缓存 2020-05-20 08:44:30 +08:00
陈精华
c16116c7cd 优化:视频文件预览支持FTP 2020-05-20 08:44:30 +08:00
陈精华
1a4748bbec 优化:url特殊字符相关处理 2020-05-20 08:44:30 +08:00
陈精华
c0f7d60213 新增:更新日志 2020-05-18 15:55:26 +08:00
陈精华
bf83a0847d 优化:构建镜像使用阿里云yum源,加速构建 2020-05-18 15:55:26 +08:00
陈精华
7601d49795 修复:允许URL中出现|{}等字符,解决The valid characters are defined in RFC 7230 and RFC 3986问题 2020-05-18 15:55:26 +08:00
陈精华
1edf4d83f1 优化:重构代码 2020-05-18 15:55:26 +08:00
陈精华
f620c00785 优化:首页评论切换到Gitalk 2020-05-18 15:55:26 +08:00
陈精华
180e7bcb8a 优化:重构大量代码,修复异常 2020-05-18 15:55:26 +08:00
陈精华
8a52450629 优化:去除一种文件只允许上传一个提示 2020-05-18 15:55:26 +08:00
陈精华
a535ebfe1d 新功能点:新增配置是否可以下载转换完成的pdf文件 2020-05-18 15:55:26 +08:00
陈精华
3e80590a82 优化:默认启动水印 2020-05-18 15:55:26 +08:00
陈精华
5196536bb4 修复:修复预览ftp时,图片图片、pdf预览异常 2020-05-18 15:55:26 +08:00
陈精华
59ac8effc1 优化:添加日志 2020-05-18 15:55:26 +08:00
陈精华
9cc0267619 优化:允许上传多个同一类型文件 2020-05-18 15:55:26 +08:00
陈精华
a21f35c2b0 修复:删除文件时,也删除文件夹 2020-05-18 15:55:26 +08:00
陈精华
fde31cb327 新功能点:支持全局水印 2020-05-18 15:55:26 +08:00
陈精华
9c096605bb 修复:修复TrustHost静态注入问题 2020-05-18 15:55:26 +08:00
陈精华
b90e326eec 优化:移除localBaseUrl 2020-05-18 15:55:26 +08:00
陈精华
66e2acd063 优化:图片预览背景颜色和office相关预览背景颜色统一 2020-05-12 11:08:02 +08:00
陈精华
44165d655d 优化:修改历史遗留容易造成误解的方法名 2020-05-12 11:08:02 +08:00
陈精华
c9a6956b0d 优化:将前端所有CDN依赖放到本地,方便没有外网连接的用户使用 2020-05-12 11:08:02 +08:00
陈精华
9288564195 优化:去除pom文件多余properties 2020-05-12 11:08:02 +08:00
telami
9b8e7f812c 修复:预览图片时,点击周围会出现白屏 2020-05-07 09:03:40 +08:00
telami
3908f1be7e 修复:需求https://gitee.com/kekingcn/file-online-preview/issues/I14D4X,当使用nginx做代理时,配置了content-path和baseUrl时,访问view.html和getCorsFile会出现404 2020-04-29 09:04:37 +08:00
telami
15bd035304 修复:需求https://gitee.com/kekingcn/file-online-preview/issues/I14D4X,当使用nginx做代理时,配置了content-path和baseUrl时,访问view.html和getCorsFile会出现404 2020-04-29 09:04:37 +08:00
陈精华
e0b1cd76ca 修复:addTask异常 2020-04-14 11:22:07 +08:00
陈精华
2144b776b1 【新特性】支持限制预览源站点,保护预览服务不被滥用 2020-02-19 10:40:15 +08:00
陈精华
a8022df1d9 部分页面移动端样式 2020-02-19 10:40:15 +08:00
kl
a5d92bf905 Update .gitattributes 2020-02-10 15:51:43 +08:00
kl
81a18d07c3 Create .gitattributes 2020-02-10 15:47:24 +08:00
dependabot[bot]
86e5dcb23b Bump commons-compress from 1.18 to 1.19 in /jodconverter-web
Bumps commons-compress from 1.18 to 1.19.

Signed-off-by: dependabot[bot] <support@github.com>
2019-11-29 16:57:25 +08:00
陈精华
1339c09382 优化:调整异常页面提示文案 2019-11-29 16:52:58 +08:00
陈精华
01e310a6e7 优化:预览URL特殊字体使用Hutool解决方案 2019-11-29 16:52:58 +08:00
陈精华
a07c962867 优化:Office组件运行状态检测 2019-11-29 16:52:58 +08:00
陈精华
09b6964c0e 脚本:使用kkFileView站点下载OpenOffice安装文件,加速国内用户构建Docker镜像 2019-11-29 16:52:58 +08:00
陈精华
461030d34f 构建脚本:编译时包含本地jar依赖 2019-11-21 18:19:52 +08:00
陈精华
c1a7cd8c46 新功能点,加入CAD图纸.dwg文件预览 2019-11-21 17:11:36 +08:00
陈精华
5888c56f1d 优化:异常处理、异常提示 2019-11-21 17:11:36 +08:00
陈精华
0798b8d8a0 优化:删除无用代码、页面加header 2019-11-21 17:11:36 +08:00
陈精华
ae93d48b44 配置:默认指定缓存实现为JDK实现 2019-11-21 17:11:36 +08:00
陈精华
506a3ba2b3 优化:服务器无法通过外网访问本地下载时,使用内网IP下载 2019-11-21 17:11:36 +08:00
陈精华
12f197b623 构建脚本:使用kkFileView站点下载OpenOffice安装文件,加速国内用户构建Docker镜像 2019-11-21 17:11:36 +08:00
陈精华
2001b241ee 运行环境:CentOS预先安装OpenOffice相关依赖 2019-11-21 17:11:36 +08:00
陈精华
7911edec4b 修复:文本文档首次预览后缓存文件未清理问题 2019-11-06 16:53:39 +08:00
陈精华
7ea70bf422 优化:图片模式下图片url使用baseUrl 2019-11-06 16:53:39 +08:00
陈精华
b1fdbd26a3 新功能点:全部能识别的纯文本直接预览,不用再转跳下载(.md、.java、.py等浏览器不认识的后缀名) 2019-10-25 15:16:25 +08:00
陈精华
fa7241bd4e 新功能点:所有配置项支持从环境变量里读取,方便Docker镜像部署 2019-10-25 15:16:25 +08:00
陈精华
8fdf462c6c 新功能点:缓存清理时间cron表达式支持自定义 link #I1147X 2019-10-25 15:16:25 +08:00
陈精华
f7c7411bcf fixup! 优化:目录调整,符合maven规范;maven编译指定.sh脚本换行符为unix换行 2019-10-25 15:16:25 +08:00
陈精华
845cb2e657 修复:参数包含特殊字符时url解码失败 2019-10-25 15:16:25 +08:00
陈精华
a4bfde68bd 优化:目录调整,符合maven规范;maven编译指定.sh脚本换行符为unix换行 2019-10-25 15:16:25 +08:00
陈精华
19d1ba6cf9 优化:(内部)移除为pdf文档提供base64缩略图 2019-10-25 15:16:25 +08:00
陈精华
1060bdd00f 新功能点:支持base url配置(主要用于nginx反向代理等) 2019-10-17 11:36:43 +08:00
陈精华
8c2fb2bdee 优化:默认启用缓存 2019-10-17 11:36:43 +08:00
陈精华
0fe75387eb 优化:启动脚本加入官网链接,点star推广等文案 close #I1148F 2019-09-16 11:49:49 +08:00
陈精华
fbea49e54f 优化:加入查看日志脚本 2019-09-16 11:49:49 +08:00
陈精华
41a72798d9 优化:去除可能导致文件不更新的缓存 2019-09-16 11:49:49 +08:00
陈精华
03cc185085 修复:压缩包中文件名有空格异常 2019-09-16 11:49:49 +08:00
陈精华
bfbd8ee25e 新功能点:(内部)为pdf文档提供base64缩略图 2019-09-10 18:24:06 +08:00
陈精华
f3f36169ff 优化:压缩文件名支持有特殊字符 2019-09-10 18:24:06 +08:00
陈精华
2df88544d3 修复:macOS下office组件默认路径错误 2019-09-10 18:24:06 +08:00
陈精华
6b744d77c7 修复:RocksDB缓存实现压缩包图片url缓存失效 2019-09-10 18:24:06 +08:00
doras
ba57dedebb "加入是否启用缓存配置项"后,excel转成的html文件不再转换编码,修复因此出现的乱码问题 2019-08-26 11:17:37 +08:00
陈精华
affd5b3057 图片和pdf预览模式切换按钮大小调整 2019-08-23 18:18:37 +08:00
陈精华
30c3128995 修复压缩文件中文fileKey未编码 link #I111PD 2019-08-23 18:18:37 +08:00
陈精华
b003a05775 加入是否启用缓存配置项 2019-08-23 18:18:37 +08:00
陈精华
98ec3d7dab 首页预览打开新页面 2019-08-23 18:18:37 +08:00
陈精华
69e23dbb99 shutdown脚本更新 2019-08-23 18:18:37 +08:00
陈精华
47bda1023a 修复Chrome76+删除弹出新窗口 2019-08-23 18:18:37 +08:00
陈精华
fd538a74af 中文语言环境 2019-08-23 18:18:37 +08:00
陈精华
300d213a7a cdn资源不指定http/https 2019-08-23 18:18:37 +08:00
陈精华
4c0a70f300 2.2.0迭代 2019-08-23 18:18:37 +08:00
陈精华
8798d344b6 2.1.2版 2019-07-30 16:31:53 +08:00
陈精华
63e62ab57b pdf.js使用里面一个bug 2019-07-30 16:31:53 +08:00
陈精华
9a027674ac 演示首页兼容IE 2019-07-30 16:31:53 +08:00
1045485954@qq.com
e4407467dd IE兼容性问题,目前已兼容到IE9 2019-07-17 09:03:32 +08:00
陈精华
551eeb0390 2.1.1版 2019-07-09 10:46:21 +08:00
陈精华
11d6ad1ed3 修复文件下载流URL参数中包含中文URL编码不正确导致HTTP-400异常 2019-07-09 10:46:21 +08:00
陈精华
e57db6925c 修复config.js 404问题 2019-07-09 10:46:21 +08:00
陈精华
87096364d8 首页示例修改、首页更新记录 2019-07-09 10:46:21 +08:00
陈精华
ad8027a7d0 2.1.1迭代 2019-07-09 10:46:21 +08:00
陈精华
9786fa8275 2.1.0版 2019-06-19 15:24:24 +08:00
陈精华
37762cf034 支持FTP文件地址作为预览源url 2019-06-19 15:24:24 +08:00
陈精华
a78f1e5f8e Docker构建 2019-06-19 15:24:24 +08:00
陈精华
440b8030e0 新增Docker构建 2019-06-19 15:24:24 +08:00
陈精华
fb7cdfbef7 支持http/https文件流作为预览源url 2019-06-19 15:24:24 +08:00
陈精华
cf1ee9c631 支持自动清理预览文件及缓存 2019-06-19 15:24:24 +08:00
陈精华
13123f8f9d addTask转码优化 2019-06-19 15:24:24 +08:00
陈精华
189bc3965d 2.1.0迭代 2019-06-19 15:24:24 +08:00
kl
0aa7444dba Update pom.xml 2019-05-30 09:08:08 +08:00
陈精华
628efec6bd 2.0.2版 2019-05-23 09:53:37 +08:00
陈精华
6d0846a551 修复rocksdb缓存只缓存一条数据问题 2019-05-23 09:53:37 +08:00
陈精华
41d9015023 支持flv视频预览 2019-05-23 09:53:37 +08:00
陈精华
3f40b60c64 支持7z文件预览 2019-05-23 09:53:37 +08:00
陈精华
f244054462 优化读取动态配置 2019-05-23 09:53:37 +08:00
陈精华
37fbc98827 2.0.2迭代 2019-05-23 09:53:37 +08:00
陈精华
795cf3393e 2.0.1版 2019-05-09 15:20:15 +08:00
陈精华
70323b8ee3 pdf预览支持url中有中文或特殊字符 2019-05-09 15:20:15 +08:00
陈精华
67686e99f0 修复excel预览网页乱码问题 2019-05-09 15:20:15 +08:00
陈精华
90554462dc pdf默认预览模式也从配置文件中取,和word ppt统一 2019-05-09 15:20:15 +08:00
kl
ba3084d698 Update README.md 2019-05-09 09:18:54 +08:00
陈精华
3813f75f65 2.0版本 2019-05-07 10:16:26 +08:00
陈精华
a663e99bcd 背景色统一 2019-04-28 13:55:40 +08:00
陈精华
d517ab4e6f 替换pdf和图片预览相互转跳按钮图标 2019-04-28 13:55:40 +08:00
陈精华
29726c11a3 PDF预览也支持图片模式和查看大图 2019-04-28 13:55:40 +08:00
陈精华
336a18ade7 office预览只有PDF转图片 2019-04-26 15:35:43 +08:00
陈精华
53814fe6ab office图片&PDF预览背景色统一 2019-04-26 14:54:09 +08:00
陈精华
50fb586e6f office图片预览打开大图新开窗口 2019-04-26 14:25:35 +08:00
陈精华
a49ee9d726 图片预览可在viewjs中大图预览&翻页 2019-04-26 14:15:08 +08:00
陈精华
ae40d0233b 加入shutdown脚本 2019-04-26 14:15:08 +08:00
陈精华
8f7c13850e 修复调试时只打开jodconverter-web目录里读不到配置文件异常 2019-04-26 14:15:08 +08:00
陈精华
b4d3419797 word、ppt文档新增图片预览模式 2019-04-26 09:04:34 +08:00
陈精华
68aa5db66b RocksDB缓存实现,并更换默认实现为RocksDB 2019-04-23 11:40:44 +08:00
陈精华
7e8de7c754 解压相关 2019-04-18 16:14:58 +08:00
陈精华
f989fbf9c9 优先使用自定义office.home 2019-04-18 11:53:59 +08:00
陈精华
af8ddc10da 文件转换编码默认根据操作系统获取,变为可选配置
文本和多媒体类型添加默认值,变为可选配置
2019-04-17 13:32:14 +08:00
陈精华
3713e6e550 MacOS下office安装路径更新 2019-04-17 13:32:14 +08:00
陈精华
4a7ba07df1 file.Dir变为选配置添加其默认值 2019-04-16 22:10:48 +08:00
陈精华
b625381de3 脚本修改 2019-04-16 16:11:22 +08:00
陈精华
0968ac774a 脚本修改 2019-04-16 16:11:22 +08:00
陈精华
0db6b23bf7 Linux下集成OpenOffice 2019-04-16 16:11:22 +08:00
陈精华
6dc10e8df4 解决tar包office目录层级过长问题 2019-04-16 16:11:22 +08:00
陈精华
9976f0ae99 dev和release区分开 2019-04-16 16:11:22 +08:00
陈精华
55537d3a25 Windows下集成OpenOffice 2019-04-16 16:11:22 +08:00
陈精华
02e116fd8a 完善启动脚本 2019-04-16 16:11:22 +08:00
陈精华
5af3a97720 支持部分配置在运行时动态改变 2019-04-16 16:11:22 +08:00
陈精华
bf08c2c26f 更新记录 2019-04-16 16:11:22 +08:00
陈精华
236ed405f2 启动脚本&配置文件 2019-04-16 16:11:22 +08:00
陈精华
0fb02e3ccb 打包为zip和tar.gz包 2019-04-16 16:11:22 +08:00
陈精华
3dd6609fd6 缓存及队列实现抽象,提供JDK和REDIS两种实现 2019-04-16 16:11:22 +08:00
kl
dd876792c7 Update pom.xml 2018-10-22 11:34:30 +08:00
kl
3b79ef31e8 Update pom.xml
更新jar版本依赖,老版本有安全风险
2018-10-17 09:09:02 +08:00
kl
deb3abcac1 Merge remote-tracking branch 'origin/master' 2018-03-26 17:06:42 +08:00
kl
1c1a945959 使用畅言替换友言社评服务 2018-03-26 17:03:20 +08:00
duanmuxiangxiao
d1c5211d03 viewerjs版本升级release 1.0.0-rc.1 2018-03-26 16:48:02 +08:00
duanmuxiangxiao
d73bc3a031 图片轮播,修改图片切换按钮样式 2018-03-26 13:39:54 +08:00
15899 changed files with 9401775 additions and 102175 deletions

5
.gitattributes vendored Normal file
View File

@@ -0,0 +1,5 @@
*.css linguist-language=java
*.less linguist-language=java
*.js linguist-language=java
*.html linguist-language=java
*.* linguist-language=java

5
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: "Security Report / 安全漏洞报告"
url: "https://github.com/kekingcn/kkFileView/security/advisories/new"
about: "For sensitive security issues, please use private security report. / 涉及敏感安全问题请使用私密安全报告。"

View File

@@ -0,0 +1,76 @@
name: "Feature Request / 功能建议"
description: "Propose a new feature with clear use case and acceptance criteria. / 提交功能建议,请明确场景与验收标准。"
title: "[FEATURE] "
labels: ["type/feature", "priority/p2", "status/needs-info"]
body:
- type: markdown
attributes:
value: |
Thanks for your idea! / 感谢你的建议
Please provide concrete business scenarios and the expected behavior.
请尽量提供明确业务场景和期望行为便于评估优先级与实现方案
For urgent production issues, you can use our Knowledge Planet channel for faster processing:
https://wx.zsxq.com/group/48844125114258
如为线上紧急问题可通过知识星球渠道加速处理
https://wx.zsxq.com/group/48844125114258
- type: textarea
id: background
attributes:
label: "Background / 背景"
description: "What problem are you trying to solve? / 你要解决什么问题?"
placeholder: "Describe current pain points... / 描述当前痛点..."
validations:
required: true
- type: textarea
id: proposal
attributes:
label: "Proposal / 建议方案"
description: "What do you expect kkFileView to support? / 期望 kkFileView 支持什么?"
placeholder: "Describe expected feature behavior... / 描述期望功能行为..."
validations:
required: true
- type: textarea
id: use_case
attributes:
label: "Use Case / 使用场景"
description: "Provide 1-3 concrete scenarios. / 提供 1-3 个具体场景"
placeholder: |
Scenario 1:
Scenario 2:
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: "Alternatives / 备选方案"
description: "What alternatives have you considered? / 是否考虑过替代方案?"
placeholder: "Existing workaround or alternative... / 当前替代做法..."
validations:
required: false
- type: textarea
id: acceptance
attributes:
label: "Acceptance Criteria / 验收标准"
description: "How do we know this feature is done? / 如何判断该功能完成?"
placeholder: |
- [ ] Criterion 1
- [ ] Criterion 2
validations:
required: true
- type: checkboxes
id: checklist
attributes:
label: "Checklist / 提交前检查"
options:
- label: "I have searched existing issues and did not find a duplicate feature request. / 我已搜索现有 issue未发现重复功能建议"
required: true
- label: "I provided concrete use cases and expected behavior. / 我已提供具体使用场景和期望行为"
required: true

121
.github/ISSUE_TEMPLATE/issue-report.yml vendored Normal file
View File

@@ -0,0 +1,121 @@
name: "Issue Report / 问题反馈"
description: "Please provide complete required information to help us reproduce and follow up. / 请完整填写必填信息,便于复现与跟进。"
title: "[ISSUE] "
labels: ["status/needs-info"]
body:
- type: markdown
attributes:
value: |
Thanks for your report! / 感谢反馈
**Please fill in all required fields.**
**请完整填写所有必填项**
Incomplete issues may be closed and asked to resubmit.
信息不完整的问题可能会被关闭并要求重新提交
For urgent production issues, you can use our Knowledge Planet channel for faster processing:
https://wx.zsxq.com/group/48844125114258
如为线上紧急问题可通过知识星球渠道加速处理
https://wx.zsxq.com/group/48844125114258
- type: dropdown
id: issue_type
attributes:
label: "Issue Type / 问题类型"
description: "Select the closest type. / 请选择最接近的问题类型"
options:
- "Bug / 缺陷"
- "Performance / 性能问题"
- "Security / 安全问题"
- "Question / 使用咨询"
validations:
required: true
- type: input
id: kkfileview_version
attributes:
label: "kkFileView Version / kkFileView 版本"
placeholder: "e.g. 4.4.0"
validations:
required: true
- type: input
id: deploy_mode
attributes:
label: "Deployment Mode / 部署方式"
description: "jar / docker / k8s / source, etc. / jar / docker / k8s / 源码部署等"
placeholder: "e.g. docker"
validations:
required: true
- type: textarea
id: environment
attributes:
label: "Environment / 环境信息"
description: "OS, JDK, LibreOffice/OpenOffice, browser, reverse proxy, etc. / 操作系统、JDK、Office组件、浏览器、反向代理等"
placeholder: |
- OS:
- JDK:
- LibreOffice/OpenOffice:
- Browser:
- Proxy (Nginx/Ingress):
validations:
required: true
- type: textarea
id: reproduce_steps
attributes:
label: "Steps to Reproduce / 复现步骤"
description: "Provide clear, minimal, reproducible steps. / 提供清晰、最小可复现步骤"
placeholder: |
1) ...
2) ...
3) ...
validations:
required: true
- type: textarea
id: expected_result
attributes:
label: "Expected Result / 期望结果"
placeholder: "What should happen? / 期望实际应该出现什么结果?"
validations:
required: true
- type: textarea
id: actual_result
attributes:
label: "Actual Result / 实际结果"
placeholder: "What happened instead? / 实际发生了什么?"
validations:
required: true
- type: textarea
id: logs
attributes:
label: "Logs & Screenshots / 日志与截图"
description: "Paste key logs/error stack and attach screenshots (mask sensitive data). / 粘贴关键日志或异常堆栈,并上传截图(请脱敏)"
render: shell
validations:
required: true
- type: textarea
id: sample_file
attributes:
label: "Sample File / 样例文件(可选)"
description: "If possible, provide a minimal sample file or reproducible URL (desensitized). / 如可提供,请附最小样例文件或可复现 URL脱敏"
validations:
required: false
- type: checkboxes
id: checklist
attributes:
label: "Checklist / 提交前检查"
options:
- label: "I have searched existing issues and did not find a duplicate. / 我已搜索现有 issue未发现重复问题"
required: true
- label: "I can reproduce this issue on the stated version/environment. / 我可在上述版本与环境复现该问题"
required: true
- label: "I have masked sensitive information in logs/screenshots. / 我已对日志与截图中的敏感信息做脱敏处理"
required: true

View File

@@ -0,0 +1,78 @@
name: Auto Close Old Issues (1y)
on:
schedule:
# Daily at 02:20 UTC
- cron: '20 2 * * *'
workflow_dispatch:
permissions:
issues: write
jobs:
close_old_issues:
runs-on: ubuntu-latest
steps:
- name: Close issues older than 1 year
uses: actions/github-script@v7
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const now = new Date();
const cutoff = new Date(now.getTime() - 365 * 24 * 60 * 60 * 1000);
const closeComment = ` Issue 已超过 1 年未活跃为便于维护当前问题队列先做关闭处理\n\n如该问题在最新版本仍存在欢迎直接 **Reopen** Issue或新建 Issue 并关联本单并补充\n1. 版本与部署方式\n2. 最小复现步骤\n3. 关键日志/截图请脱敏\n\n我们会优先跟进`;
let page = 1;
let processed = 0;
while (true) {
const { data: issues } = await github.rest.issues.listForRepo({
owner,
repo,
state: 'open',
per_page: 100,
page,
sort: 'created',
direction: 'asc'
});
if (!issues.length) break;
for (const issue of issues) {
// skip pull requests
if (issue.pull_request) continue;
const createdAt = new Date(issue.created_at);
if (createdAt > cutoff) {
// list is sorted asc by created time; remaining items are newer
core.info('Reached issues newer than cutoff, stop scanning.');
return;
}
try {
await github.rest.issues.createComment({
owner,
repo,
issue_number: issue.number,
body: closeComment,
});
await github.rest.issues.update({
owner,
repo,
issue_number: issue.number,
state: 'closed',
});
processed += 1;
core.info(`Closed #${issue.number}`);
} catch (e) {
core.warning(`Failed to close #${issue.number}: ${e.message}`);
}
}
page += 1;
}
core.info(`Done. Closed ${processed} old issues.`);

View File

@@ -0,0 +1,34 @@
name: Copilot Issue Auto Comment
on:
issues:
types: [opened]
workflow_dispatch:
permissions:
issues: write
jobs:
copilot_auto_comment:
runs-on: ubuntu-latest
steps:
- name: Ask Copilot to triage issue automatically
uses: actions/github-script@v7
with:
script: |
const issue = context.payload.issue;
if (!issue) return;
const owner = context.repo.owner;
const repo = context.repo.repo;
const body = `@copilot 请自动分诊并直接给出可执行建议无需人工先介入\n\n- 先判断类型Bug / Performance / Security / Question / Feature\n- 检查 Issue 信息是否完整版本部署方式复现步骤日志\n- 若信息不完整请直接按模板列出缺失项并引导补充\n- 若信息较完整请给出下一步排查建议与最小复现建议\n- 若判断为已知问题或已修复请给出对应版本/修复方向\n\nIssue #${issue.number}\n标题${issue.title}\n链接${issue.html_url}\n\n---\n\n补充说明 / Support Notice:\n- GitHub Issues 会持续跟进处理 / We will continue to follow up through GitHub Issues.\n- 如为线上紧急问题可通过知识星球渠道加速处理 / For urgent production issues, you can use our Knowledge Planet channel for faster processing:\n https://wx.zsxq.com/group/48844125114258`;
await github.rest.issues.createComment({
owner,
repo,
issue_number: issue.number,
body,
});
core.info(`Copilot prompt comment posted to #${issue.number}`);

52
.github/workflows/maven.yml vendored Normal file
View File

@@ -0,0 +1,52 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Java CI with Maven
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin' # 使用 Eclipse Temurin (AdoptOpenJDK 的继任者)
cache: 'maven'
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn -B package -Dmaven.test.skip=true --file pom.xml
- name: Upload Linux distribution package
if: success()
uses: actions/upload-artifact@v4
with:
name: kkfileview-linux
path: server/target/*.tar.gz
retention-days: 7
- name: Upload Windows distribution package
if: success()
uses: actions/upload-artifact@v4
with:
name: kkfileview-windows
path: server/target/*.zip
retention-days: 7

118
.github/workflows/nightly-e2e.yml vendored Normal file
View File

@@ -0,0 +1,118 @@
name: Nightly E2E Full
on:
schedule:
- cron: '30 18 * * *' # 02:30 Asia/Shanghai
workflow_dispatch:
permissions:
contents: read
jobs:
e2e-nightly:
runs-on: ubuntu-latest
timeout-minutes: 50
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
cache: maven
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: tests/e2e/package-lock.json
- name: Setup Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install LibreOffice + zip
run: |
sudo apt-get update
sudo apt-get install -y libreoffice zip
- name: Setup Python deps for office fixtures
run: |
python -m pip install --upgrade pip
pip install -r tests/e2e/requirements.txt
- name: Build kkFileView
run: mvn -q -pl server -DskipTests package
- name: Install E2E deps
working-directory: tests/e2e
run: |
npm ci
npx playwright install --with-deps chromium
- name: Start fixture server
run: |
cd tests/e2e/fixtures
python3 -m http.server 18080 > /tmp/fixture-server.log 2>&1 &
- name: Start kkFileView
run: |
JAR_PATH=$(ls server/target/kkFileView-*.jar | head -n 1)
nohup env KK_TRUST_HOST='*' KK_NOT_TRUST_HOST='10.*,172.16.*,192.168.*' java -jar "$JAR_PATH" > /tmp/kkfileview.log 2>&1 &
- name: Wait for services
run: |
fixture_ready=false
for i in {1..60}; do
if curl -fsS http://127.0.0.1:18080/sample.txt >/dev/null; then
fixture_ready=true
break
fi
sleep 1
done
if [ "$fixture_ready" != "true" ]; then
echo "Error: fixture server did not become ready within 60 seconds." >&2
exit 1
fi
kkfileview_ready=false
for i in {1..120}; do
if curl -fsS http://127.0.0.1:8012/ >/dev/null; then
kkfileview_ready=true
break
fi
sleep 1
done
if [ "$kkfileview_ready" != "true" ]; then
echo "Error: kkFileView service did not become ready within 120 seconds." >&2
exit 1
fi
- name: Run nightly E2E suites
working-directory: tests/e2e
env:
KK_BASE_URL: http://127.0.0.1:8012
FIXTURE_BASE_URL: http://127.0.0.1:18080
E2E_MAX_PREVIEW_MS: 20000
run: npm run test:ci
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v4
with:
name: nightly-playwright-report
path: tests/e2e/playwright-report
- name: Upload service logs
if: always()
uses: actions/upload-artifact@v4
with:
name: nightly-e2e-service-logs
path: |
/tmp/kkfileview.log
/tmp/fixture-server.log

100
.github/workflows/pr-e2e-mvp.yml vendored Normal file
View File

@@ -0,0 +1,100 @@
name: PR E2E MVP
on:
pull_request:
branches: [master]
workflow_dispatch:
permissions:
contents: read
jobs:
e2e-mvp:
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
cache: maven
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: tests/e2e/package-lock.json
- name: Setup Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install LibreOffice + zip
run: |
sudo apt-get update
sudo apt-get install -y libreoffice zip
- name: Setup Python deps for office fixtures
run: |
python -m pip install --upgrade pip
pip install -r tests/e2e/requirements.txt
- name: Build kkFileView
run: mvn -q -pl server -DskipTests package
- name: Install E2E deps
working-directory: tests/e2e
run: |
npm install
npx playwright install --with-deps chromium
- name: Start fixture server
run: |
cd tests/e2e/fixtures
python3 -m http.server 18080 > /tmp/fixture-server.log 2>&1 &
- name: Start kkFileView
run: |
JAR_PATH=$(ls server/target/kkFileView-*.jar | head -n 1)
nohup env KK_TRUST_HOST='*' KK_NOT_TRUST_HOST='10.*,172.16.*,192.168.*' java -jar "$JAR_PATH" > /tmp/kkfileview.log 2>&1 &
- name: Wait for services
run: |
for i in {1..60}; do
curl -fsS http://127.0.0.1:18080/sample.txt >/dev/null && break
sleep 1
done
for i in {1..120}; do
curl -fsS http://127.0.0.1:8012/ >/dev/null && break
sleep 1
done
- name: Run E2E
working-directory: tests/e2e
env:
KK_BASE_URL: http://127.0.0.1:8012
FIXTURE_BASE_URL: http://127.0.0.1:18080
run: npm test
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: tests/e2e/playwright-report
- name: Upload service logs
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-service-logs
path: |
/tmp/kkfileview.log
/tmp/fixture-server.log

22
.gitignore vendored
View File

@@ -17,25 +17,15 @@ target/
### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
/*.iml
**/target/
.classpath
.project
**/.settings
**/bin/
**/build/
**/.externalToolBuilders/
*.iml
**/.idea/
**/disconf
**/rpc.properties
/producer/tmp
/.temfile
.temfile
convertedFile/
### VS Code ###
.vscode/
.DS_Store
server/src/main/cache/
server/src/main/file/

View File

@@ -0,0 +1,31 @@
version: '1.0'
name: master-pipeline
displayName: MasterPipeline
stages:
- stage:
name: compile
displayName: 编译
steps:
- step: build@maven
name: build_maven
displayName: Maven 构建
# 支持67891011六个版本
jdkVersion: 8
# 支持2.2.13.2.53.3.93.5.23.5.33.5.43.6.13.6.3八个版本
mavenVersion: 3.6.3
# 构建命令
commands:
- mvn -B clean package -Dmaven.test.skip=true
# 非必填字段开启后表示将构建产物暂存但不会上传到制品库中7天后自动清除
artifacts:
# 构建产物名字作为产物的唯一标识可向下传递支持自定义默认为BUILD_ARTIFACT在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
- name: BUILD_ARTIFACT
# 构建产物获取路径是指代码编译完毕之后构建物的所在路径如通常jar包在target目录下当前目录为代码库根目录
path:
- ./server/target/kkFileView-*.tar.gz
- ./server/target/kkFileView-*.zip
triggers:
push:
branches:
include:
- master

4
Dockerfile Normal file
View File

@@ -0,0 +1,4 @@
FROM keking/kkfileview-base:4.4.0
ADD server/target/kkFileView-*.tar.gz /opt/
ENV KKFILEVIEW_BIN_FOLDER=/opt/kkFileView-4.4.0/bin
ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-Dspring.config.location=/opt/kkFileView-4.4.0/config/application.properties","-jar","/opt/kkFileView-4.4.0/bin/kkFileView-4.4.0.jar"]

430
README.cn.md Normal file
View File

@@ -0,0 +1,430 @@
# kkFileView
文档在线预览项目解决方案项目使用流行的spring boot搭建易上手和部署万能的文件预览开源项目基本支持主流文档格式预览
1. 支持 doc, docx, xls, xlsx, xlsm, ppt, pptx, csv, tsv, dotm, xlt, xltm, dot, dotx,xlam, xla ,pages Office 办公文档
2. 支持 wps, dps, et, ett, wpt 等国产 WPS Office 办公文档
3. 支持 odt, ods, ots, odp, otp, six, ott, fodt, fods 等OpenOfficeLibreOffice 办公文档
4. 支持 vsd, vsdx Visio 流程图文件
5. 支持 wmf, emf Windows 系统图像文件
6. 支持 psd ,eps Photoshop 软件模型文件
7. 支持 pdf ,ofd, rtf 等文档
8. 支持 xmind 软件模型文件
9. 支持 bpmn 工作流文件
10. 支持 eml 邮件文件
11. 支持 epub 图书文档
12. 支持 obj, 3ds, stl, ply, gltf, glb, off, 3dm, fbx, dae, wrl, 3mf, ifc, brep, step, iges, fcstd, bim 3D 模型文件
13. 支持 dwg, dxf, dwf, iges , igs, dwt, dng, ifc, dwfx, stl, cf2, plt CAD 模型文件
14. 支持 txt, xml(渲染), xbrl(渲染), md(渲染), java, php, py, js, css 等所有纯文本
15. 支持 zip, rar, jar, tar, gzip, 7z 等压缩包
16. 支持 jpg, jpeg, png, gif, bmp, ico, jfif, webp 等图片预览翻转缩放镜像
17. 支持 tif, tiff 图信息模型文件
18. 支持 tga 图像格式文件
19. 支持 svg 矢量图像格式文件
20. 支持 mp3,wav,mp4,flv 等音视频格式文件
21. 支持 avi,mov,rm,webm,ts,rm,mkv,mpeg,ogg,mpg,rmvb,wmv,3gp,ts,swf 等视频格式转码预览
22. 支持 dcm 等医疗数位影像预览
23. 支持 drawio 绘图预览
> 基于当前良好的架构模式支持的文件类型在进一步丰富中
### 项目特性
- 使用 spring-boot 开发预览服务搭建部署非常简便
- rest 接口提供服务跨语言跨平台特性(java,php,python,go,php....)都支持应用接入简单方便
- 抽象预览服务接口方便二次开发非常方便添加其他类型文件预览支持
- 最最重要 Apache 协议开源代码 pull 下来想干嘛就干嘛
### 官网及文档
地址[https://kkview.cn](https://kkview.cn/)
### 在线体验
> 请善待公共服务会不定时停用
地址[https://file.kkview.cn](https://file.kkview.cn)
### 项目文档Project documentation
1. 详细使用文档https://kkview.cn/zh-cn/docs/home.html
### 联系我们加入组织
> 我们会用心回答解决大家在项目使用中的问题也请大家在提问前至少 Google baidu 珍爱生命远离无效的交流沟通
<img src="./doc/gitee星球.png/" width="60%">
### 文档预览效果
#### 1. 文本预览
支持所有类型的文本文档预览 由于文本文档类型过多无法全部枚举默认开启的类型如下 txt,html,htm,asp,jsp,xml,xbrl,json,properties,md,gitignore,log,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd
文本预览效果如下
![文本预览效果如下](./doc/img/preview/preview-text.png)
#### 2. 图片预览
支持jpgjpegpnggif等图片预览翻转缩放镜像预览效果如下
![图片预览](./doc/img/preview/preview-image.png)
#### 3. word文档预览
支持docdocx文档预览word预览有两种模式一种是每页word转为图片预览另一种是整个word文档转成pdf再预览pdf两种模式的适用场景如下
* 图片预览word文件大前台加载整个pdf过慢
* pdf预览内网访问加载pdf快
图片预览模式预览效果如下
![word文档预览1](./doc/img/preview/preview-doc-image.png)
pdf预览模式预览效果如下
![word文档预览2](./doc/img/preview/preview-doc-pdf.png)
#### 4. ppt文档预览
支持pptpptx文档预览和word文档一样有两种预览模式
图片预览模式预览效果如下
![ppt文档预览1](./doc/img/preview/preview-ppt-image.png)
pdf预览模式预览效果如下
![ppt文档预览2](./doc/img/preview/preview-ppt-pdf.png)
#### 5. pdf文档预览
支持pdf文档预览和word文档一样有两种预览模式
图片预览模式预览效果如下
![pdf文档预览1](./doc/img/preview/preview-pdf-image.png)
pdf预览模式预览效果如下
![pdf文档预览2](./doc/img/preview/preview-pdf-pdf.png)
#### 6. excel文档预览
支持xlsxlsx文档预览预览效果如下
![excel文档预览](./doc/img/preview/preview-xls.png)
#### 7. 压缩文件预览
支持zip,rar,jar,tar,gzip等压缩包预览效果如下
![压缩文件预览1](./doc/img/preview/preview-zip.png)
可点击压缩包中的文件名直接预览文件预览效果如下
![压缩文件预览2](./doc/img/preview/preview-zip-inner.png)
#### 8. 多媒体文件预览
理论上支持所有的视频音频文件由于无法枚举所有文件格式默认开启的类型如下
mp3,wav,mp4,flv
视频预览效果如下
![多媒体文件预览1](./doc/img/preview/preview-video.png)
音频预览效果如下
![多媒体文件预览2](./doc/img/preview/preview-audio.png)
#### 9. CAD文档预览
支持CAD dwg文档预览和word文档一样有两种预览模式
图片预览模式预览效果如下
![cad文档预览1](./doc/img/preview/preview-cad-image.png)
pdf预览模式预览效果如下
![cad文档预览2](./doc/img/preview/preview-cad-pdf.png)
#### 10. Excel文件纯前端渲染效果
![Excel文件纯前端渲染效果](./doc/img/preview/preview-xlsx-web.png)
#### 11. 流程图bpmn文件预览效果
![流程图bpmn文件预览效果](./doc/img/preview/preview-bpmn.png)
#### 12. 3D模型文件预览效果
![3D模型文件预览效果](./doc/img/preview/preview-3ds.png)
#### 13. dcm医疗数位影像文件预览效果
![dcm医疗数位影像文件预览效果](./doc/img/preview/preview-dcm.png)
#### 14. drawio流程图预览效果
![drawio流程图预览效果](./doc/img/preview/preview-drawio.png)
考虑说明篇幅原因就不贴其他格式文件的预览效果了感兴趣的可以参考下面的实例搭建下
### 快速开始
> 项目使用技术
- spring boot [spring boot开发参考指南](http://www.kailing.pub/PdfReader/web/viewer.html?file=springboot)
- freemarker
- redisson
- jodconverter
> 依赖外部环境
- redis (可选默认不用)
- OpenOffice 或者 LibreOffice( Windows 下已内置Linux 脚本启动模式会自动安装Mac OS 下需要手动安装)
1. 第一步pull 项目 https://github.com/kekingcn/file-online-preview.git
3. 第二步运行 ServerMain main 方法服务启动后访问 http://localhost:8012/
会看到如下界面代表服务启动成功
![输入图片说明](https://gitee.com/uploads/images/2017/1213/100221_ea15202e_492218.png "屏幕截图.png")
### 历史更新记录
#### > 2025年01月16日v4.4.0 版本发布
### 新增功能
1. xlsx 新增支持打印功能
2. 配置文件新增启用 GZIP 压缩
3. CAD 格式新增支持转换成 SVG TIF 格式新增超时结束线程管理
4. 新增删除文件使用验证码校验
5. 新增 xbrl 格式预览支持
6. PDF 预览新增控制签名绘图插图控制搜索定位页码定义显示内容等功能
7. 新增 CSV 格式前端解析支持
8. 新增 ARM64 下的 Docker 镜像支持
9. 新增 Office 预览支持转换超时属性设置功能
10. 新增预览文件 host 黑名单机制
### 优化
1. 优化 OFD 移动端预览 页面不自适应
2. 更新 xlsx 前端解析组件加速解析速度
3. 升级 CAD 组件
4. office 功能调整支持批注转换页码限制生成水印等功能
5. 升级 markdown 组件
6. 升级 dcm 解析组件
7. 升级 PDF.JS 解析组件
8. 更换视频播放插件为 ckplayer
9. tif 解析更加智能化支持被修改的图片格式
10. 针对大小文本文件检测字符编码的正确率处理并发隐患
11. 重构下载文件的代码新增通用的文件服务器认证访问的设计
12. 更新 bootstrap 组件并精简掉不需要的文件
13. 更新 epub 版本优化 epub 显示效果
14. 解决定时清除缓存时对于多媒体类型文件只删除了磁盘缓存文件
15. 自动检测已安装 Office 组件增加 LibreOffice 7.5 & 7.6 版本默认路径
16. 修改 drawio 默认为预览模式
17. 新增 PDF 线程管理超时管理内存缓存管理更新 PDF 解析组件版本
18. 优化 Dockerfile支持真正的跨平台构建镜像
### 修复
1. 修复 forceUpdatedCache 属性设置但本地缓存文件不更新的问题
2. 修复 PDF 解密加密文件转换成功后后台报错的问题
3. 修复 BPMN 不支持跨域的问题
4. 修复压缩包二级反代特殊符号错误问题
5. 修复视频跨域配置导致视频无法预览的问题
6. 修复 TXT 文本类分页二次加载问题
7. 修复 Drawio 缺少 Base64 组件的问题
8. 修复 Markdown 被转义问题
9. 修复 EPUB 跨域报错问题
10. 修复 URL 特殊符号问题
11. 修复压缩包穿越漏洞
12. 修复压缩获取路径错误图片合集路径错误水印问题等 BUG
13. 修复前端解析 XLSX 包含 EMF 格式文件错误问题
#### > 2023年07月05日v4.3.0 版本发布
#### 新增功能:
1. 新增dcm等医疗数位影像预
2. 新增drawio绘图预览
3. 新增开启缓存的情况下重新生成的命令 &forceUpdatedCache=true
4. 新增dwg CAD文件预览
5. 新增PDF文件支持密码功能
6. 新增PDF文件生成图片的dpi自定义配置
7. 新增删除转换后OFFICECADTIFF压缩包源文件配置 默认开启 节约磁盘空间
8. 新增前端解析xlsx方法
9. 新增pages,eps, iges , igs, dwt, dng, ifc, dwfx, stl, cf2, plt等格式支持
#### 优化:
1. 调整生成的PDF文件 文件名称添加文件后缀 防止生成同名文件
2. 调整SQL文件预览方式
3. 优化OFD预览兼容性
4. 美化TXT文本 分页框的显示
5. 升级LinuxDocker版内置office为LibreOffice-7.5.3版本
6. 升级Windows版内置office为LibreOffice-7.5.3 Portable版本
7. 其他功能优化
#### 修复:
1. 修复反代情况下压缩包获取路径错误
2. 修复预览图片的url中如果包含&会导致.click报错
3. 修复OFD预览部分已知问题
4. 修复预览压缩包时如果点击的是文件目录树节点页面会报错
5. 其他已知问题修复
#### > 2023年04月18日v4.2.1 版本发布
#### 更新日志:
1. 修复 dwg 文件预览报空指针的 bug
#### > 2023年04月13日v4.2.0 版本发布
#### 新增功能:
1. 新增 SVG 格式文件预览支持
2. 新增加密的 Office 文件预览支持
3. 新增加密的 ziprar 等压缩包文件预览支持
4. 新增 xmind 软件模型文件预览支持
5. 新增 bpmn 工作流模型文件预览支持
6. 新增 eml 邮件文件预览支持
7. 新增 epub 电子书文件预览支持
8. 新增 dotm,ett,xlt,xltm,wpt,dot,xlam,xla,dotx 等格式的办公文档预览支持
9. 新增 obj, 3ds, stl, ply, gltf, glb, off, 3dm, fbx, dae, wrl, 3mf, ifc, brep, step, iges, fcstd, bim 3D 模型文件预览支持
10. 新增可配置限制高风险文件上传的功能比如 exe 文件
11. 新增可配置站点的备案信息
12. 新增演示站点删除文件需要密码的功能
#### 优化:
1. 文本文档预览加入缓存
2. 美化 404500 报错页
3. 优化发票等 ofd 文件预览的印证渲染兼容性
4. 移除 office-plugin 模块, 使用新版 jodconverter组件
5. 优化 Excel 文件的预览效果
6. 优化 CAD 文件的预览效果
7. 更新 xstream junrarpdfbox 等依赖的版本
8. 更新 TIF 文件转换 PDF 的插件添加转换缓存
9. 优化演示页 UI 部署
10. 压缩包文件预览支持目录
#### 修复:
1. 修复部分接口 XSS 问题
2. 修复控制台打印的演示地址不跟着 content-path 配置走的问题
3. 修复 ofd 文件预览跨域问题
4. 修复内部自签证书 https 协议 url 文件无法下载的问题
5. 修复特殊符号的文件无法删除的问题
6. 修复 PDF 转图片,内存无法回收导致的 OOM
7. 修复 xlsx7.4 以上版本文件预览乱码的问题
8. 修复 TrustHostFilter 未拦截跨域接口的问题这是一个安全问题有使用到 TrustHost 功能的务必升级
9. 修复压缩包文件预览在 Linux 系统下文件名乱码的问题
10. 修复 ofd 文件预览页码只能显示10页的问题
#### > 2022年12月14日v4.1.0 版本发布
1. 全新首页视觉 @wsd7747
2. tif图片预览兼容多页tif的pdf转换jpg转换以及jpg在线多页预览功能 @zhangzhen1979
3. 优化docker构建方案使用分层构建方式 @yl-yue
4. 实现基于userToken缓存加密文件 @yl-yue
5. 实现加密wordpptexcel文件预览 @yl-yue
6. Linux & Docker镜像升级LibreOffice 7.3
7. 更新OFD预览组件更新tif预览组件更新PPT水印支持
8. 大量其他升级优化 & 已知问题修复
感谢 @yl-yue @wsd7747 @zhangzhen1979 @tomhusky @shenghuadun @kischn.sun 的代码贡献
#### > 2021年7月6日v4.0.0 版本发布
1. 底层集成OpenOffice替换为LibreOfficeOffice文件兼容性增强预览效果提升
2. 修复压缩文件目录穿越漏洞
3. 修复PPT预览使用PDF模式无效
4. 修复PPT图片预览模式前端显示异常
5. 新增功能首页文件上传功能可通过配置实时开启或禁用
6. 优化增加Office进程关闭日志
7. 优化Windows环境下查找Office组件逻辑(内置的LibreOffice优先)
8. 优化启动Office进程改同步执行
#### > 2021年6月17日v3.6.0 版本发布
ofd 类型文件支持版本本次版本重要功能均由社区开发贡献感谢 @gaoxingzaq@zhangxiaoxiao9527 的代码贡献
1. 新增 ofd 类型文件预览支持ofd 是国产的类似 pdf 格式的文件
2. 新增了 ffmpeg 视频文件转码预览支持打开转码功能后理论上支持所有主流视频的预览 rmrmvbflv
3. 美化了 pptpptx 类型文件预览效果比之前版本好看太多
4. 更新了 pdfboxxstreamcommon-io 等依赖的版本
#### > 2021年1月28日
2020农历年最后一个版本发布主要包含了部分 UI 改进和解决了 QQ 群友 Issue 里反馈的 Bug 修复最最重要的是发个新版过个好年
1. 引入galimatias,解决不规范文件名导致文件下载异常
2. 更新index接入演示界面UI风格
3. 更新markdown文件预览UI风格
4. 更新XML文件预览UI风格调整类文本预览架构更方便扩展
5. 更新simTxT文件预览UI风格
6. 调整多图连续预览上下翻图的UI
7. 采用apache-common-io包简化所有的文件下载io操作
8. XML文件预览支持切换纯文本模式
9. 增强url base64解码失败时的提示信息
10. 修复导包错误以及图片预览 bug
11. 修复发行包运行时找不到日志目录的问题
12. 修复压缩包内多图连续预览的bug
13. 修复大小写文件类型后缀没通用匹配的问题
14. 指定Base64转码采用Apache Commons-code中的实现修复base64部分jdk版本下出现的异常
15. 修复类文本类型HTML文件预览的bug
16. 修复dwg文件预览时无法在jpg和pdf两种类型之间切换
17. escaping of dangerous characters to prevent reflected xss
18. 修复重复编码导致文档转图片预览失败的问题&编码规范
#### > 2020年12月27日
2020年年终大版本更新架构全面设计代码全面重构代码质量全面提升二次开发更便捷欢迎拉源码品鉴提issuepr共同建设
1. 架构模块调整,大量的代码重构代码质量提升N个等级欢迎品鉴
2. 增强XML文件预览效果新增XML文档数结构预览
3. 新增markdown文件预览支持预览支持md渲染和源文本切换支持
4. 切换底层web server为jetty解决这个issuehttps://github.com/kekingcn/kkFileView/issues/168
5. 引入cpdetector解决文件编码识别问题
6. url采用base64+urlencode双编码彻底解决各种奇葩文件名预览问题
7. 新增配置项office.preview.switch.disabled控制offic文件预览切换开关
8. 优化文本类型文件预览逻辑采用Base64传输内容避免预览时再次请求文件内容
9. office预览图片模式禁用图片放大效果达到图片和pdf预览效果一致的体验
10. 直接代码静态设置pdfbox兼容低版本jdk在IDEA中运行也不会有警告提示
11. 移除guavahutool等非必须的工具包减少代码体积
12. Office组件加载异步化提速应用启动速度最快到5秒内
13. 合理设置预览消费队列的线程数
14. 修复压缩包里文件再次预览失败的bug
15. 修复图片预览的bug
#### > 2020年05月20日
1. 新增支持全局水印并支持通过参数动态改变水印内容
2. 新增支持CAD文件预览
3. 新增base.url配置支持使用nginx反向代理和使用context-path
4. 支持所有配置项支持从环境变量里读取方便Docker镜像部署和集群中大规模使用
5. 支持配置限信任站点只能预览来自信任点的文件源保护预览服务不被滥用
6. 支持配置自定义缓存清理时间cron表达式
7. 全部能识别的纯文本直接预览不用再转跳下载.md .java .py等
8. 支持配置限制转换后的PDF文件下载
9. 优化maven打包配置解决 .sh 脚本可能出现换行符问题
10. 将前端所有CDN依赖放到本地方便没有外网连接的用户使用
11. 首页评论服务由搜狐畅言切换到Gitalk
12. 修复url中包含特殊字符可能会引起的预览异常
13. 修复转换文件队列addTask异常
14. 修复其他已经问题
15. 官网建设[https://kkview.cn](https://kkview.cn/)
16. 官方Docker镜像仓库建设[https://hub.docker.com/r/keking/kkfileview](https://hub.docker.com/r/keking/kkfileview)
#### > 2019年06月18日
1. 支持自动清理缓存及预览文件
2. 支持http/https下载流url文件预览
3. 支持FTP url文件预览
4. 加入Docker构建
#### > 2019年04月08日
1. 缓存及队列实现抽象提供JDK和REDIS两种实现(REDIS成为可选依赖)
2. 打包方式提供zip和tar.gz包并提供一键启动脚本
#### > 2018年01月19日
1. 大文件入队提前处理
1. 新增addTask文件转换入队接口
1. 采用redis队列支持kkFIleView接口和异构系统入队两种方式
#### > 2018年01月17日
1. 优化项目结构抽象文件预览接口更方便的加入更多的文件类型预览支持方便二次开发
1. 新增英文文档说明@幻幻Fate@汝辉贡献
1. 新增图片预览文件支持类型
1. 修复压缩包内轮播图片总是从第一张开始的问题
#### > 2018年01月12日
1. 新增多图片同时预览
1. 支持压缩包内图片轮番预览
#### > 2018年01月02日
1. 修复txt等文本编码问题导致预览乱码
1. 修复项目模块依赖引入不到的问题
1. 新增spring boot profile支持多环境配置
1. 引入pdf.js预览doc等文件支持doc标题生成pdf预览菜单支持手机端预览
### 关于引用
ofd 引用于 [ofdview ](https://gitee.com/cnofd/ofdview ) 开源协议 Apache-2.0
CAD 引用于 aspose-cad 测试版本 商用请自行购买
xmind 引用于 [ xmind-embed-viewer](https://github.com/xmindltd/xmind-embed-viewer) 开源协议 MIT
epub 引用于 [ epub.js](https://github.com/futurepress/epub.js) 开源协议 BSD许可证
压缩包 引用于 [sevenzipjbinding](https://github.com/borisbrodski/sevenzipjbinding )开源协议LGPL
3D 引用于 [Online3DViewer](https://github.com/kovacsv/Online3DViewer )开源协议MIT
drawio 引用于 [drawio](https://github.com/jgraph/drawio )开源协议 Apache-2.0
bpmn流程图 引用于 [bpmn-js](https://github.com/bpmn-io/bpmn-js ) 自定义协议 保留水印 具体自行查看
dcm医疗数位影像 引用于 [dcmjs](https://github.com/dcmjs-org/dcmjs )开源协议MIT
### 使用登记
如果这个项目解决了你的实际问题可在 https://gitee.com/kekingcn/file-online-preview/issues/IGSBV
登记下如果节省了你的三方预览服务费用也愿意支持下的话可点击下方捐助请作者喝杯咖啡也是非常感谢
### Stars
#### GitHub
[![Stargazers over time](https://starchart.cc/kekingcn/kkFileView.svg)](https://starchart.cc/kekingcn/kkFileView)
### 鸣谢
- 本项目诞生于[凯京集团]在取得公司高层同意后以 Apache 协议开源出来反哺社区在此特别感谢凯京集团以及集团领导[@唐老大](https://github.com/tangshd)的支持、@端木详笑的贡献。
- 本项目已脱离公司由[KK开源社区]维护发展壮大感谢所有给 kkFileView Issue Pr 开发者
- 本项目引入的第三方组件已在 '关于引用' 列表列出感谢这些项目 kkFileView 更出色

View File

@@ -1,104 +0,0 @@
# file-online-preview
[![GitHub license](https://img.shields.io/github/license/kekingcn/kkFileView.svg?style=flat-square)](https://github.com/kekingcn/kkFileView/blob/master/LICENSE)
### Introduction
This kekingcn kkFileView project is intended to be a solution for previewing documents online. At present,there are some similar paid products in the industry.
Such as [永中office](http://dcs.yozosoft.com/)】,【[office365](http://www.officeweb365.com/)】,【[idocv](https://www.idocv.com/)】, etc...
It is an open source implementation and released under the Apache License version 2.0. Finally,It is aimed to feedback the community after obtaining the consent of company executives,
special thanks to the supports of @唐老大 and the contributions of @端木详笑.
### Features
- Build with the popular frame spring boot
- Easy to build and deploy
- Basically support online preview of mainstream office documents, such as Doc, docx, Excel, PDF, TXT, zip, rar, pictures, etc
- REST API
- Abstract file preview interface so that it is easy to extend more file extensions and develop this project on your own
### Live demo
> Please treat public service kindly, or this would stop at any time.
URLhttp://file.keking.cn/
### Documentation
1. 中文文档https://gitee.com/kekingcn/file-online-preview/blob/master/README.md
1. English documenthttps://github.com/kekingcn/kkFileView/blob/master/README.en.md
### Contact us && Join us
> We will answer everyone's questions in use of this project.
And please Google or Baidu first before asking a question, so that we can solve it efficiently.
Cherish life away from ineffective communication.
![输入图片说明](https://gitee.com/uploads/images/2017/1219/173717_934cb068_492218.png "屏幕截图.png")
QQ group613025121
### Pictures for some samples
> Excel
![输入图片说明](https://gitee.com/uploads/images/2017/1213/093051_cd55b3ec_492218.png "屏幕截图.png")
> doc
![输入图片说明](https://gitee.com/uploads/images/2017/1213/092350_5b2ecbe5_492218.png "屏幕截图.png")
> zip,rar
![输入图片说明](https://gitee.com/uploads/images/2017/1213/093806_46cede06_492218.png "屏幕截图.png")
> png,jpeg,jpg,etc., support for zooming with mouse scroll, rotation, inversion,etc.
![输入图片说明](https://gitee.com/uploads/images/2017/1213/094335_657a6f60_492218.png "屏幕截图.png")
Considering space issues, the pictures of other types of documents will not be shown here.You can deploy it by yourself if you are interested in our project.There is a way to deploy it as below.
### Quick Start
> Technology stack
- Spring boot [spring boot Development Reference Guide](http://www.kailing.pub/PdfReader/web/viewer.html?file=springboot)
- Freemarker
- Redisson
- Jodconverter
> Dependencies
- Redis
- OpenOffice or LibreOffice
1. First step`git pull https://github.com/kekingcn/file-online-preview.git`
2. Second stepconfigure redis address and OpenOffice directorysuch as
```
#=============================================#Spring Redisson Configuration#===================================#
spring.redisson.address = 192.168.1.204:6379
##The folder for files which are uploaded to the server(Because of running as jar)
file.dir = C:\\Users\\yudian\\Desktop\\dev\\
## openoffice configuration
office.home = C:\\Program Files (x86)\\OpenOffice 4
```
'file.dir' is the real storage address of the converted files, please end with '/'.
3. Third stepRun the main method of FilePreviewApplication.java.After starting,visit `http://localhost:8012/`.
If everything is ok,you will see the picture below.
![输入图片说明](https://gitee.com/uploads/images/2017/1213/100221_ea15202e_492218.png "屏幕截图.png")
### Changelog
> January 17th 2018
1. Refined the project directory, abstract file preview interface, Easy to extend more file extensions and depoly this project on your own
1. Added English documentation (@幻幻Fate@汝辉) contribution
1. Support for more image file extensions
1. Fixed the issue that image carousel in zip file will always start from the first
> January 12th 2018
1. Support for multiple images preview
1. Support for images rotation preview in rar/zip
> January 2nd 2018
1. Fixed gibberish issue when preview a txt document caused by the file encoding problem
1. Fixed the issue that some module dependencies can not be found
1. Add a spring boot profile, and support for Multi-environment configuration
1. Add `pdf.js` to preview the documents such as doc,etc.,support for generating doc headlines as pdf menusupport for mobile preview
### Register Usage
If this project is helpful for you, please register on 'https://gitee.com/kekingcn/file-online-preview/issues/IGSBV',
If this project helps you to economize the service charge for preview of documents, as well as you are willing to support us, click donate below to donate a cup of coffee, we would appreciate it.

238
README.md
View File

@@ -1,103 +1,191 @@
# file-online-preview
此项目为文件文档在线预览项目解决方案对标业内付费产品有[永中office](http://dcs.yozosoft.com/)】【[office365](http://www.officeweb365.com/)】【[idocv](https://www.idocv.com/)】等在取得公司高层同意后以Apache协议开源出来反哺社区在此特别感谢@唐老大的支持以及@端木详笑的贡献。该项目使用流行的spring boot搭建易上手和部署基本支持主流办公文档的在线预览如doc,docx,Excel,pdf,txt,zip,rar,图片等等
### 项目特性
# kkFileView
1. 支持officepdf等办公文档
1. 支持txt,java,php,py,md,js,css等所有纯文本
1. 支持zip,rar,jar,tar,gzip等压缩包
1. 支持jpgjpegpnggif等图片预览翻转缩放镜像
1. 使用spring boot开发预览服务搭建部署非常简便
1. rest接口提供服务跨平台特性(java,php,python,go,php....)都支持应用接入简单方便
1. 抽象预览服务接口方便二次开发非常方便添加其他类型文件预览支持
1. 最最重要Apache协议开源代码pull下来想干嘛就干嘛
### Introduction
### 在线体验
> 请善待公共服务会不定时停用
Document online preview project solution, built using the popular Spring Boot framework for easy setup and deployment. This versatile open source project provides basic support for a wide range of document formats, including:
地址http://file.keking.cn/
1. Supports Office documents such as `doc`, `docx`, `xls`, `xlsx`, `xlsm`, `ppt`, `pptx`, `csv`, `tsv`, , `dotm`, `xlt`, `xltm`, `dot`, `xlam`, `dotx`, `xla,` ,`pages` etc.
2. Supports domestic WPS Office documents such as `wps`, `dps`, `et` , `ett`, ` wpt`.
3. Supports OpenOffice, LibreOffice office documents such as `odt`, `ods`, `ots`, `odp`, `otp`, `six`, `ott`, `fodt` and `fods`.
4. Supports Visio flowchart files such as `vsd`, `vsdx`.
5. Supports Windows system image files such as `wmf`, `emf`.
6. Supports Photoshop software model files such as `psd` ,`eps`.
7. Supports document formats like `pdf`, `ofd`, and `rtf`.
8. Supports software model files like `xmind`.
9. Support for `bpmn` workflow files.
10. Support for `eml` mail files
11. Support for `epub` book documents
12. Supports 3D model files like `obj`, `3ds`, `stl`, `ply`, `gltf`, `glb`, `off`, `3dm`, `fbx`, `dae`, `wrl`, `3mf`, `ifc`, `brep`, `step`, `iges`, `fcstd`, `bim`, etc.
13. Supports CAD model files such as `dwg`, `dxf`, `dwf` `iges` ,` igs`, `dwt` , `dng` , `ifc` , `dwfx` , `stl` , `cf2` , `plt`, etc.
14. Supports all plain text files such as `txt`, `xml` (rendering), `md` (rendering), `java`, `php`, `py`, `js`, `css`, etc.
15. Supports compressed packages such as `zip`, `rar`, `jar`, `tar`, `gzip`, `7z`, etc.
16. Supports image previewing (flip, zoom, mirror) of `jpg`, `jpeg`, `png`, `gif`, `bmp`, `ico`, `jfif`, `webp`, etc.
17. Supports image information model files such as `tif` and `tiff`.
18. Supports image format files such as `tga`.
19. Supports vector image format files such as `svg`.
20. Supports `mp3`,`wav`,`mp4`,`flv` .
21. Supports many audio and video format files such as `avi`, `mov`, `wmv`, `mkv`, `3gp`, and `rm`.
22. Supports for `dcm` .
23. Supports for `drawio` .
### 项目文档Project documentation
1. 中文文档https://gitee.com/kekingcn/file-online-preview/blob/master/README.md
1. English documenthttps://github.com/kekingcn/kkFileView/blob/master/README.en.md
### Features
- Build with the popular frame spring boot
- Easy to build and deploy
- Basically support online preview of mainstream office documents, such as Doc, docx, Excel, PDF, TXT, zip, rar, pictures, etc
- REST API
- Abstract file preview interface so that it is easy to extend more file extensions and develop this project on your own
### 联系我们加入组织
> 我们会用心回答解决大家在项目使用中的问题也请大家在提问前至少Google或baidu过珍爱生命远离无效的交流沟通
### Official website and DOCS
![输入图片说明](https://gitee.com/uploads/images/2017/1219/173717_934cb068_492218.png "屏幕截图.png")
QQ群号613025121
URL[https://kkview.cn](https://kkview.cn/)
### 文档预览效果
> Excel预览效果
### Live demo
> Please treat public service kindly, or this would stop at any time.
![输入图片说明](https://gitee.com/uploads/images/2017/1213/093051_cd55b3ec_492218.png "屏幕截图.png")
> doc预览效果
URL[https://file.kkview.cn](https://file.kkview.cn)
![输入图片说明](https://gitee.com/uploads/images/2017/1213/092350_5b2ecbe5_492218.png "屏幕截图.png")
### Contact Us
> We will answer your questions carefully and solve any problems you encounter while using the project. We also kindly ask that you at least Google or Baidu before asking questions in order to save time and avoid ineffective communication. Let's cherish our lives and stay away from ineffective communication.
> zip,rar压缩预览效果
<img src="./doc/github星球.png/" width="50%">
![输入图片说明](https://gitee.com/uploads/images/2017/1213/093806_46cede06_492218.png "屏幕截图.png")
### Quick Start
> Technology stack
- Spring boot [spring boot Development Reference Guide](http://www.kailing.pub/PdfReader/web/viewer.html?file=springboot)
- Freemarker
- Redisson
- Jodconverter
> Dependencies
- Redis(Optional, Unnecessary by default)
- OpenOffice or LibreOffice(Integrated on Windows, will be installed automatically on Linux, need to be manually installed on Mac OS)
> png,jpeg,jpg等图片预览效果支持滚轮缩放旋转倒置等
1. First step`git pull https://github.com/kekingcn/kkFileView.git`
![输入图片说明](https://gitee.com/uploads/images/2017/1213/094335_657a6f60_492218.png "屏幕截图.png")
考虑说明篇幅原因就不贴其他格式文件的预览效果了感兴趣的可以参考下面的实例搭建下
2. second stepRun the main method of `/server/src/main/java/cn/keking/ServerMain.java`. After starting,visit `http://localhost:8012/`.
### 快速开始
> 项目使用技术
- spring boot [spring boot开发参考指南](http://www.kailing.pub/PdfReader/web/viewer.html?file=springboot)
- freemarker
- redisson
- jodconverter
> 依赖外部环境
- redis
- OpenOffice或者LibreOffice
### Changelog
> December 14, 2022, version 4.1.0 released:
1. 第一步pull项目https://github.com/kekingcn/file-online-preview.git
1. Updated homepage design by @wsd7747.
2. Compatible with multipage tif for pdf and jpg conversion and multiple page online preview for tif image preview by @zhangzhen1979.
3. Optimized docker build, using layered build method by @yl-yue.
4. Implemented file encryption based on userToken cache by @yl-yue.
5. Implemented preview for encrypted Word, PPT, and Excel files by @yl-yue.
6. Upgraded Linux & Docker images to LibreOffice 7.3.
7. Updated OFD preview component, tif preview component, and added support for PPT watermarking.
8. Numerous other upgrades, optimizations, and bug fixes.
We thank @yl-yue, @wsd7747, @zhangzhen1979, @tomhusky, @shenghuadun, and @kischn.sun for their code contributions.
2. 第二步配置redis地址和OpenOffice目录
```
#=============================================#spring Redisson配置#===================================#
spring.redisson.address = 192.168.1.204:6379
##资源映射路径(因为jar方式运行的原因)
file.dir = C:\\Users\\yudian\\Desktop\\dev\\
## openoffice相关配置
office.home = C:\\Program Files (x86)\\OpenOffice 4
```
file.dir为转换文件实际存储地址注意要以/结尾
> July 6, 2021, version 4.0.0 released:
3. 第三步运行FilePreviewApplication的main方法服务启动后访问http://localhost:8012/
会看到如下界面代表服务启动成功
![输入图片说明](https://gitee.com/uploads/images/2017/1213/100221_ea15202e_492218.png "屏幕截图.png")
1. The integration of OpenOffice in the underlying system has been replaced with LibreOffice, resulting in enhanced compatibility and improved preview effects for Office files.
2. Fixed the directory traversal vulnerability in compressed files.
3. Fixed the issue where previewing PPT files in PDF mode was ineffective.
4. Fixed the issue where the front-end display of image preview mode for PPT files was abnormal.
5. Added a new feature: the file upload function on the homepage can be enabled or disabled in real-time through configuration.
6. Optimized the logging of Office process shutdown.
7. Optimized the logic for finding Office components in Windows environment, with built-in LibreOffice taking priority.
8. Optimized the synchronous execution of starting Office processes.
### 历史更新记录
> June 17, 2021, version 3.6.0 released:
> 2018年01月19日
This version includes support for OFD file type versions, and all the important features in this release were contributed by the community. We thank @gaoxingzaq and @zhangxiaoxiao9527 for their code contributions.
1. 大文件入队提前处理
1. 新增addTask文件转换入队接口
1. 采用redis队列支持kkFIleView接口和异构系统入队两种方式
1. Added support for previewing OFD type files. OFD is a domestically produced file format similar to PDF.
2. Added support for transcoding and previewing video files through ffmpeg. With transcoding enabled, theoretically, all mainstream video file formats such as RM, RMVB, FLV, etc. are supported for preview.
3. Beautified the preview effect of PPT and PPTX file types, much better looking than the previous version.
4. Updated the versions of dependencies such as pdfbox, xstream, common-io.
> 2018年01月17日
> January 28, 2021:
1. 优化项目结构抽象文件预览接口更方便的加入更多的文件类型预览支持方便二次开发
1. 新增英文文档说明@幻幻Fate@汝辉贡献
1. 新增图片预览文件支持类型
1. 修复压缩包内轮播图片总是从第一张开始的问题
The final update of the Lunar New Year 2020 has been released, mainly including some UI improvements, bug fixes reported by QQ group users and issues, and most importantly, it is a new version for a good year.
> 2018年01月12日
1. Introduced galimatias to solve the problem of abnormal file download caused by non-standard file names.
2. Updated UI style of index access demonstration interface.
3. Updated UI style of markdown file preview.
4. Updated UI style of XML file preview, adjusted the architecture of text file preview to facilitate expansion.
5. Updated UI style of simTxT file preview.
6. Adjusted the UI of continuous preview of multiple images to flip up and down.
7. Simplified all file download IO operations by adopting the apache-common-io package.
8. XML file preview supports switching to pure text mode.
9. Enhanced prompt information when url base64 decoding fails.
10. Fixed import errors and image preview bug.
11. Fixed the problem of missing log directory when running the release package.
12. Fixed the bug of continuous preview of multiple images in the compressed package.
13. Fixed the problem of no universal matching for file type suffixes in uppercase and lowercase.
14. Specified the use of the Apache Commons-code implementation for Base64 encoding to fix exceptions occurring in some JDK versions.
15. Fixed the bug of HTML file preview of text-like files.
16. Fixed the problem of inability to switch between jpg and pdf when previewing dwg files.
17. Escaped dangerous characters to prevent reflected xss.
18. Fixed the problem of duplicate encoding causing the failure of document-to-image preview and standardized the encoding.
1. 新增多图片同时预览
1. 支持压缩包内图片轮番预览
> December 27, 2020:
> 2018年01月02日
The year-end major update of 2020 includes comprehensive architecture design, complete code refactoring, significant improvement in code quality, and more convenient secondary development. We welcome you to review the source code and contribute to building by raising issues and pull requests.
1. 修复txt等文本编码问题导致预览乱码
1. 修复项目模块依赖引入不到的问题
1. 新增spring boot profile支持多环境配置
1. 引入pdf.js预览doc等文件支持doc标题生成pdf预览菜单支持手机端预览
1. Adjusted architecture modules, extensively refactored code, and improved code quality by several levels. Please feel free to review.
2. Enhanced XML file preview effect and added preview of XML document structure.
3. Added support for markdown file preview, including support for md rendering and switching between source text and preview.
4. Switched the underlying web server to jetty, resolving the issue: https://github.com/kekingcn/kkFileView/issues/168
5. Introduced cpdetector to solve the problem of file encoding recognition.
6. Adopted double encoding with base64 and urlencode for URLs to completely solve preview problems with bizarre file names.
7. Added configuration item office.preview.switch.disabled to control the switch of office file preview.
8. Optimized text file preview logic, transmitting content through Base64 to avoid requesting file content again during preview.
9. Disabled the image zoom effect in office preview mode to achieve consistent experience with image and pdf preview.
10. Directly set pdfbox to be compatible with lower version JDK, and there will be no warning prompts even when run in IDEA.
11. Removed non-essential toolkits like Guava and Hutool to reduce code volume.
12. Asynchronous loading of Office components speeds up application launch to within 5 seconds.
13. Reasonable settings of the number of threads in the preview consumption queue.
14. Fixed the bug where files in compressed packages failed to preview again.
15. Fixed the bug in image preview.
### 使用登记
如果这个项目解决了你的实际问题可在https://gitee.com/kekingcn/file-online-preview/issues/IGSBV
登记下如果节省了你的三方预览服务费用也愿意支持下的话可点击下方捐助请作者喝杯咖啡也是非常感谢
> May 20th 2020
1. Support for global watermark and dynamic change of watermark content through parameters
2. Support for CAD file Preview
3. Add configuration item base.url, support using nginx reverse proxy and set context-path
4. All configuration items can be read from environment variables, which is convenient for docker image deployment and large-scale use in cluster
5. Support the configuration of TrustHost (only the file source from the trust site can be previewed), and protect the preview service from abuse
6. Support configuration of customize cache cleanup time (cron expression)
7. All recognizable plain text can be previewed directly without downloading, such as .md .java .py, etc
8. Support configuration to limit PDF file download after conversion
9. Optimize Maven packaging configuration to solve the problem of line break in .sh script
10. Place all CDN dependencies on the front end locally for users without external network connection
11. Comment Service on home page switched from Sohu ChangYan to gitalk
12. Fixed preview exceptions that may be caused by special characters in the URL
13. Fixed the addtask exception of the transformation file queue
14. Fixed other known issues
15. Official website build: [https://kkview.cn](https://kkview.cn)
16. Official docker image repository build: [https://hub.docker.com/r/keking/kkfileview](https://hub.docker.com/r/keking/kkfileview)
> June 18th 2019
1. Support automatic cleaning of cache and preview files
2. Support http/https stream url file preview
3. Support FTP url file preview
4. Add Docker build
> April 8th 2019
1. Cache and queue implementations abstract, providing JDK and REDIS implementations (REDIS becomes optional dependencies)
2. Provides zip and tar.gz packages, and provides a one-click startup script
> January 17th 2018
1. Refined the project directory, abstract file preview interface, Easy to extend more file extensions and depoly this project on your own
1. Added English documentation (@幻幻Fate@汝辉) contribution
1. Support for more image file extensions
1. Fixed the issue that image carousel in zip file will always start from the first
> January 12th 2018
1. Support for multiple images preview
1. Support for images rotation preview in rar/zip
> January 2nd 2018
1. Fixed gibberish issue when preview a txt document caused by the file encoding problem
1. Fixed the issue that some module dependencies can not be found
1. Add a spring boot profile, and support for Multi-environment configuration
1. Add `pdf.js` to preview the documents such as doc,etc.,support for generating doc headlines as pdf menusupport for mobile preview
### Sponsor Us
If this project has been helpful to you, we welcome your sponsorship. Your support is our greatest motivation.

174
SECURITY_CONFIG.md Normal file
View File

@@ -0,0 +1,174 @@
# kkFileView 安全配置指南
## 重要安全更新
4.4.0 之后版本开始kkFileView 增强了安全性默认拒绝所有未配置的外部文件预览请求以防止 SSRF服务器端请求伪造攻击
## 🔒 安全配置说明
### 1. 信任主机白名单配置推荐
`application.properties` 中配置允许预览的域名
```properties
# 方式1通过配置文件
trust.host = kkview.cn,yourdomain.com,cdn.example.com
# 方式2通过环境变量
KK_TRUST_HOST=kkview.cn,yourdomain.com,cdn.example.com
```
**示例场景**
- 只允许预览来自 `oss.aliyuncs.com` `cdn.example.com` 的文件
```properties
trust.host = oss.aliyuncs.com,cdn.example.com
```
### 2. 允许所有主机不推荐仅测试环境
```properties
trust.host = *
```
**警告**此配置会允许访问任意外部地址存在安全风险仅应在测试环境使用
### 3. 黑名单配置高级
禁止特定域名或内网地址
```properties
# 禁止访问内网地址强烈推荐
not.trust.host = localhost,127.0.0.1,192.168.*,10.*,172.16.*,169.254.*
# 禁止特定恶意域名
not.trust.host = malicious-site.com,spam-domain.net
```
**优先级**黑名单 > 白名单
### 4. Docker 环境配置
```bash
docker run -d \
-e KK_TRUST_HOST=yourdomain.com,cdn.example.com \
-e KK_NOT_TRUST_HOST=localhost,127.0.0.1 \
-p 8012:8012 \
keking/kkfileview:4.4.0
```
## 🛡 安全最佳实践
### 推荐配置
```properties
# 1. 明确配置信任主机白名单
trust.host = your-cdn.com,your-storage.com
# 2. 配置黑名单防止内网访问
not.trust.host = localhost,127.0.0.1,192.168.*,10.*,172.16.*
# 3. 禁用文件上传生产环境
file.upload.disable = true
# 4. 配置基础URL使用反向代理时
base.url = https://preview.yourdomain.com
```
### 不推荐配置
```properties
# 危险允许所有主机访问
trust.host = *
# 危险启用文件上传生产环境
file.upload.disable = false
```
## 🔍 配置验证
### 测试白名单是否生效
1. 配置白名单
```properties
trust.host = kkview.cn
```
2. 尝试预览白名单内的文件
```
http://localhost:8012/onlinePreview?url=https://kkview.cn/test.pdf
应该可以正常预览
```
3. 尝试预览白名单外的文件
```
http://localhost:8012/onlinePreview?url=https://other-domain.com/test.pdf
应该被拒绝显示"不信任的文件源"
```
### 测试黑名单是否生效
1. 配置黑名单
```properties
not.trust.host = localhost,127.0.0.1
```
2. 尝试访问本地文件
```
http://localhost:8012/getCorsFile?urlPath=http://127.0.0.1:8080/admin
应该被拒绝
```
## 📋 常见问题
### Q1: 升级后无法预览文件了
**原因**新版本默认拒绝未配置的主机
**解决**在配置文件中添加信任主机列表
```properties
trust.host = your-file-server.com
```
### Q2: 如何临时恢复旧版本行为
**不推荐**但如果确实需要
```properties
trust.host = *
```
### Q3: 配置了白名单但还是无法访问
检查以下几点
1. 域名是否完全匹配区分大小写
2. 是否配置了黑名单黑名单优先级更高
3. 查看日志中的 WARNING 信息
4. 确认环境变量是否正确设置
### Q4: 如何允许子域名
已支持通配符域名匹配可使用 `*.example.com`
```properties
trust.host = *.example.com
```
说明
- `*.example.com` 会匹配 `cdn.example.com``api.internal.example.com`但不匹配根域 `example.com`
- 对于 IP 风格通配 `192.168.*``10.*`仅匹配字面量 IPv4 地址不匹配域名
## 🚨 安全事件响应
如果发现可疑的预览请求
1. 检查日志文件搜索 "拒绝访问主机" 关键字
2. 确认 `trust.host` 配置是否合理
3. 检查是否有异常的网络请求
4. 如发现攻击行为及时更新黑名单配置
## 📞 获取帮助
- GitHub Issues: https://github.com/kekingcn/kkFileView/issues
- Gitee Issues: https://gitee.com/kekingcn/file-online-preview/issues
---
**安全提示**定期检查和更新信任主机列表遵循最小权限原则

BIN
doc/gitee星球.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

BIN
doc/github星球.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -0,0 +1,28 @@
FROM ubuntu:24.04
RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.aliyun.com@g' /etc/apt/sources.list.d/ubuntu.sources &&\
sed -i 's@//security.ubuntu.com@//mirrors.aliyun.com@g' /etc/apt/sources.list.d/ubuntu.sources &&\
sed -i 's@//ports.ubuntu.com@//mirrors.aliyun.com@g' /etc/apt/sources.list.d/ubuntu.sources &&\
apt-get update &&\
export DEBIAN_FRONTEND=noninteractive &&\
apt-get install -y --no-install-recommends openjdk-21-jre tzdata locales xfonts-utils fontconfig libreoffice-nogui &&\
echo 'Asia/Shanghai' > /etc/timezone &&\
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&\
localedef -i zh_CN -c -f UTF-8 -A /usr/share/locale/locale.alias zh_CN.UTF-8 &&\
locale-gen zh_CN.UTF-8 &&\
apt-get install -y --no-install-recommends ttf-mscorefonts-installer &&\
apt-get install -y --no-install-recommends ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy &&\
apt-get autoremove -y &&\
apt-get clean &&\
rm -rf /var/lib/apt/lists/*
# 内置一些常用的中文字体,避免普遍性乱码
ADD fonts/* /usr/share/fonts/chinese/
RUN cd /usr/share/fonts/chinese &&\
# 安装字体
mkfontscale &&\
mkfontdir &&\
fc-cache -fv
ENV LANG=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8

View File

@@ -0,0 +1,50 @@
# 构建说明
由于 kkfileview 的基础运行环境很少变动且制作耗时较久 kkfileview 本身代码开发会频繁改动因此把制作其 Docker 镜像的步骤拆分为两次
首先制作 kkfileview 的基础镜像kkfileview-base
然后使用 kkfileview-base 作为基础镜像进行构建加快 kkfileview docker 镜像构建与发布
执行如下命令即可构建基础镜像
> 这里镜像 tag 4.4.0 为例本项目所维护的 Dockerfile 文件考虑了跨平台兼容性 如果你需要用到 arm64 架构镜像, 则在arm64 架构机器上同样执行下面的构建命令即可
```shell
docker build --tag keking/kkfileview-base:4.4.0 .
```
## 跨平台构建
`docker buildx` 支持在一台机器上构建出多种平台架构的镜像推荐使用该能力进行跨平台的镜像构建
例如执行 `docker buildx build` 命令时加上 `--platform=linux/arm64` 参数即可构建出 arm64 架构镜像这极大方便了那些没有arm64 架构机器却想构建 arm64 架构镜像的用户
> 当前本项目仅支持构建 linux/amd64 linux/arm64 两种平台架构的镜像
> buildx builder driver 可以使用默认的 `docker` 类型, 若使用 `docker-container` 类型可以支持并行构建多种架构, 本文不再赘述, 有兴趣可以自行了解参考 [Docker Buildx | Docker Documentation](https://docs.docker.com/buildx/working-with-buildx/#build-multi-platform-images)
**前提要求**
以当前机器为 amd64 (x86_64)架构为例需要开启 docker buildx 特性以及开启 Linux QEMU 用户模式
> 使用 WSL2 Windows 用户如果安装了最新的 DockerDesktop, 则这些前提要求已满足, 无需额外下述设置
1. 安装 docker buildx 客户端插件
> docker 版本要求 >=19.03
若已安装, 则跳过详情参考 https://github.com/docker/buildx
2. 开启 QEMU 的用户模式功能, 并安装其它平台的模拟器:
> Linux 内核要求 >=4.8
使用 `tonistiigi/binfmt` 镜像可快速开启并安装模拟器执行下面命令:
```shell
docker run --privileged --rm tonistiigi/binfmt --install all
```
现在就可以愉快地开始构建了构建命令示例:
```shell
docker buildx build --platform=linux/amd64,linux/arm64 -t keking/kkfileview-base:4.4.0 --push .
```

View File

@@ -0,0 +1,53 @@
# Build Instructions
Since the base runtime environment for kkfileview rarely changes and takes a long time to build, while the kkfileview code itself is frequently updated, the process of building its Docker image is split into two steps:
First, create the base image for kkfileview (kkfileview-base).
Then, use kkfileview-base as the base image to build and speed up the kkfileview Docker image build and release process.
To build the base image, run the following command:
> In this example, the image tag is 4.4.0. The Dockerfile maintained in this project considers cross-platform compatibility. If you need an arm64 architecture image, run the same build command on an arm64 architecture machine.
```shell
docker build --tag keking/kkfileview-base:4.4.0 .
```
## Cross-Platform Build
`docker buildx` supports building images for multiple platform architectures on a single machine. It is recommended to use this capability for cross-platform image builds.
For example, adding the `--platform=linux/arm64` parameter when executing the `docker buildx build` command will allow you to build an arm64 architecture image. This is particularly convenient for users who want to build arm64 images but don't have an arm64 machine.
> Currently, this project only supports building images for the linux/amd64 and linux/arm64 architectures.
> The buildx builder driver can use the default `docker` type, but if you use the `docker-container` type, you can build multiple architectures in parallel. This README will not cover that in detail, you can learn more on your own. Refer to [Docker Buildx | Docker Documentation](https://docs.docker.com/buildx/working-with-buildx/#build-multi-platform-images)
**Prerequisites**
Assuming the current machine is amd64 (x86_64) architecture, you'll need to enable the docker buildx feature and enable Linux QEMU user mode:
> Windows users with WSL2 who have installed a recent version of Docker Desktop will already meet these prerequisites, so no additional setup is required.
1. Install the docker buildx client plugin:
> Docker version >=19.03 is required.
If it's already installed, you can skip this step. For more details, refer to https://github.com/docker/buildx.
2. Enable QEMU user mode and install emulators for other platforms:
> Linux kernel version >=4.8 is required.
You can quickly enable and install emulators using the tonistiigi/binfmt image by running the following command:
```shell
docker run --privileged --rm tonistiigi/binfmt --install all
```
Now you can enjoy the building. Heres an example build command:
```shell
docker buildx build --platform=linux/amd64,linux/arm64 -t keking/kkfileview-base:4.4.0 --push .
```

View File

View File

@@ -1,160 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.keking</groupId>
<artifactId>jodconverter-core</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<!-- required for org.hyperic:sigar -->
<id>jboss-public-repository-group</id>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.openoffice</groupId>
<artifactId>juh</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.openoffice</groupId>
<artifactId>ridl</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.openoffice</groupId>
<artifactId>unoil</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<!-- for the command line tool -->
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.1</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.hyperic</groupId>
<artifactId>sigar</artifactId>
<version>1.6.5.132</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.0.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 要将源码放上去需要加入这个插件 -->
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.1</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<configuration>
<!-- don't run tests in parallel -->
<perCoreThreadCount>false</perCoreThreadCount>
<threadCount>1</threadCount>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifest>
<mainClass>org.artofsolving.jodconverter.cli.Convert</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/dist.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</reporting>
<!-- distribute目录 -->
<distributionManagement>
<repository>
<id>repo</id>
<name>User Project Releases</name>
<url>http://192.168.1.204:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>repo</id>
<name>User Project SNAPSHOTS</name>
<url>http://192.168.1.204:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
</project>

View File

@@ -1,37 +0,0 @@
<assembly>
<id>dist</id>
<formats>
<format>zip</format>
</formats>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<excludes>
<exclude>org.hyperic:sigar</exclude>
</excludes>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<includes>
<include>LICENSE.txt</include>
<include>README.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>target</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>${project.artifactId}-${project.version}-javadoc.jar</include>
<include>${project.artifactId}-${project.version}-sources.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>src/main/resources</directory>
<outputDirectory>/conf</outputDirectory>
<includes>
<include>document-formats.js</include>
</includes>
</fileSet>
</fileSets>
</assembly>

View File

@@ -1,125 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter;
import static org.artofsolving.jodconverter.office.OfficeUtils.SERVICE_DESKTOP;
import static org.artofsolving.jodconverter.office.OfficeUtils.cast;
import static org.artofsolving.jodconverter.office.OfficeUtils.toUnoProperties;
import static org.artofsolving.jodconverter.office.OfficeUtils.toUrl;
import java.io.File;
import java.util.Map;
import org.artofsolving.jodconverter.office.OfficeContext;
import org.artofsolving.jodconverter.office.OfficeException;
import org.artofsolving.jodconverter.office.OfficeTask;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XStorable;
import com.sun.star.io.IOException;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.XComponent;
import com.sun.star.task.ErrorCodeIOException;
import com.sun.star.util.CloseVetoException;
import com.sun.star.util.XCloseable;
public abstract class AbstractConversionTask implements OfficeTask {
private final File inputFile;
private final File outputFile;
public AbstractConversionTask(File inputFile, File outputFile) {
this.inputFile = inputFile;
this.outputFile = outputFile;
}
protected abstract Map<String,?> getLoadProperties(File inputFile);
protected abstract Map<String,?> getStoreProperties(File outputFile, XComponent document);
public void execute(OfficeContext context) throws OfficeException {
XComponent document = null;
try {
document = loadDocument(context, inputFile);
modifyDocument(document);
storeDocument(document, outputFile);
} catch (OfficeException officeException) {
throw officeException;
} catch (Exception exception) {
throw new OfficeException("conversion failed", exception);
} finally {
if (document != null) {
XCloseable closeable = cast(XCloseable.class, document);
if (closeable != null) {
try {
closeable.close(true);
} catch (CloseVetoException closeVetoException) {
// whoever raised the veto should close the document
}
} else {
document.dispose();
}
}
}
}
private XComponent loadDocument(OfficeContext context, File inputFile) throws OfficeException {
if (!inputFile.exists()) {
throw new OfficeException("input document not found");
}
XComponentLoader loader = cast(XComponentLoader.class, context.getService(SERVICE_DESKTOP));
Map<String,?> loadProperties = getLoadProperties(inputFile);
XComponent document = null;
try {
document = loader.loadComponentFromURL(toUrl(inputFile), "_blank", 0, toUnoProperties(loadProperties));
} catch (IllegalArgumentException illegalArgumentException) {
throw new OfficeException("could not load document: " + inputFile.getName(), illegalArgumentException);
} catch (ErrorCodeIOException errorCodeIOException) {
throw new OfficeException("could not load document: " + inputFile.getName() + "; errorCode: " + errorCodeIOException.ErrCode, errorCodeIOException);
} catch (IOException ioException) {
throw new OfficeException("could not load document: " + inputFile.getName(), ioException);
}
if (document == null) {
throw new OfficeException("could not load document: " + inputFile.getName());
}
return document;
}
/**
* Override to modify the document after it has been loaded and before it gets
* saved in the new format.
* <p>
* Does nothing by default.
*
* @param document
* @throws OfficeException
*/
protected void modifyDocument(XComponent document) throws OfficeException {
// noop
}
private void storeDocument(XComponent document, File outputFile) throws OfficeException {
Map<String,?> storeProperties = getStoreProperties(outputFile, document);
if (storeProperties == null) {
throw new OfficeException("unsupported conversion");
}
try {
cast(XStorable.class, document).storeToURL(toUrl(outputFile), toUnoProperties(storeProperties));
} catch (ErrorCodeIOException errorCodeIOException) {
throw new OfficeException("could not store document: " + outputFile.getName() + "; errorCode: " + errorCodeIOException.ErrCode, errorCodeIOException);
} catch (IOException ioException) {
throw new OfficeException("could not store document: " + outputFile.getName(), ioException);
}
}
}

View File

@@ -1,75 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.FilenameUtils;
import org.artofsolving.jodconverter.document.DefaultDocumentFormatRegistry;
import org.artofsolving.jodconverter.document.DocumentFormat;
import org.artofsolving.jodconverter.document.DocumentFormatRegistry;
import org.artofsolving.jodconverter.office.OfficeException;
import org.artofsolving.jodconverter.office.OfficeManager;
import com.sun.star.document.UpdateDocMode;
public class OfficeDocumentConverter {
private final OfficeManager officeManager;
private final DocumentFormatRegistry formatRegistry;
private Map<String,?> defaultLoadProperties = createDefaultLoadProperties();
public OfficeDocumentConverter(OfficeManager officeManager) {
this(officeManager, new DefaultDocumentFormatRegistry());
}
public OfficeDocumentConverter(OfficeManager officeManager, DocumentFormatRegistry formatRegistry) {
this.officeManager = officeManager;
this.formatRegistry = formatRegistry;
}
private Map<String,Object> createDefaultLoadProperties() {
Map<String,Object> loadProperties = new HashMap<String,Object>();
loadProperties.put("Hidden", true);
loadProperties.put("ReadOnly", true);
loadProperties.put("UpdateDocMode", UpdateDocMode.QUIET_UPDATE);
return loadProperties;
}
public void setDefaultLoadProperties(Map<String, ?> defaultLoadProperties) {
this.defaultLoadProperties = defaultLoadProperties;
}
public DocumentFormatRegistry getFormatRegistry() {
return formatRegistry;
}
public void convert(File inputFile, File outputFile) throws OfficeException {
String outputExtension = FilenameUtils.getExtension(outputFile.getName());
DocumentFormat outputFormat = formatRegistry.getFormatByExtension(outputExtension);
convert(inputFile, outputFile, outputFormat);
}
public void convert(File inputFile, File outputFile, DocumentFormat outputFormat) throws OfficeException {
String inputExtension = FilenameUtils.getExtension(inputFile.getName());
DocumentFormat inputFormat = formatRegistry.getFormatByExtension(inputExtension);
StandardConversionTask conversionTask = new StandardConversionTask(inputFile, outputFile, outputFormat);
conversionTask.setDefaultLoadProperties(defaultLoadProperties);
conversionTask.setInputFormat(inputFormat);
officeManager.execute(conversionTask);
}
}

View File

@@ -1,47 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter;
import static org.artofsolving.jodconverter.office.OfficeUtils.*;
import org.artofsolving.jodconverter.document.DocumentFamily;
import org.artofsolving.jodconverter.office.OfficeException;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XServiceInfo;
class OfficeDocumentUtils {
private OfficeDocumentUtils() {
throw new AssertionError("utility class must not be instantiated");
}
public static DocumentFamily getDocumentFamily(XComponent document) throws OfficeException {
XServiceInfo serviceInfo = cast(XServiceInfo.class, document);
if (serviceInfo.supportsService("com.sun.star.text.GenericTextDocument")) {
// NOTE: a GenericTextDocument is either a TextDocument, a WebDocument, or a GlobalDocument
// but this further distinction doesn't seem to matter for conversions
return DocumentFamily.TEXT;
} else if (serviceInfo.supportsService("com.sun.star.sheet.SpreadsheetDocument")) {
return DocumentFamily.SPREADSHEET;
} else if (serviceInfo.supportsService("com.sun.star.presentation.PresentationDocument")) {
return DocumentFamily.PRESENTATION;
} else if (serviceInfo.supportsService("com.sun.star.drawing.DrawingDocument")) {
return DocumentFamily.DRAWING;
} else {
throw new OfficeException("document of unknown family: " + serviceInfo.getImplementationName());
}
}
}

View File

@@ -1,74 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter;
import static org.artofsolving.jodconverter.office.OfficeUtils.cast;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.artofsolving.jodconverter.document.DocumentFamily;
import org.artofsolving.jodconverter.document.DocumentFormat;
import org.artofsolving.jodconverter.office.OfficeException;
import com.sun.star.lang.XComponent;
import com.sun.star.util.XRefreshable;
public class StandardConversionTask extends AbstractConversionTask {
private final DocumentFormat outputFormat;
private Map<String,?> defaultLoadProperties;
private DocumentFormat inputFormat;
public StandardConversionTask(File inputFile, File outputFile, DocumentFormat outputFormat) {
super(inputFile, outputFile);
this.outputFormat = outputFormat;
}
public void setDefaultLoadProperties(Map<String, ?> defaultLoadProperties) {
this.defaultLoadProperties = defaultLoadProperties;
}
public void setInputFormat(DocumentFormat inputFormat) {
this.inputFormat = inputFormat;
}
@Override
protected void modifyDocument(XComponent document) throws OfficeException {
XRefreshable refreshable = cast(XRefreshable.class, document);
if (refreshable != null) {
refreshable.refresh();
}
}
@Override
protected Map<String,?> getLoadProperties(File inputFile) {
Map<String,Object> loadProperties = new HashMap<String,Object>();
if (defaultLoadProperties != null) {
loadProperties.putAll(defaultLoadProperties);
}
if (inputFormat != null && inputFormat.getLoadProperties() != null) {
loadProperties.putAll(inputFormat.getLoadProperties());
}
return loadProperties;
}
@Override
protected Map<String,?> getStoreProperties(File outputFile, XComponent document) {
DocumentFamily family = OfficeDocumentUtils.getDocumentFamily(document);
return outputFormat.getStoreProperties(family);
}
}

View File

@@ -1,126 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.cli;
import java.io.File;
import java.io.IOException;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.artofsolving.jodconverter.OfficeDocumentConverter;
import org.artofsolving.jodconverter.document.DefaultDocumentFormatRegistry;
import org.artofsolving.jodconverter.document.DocumentFormatRegistry;
import org.artofsolving.jodconverter.document.JsonDocumentFormatRegistry;
import org.artofsolving.jodconverter.office.OfficeManager;
import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration;
import org.json.JSONException;
/**
* Command line interface executable.
*/
public class Convert {
public static final int STATUS_OK = 0;
public static final int STATUS_MISSING_INPUT_FILE = 1;
public static final int STATUS_INVALID_ARGUMENTS = 255;
private static final Option OPTION_OUTPUT_FORMAT = new Option("o", "output-format", true, "output format (e.g. pdf)");
private static final Option OPTION_PORT = new Option("p", "port", true, "office socket port (optional; defaults to 2002)");
private static final Option OPTION_REGISTRY = new Option("r", "registry", true, "document formats registry configuration file (optional)");
private static final Option OPTION_TIMEOUT = new Option("t", "timeout", true, "maximum conversion time in seconds (optional; defaults to 120)");
private static final Option OPTION_USER_PROFILE = new Option("u", "user-profile", true, "use settings from the given user installation dir (optional)");
private static final Options OPTIONS = initOptions();
private static final int DEFAULT_OFFICE_PORT = 2002;
private static Options initOptions() {
Options options = new Options();
options.addOption(OPTION_OUTPUT_FORMAT);
options.addOption(OPTION_PORT);
options.addOption(OPTION_REGISTRY);
options.addOption(OPTION_TIMEOUT);
options.addOption(OPTION_USER_PROFILE);
return options;
}
public static void main(String[] arguments) throws ParseException, JSONException, IOException {
CommandLineParser commandLineParser = new PosixParser();
CommandLine commandLine = commandLineParser.parse(OPTIONS, arguments);
String outputFormat = null;
if (commandLine.hasOption(OPTION_OUTPUT_FORMAT.getOpt())) {
outputFormat = commandLine.getOptionValue(OPTION_OUTPUT_FORMAT.getOpt());
}
int port = DEFAULT_OFFICE_PORT;
if (commandLine.hasOption(OPTION_PORT.getOpt())) {
port = Integer.parseInt(commandLine.getOptionValue(OPTION_PORT.getOpt()));
}
String[] fileNames = commandLine.getArgs();
if ((outputFormat == null && fileNames.length != 2) || fileNames.length < 1) {
String syntax = "java -jar jodconverter-core.jar [options] input-file output-file\n"
+ "or [options] -o output-format input-file [input-file...]";
HelpFormatter helpFormatter = new HelpFormatter();
helpFormatter.printHelp(syntax, OPTIONS);
System.exit(STATUS_INVALID_ARGUMENTS);
}
DocumentFormatRegistry registry;
if (commandLine.hasOption(OPTION_REGISTRY.getOpt())) {
File registryFile = new File(commandLine.getOptionValue(OPTION_REGISTRY.getOpt()));
registry = new JsonDocumentFormatRegistry(FileUtils.readFileToString(registryFile));
} else {
registry = new DefaultDocumentFormatRegistry();
}
DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration();
configuration.setPortNumber(port);
if (commandLine.hasOption(OPTION_TIMEOUT.getOpt())) {
int timeout = Integer.parseInt(commandLine.getOptionValue(OPTION_TIMEOUT.getOpt()));
configuration.setTaskExecutionTimeout(timeout * 1000);
}
if (commandLine.hasOption(OPTION_USER_PROFILE.getOpt())) {
String templateProfileDir = commandLine.getOptionValue(OPTION_USER_PROFILE.getOpt());
configuration.setTemplateProfileDir(new File(templateProfileDir));
}
OfficeManager officeManager = configuration.buildOfficeManager();
officeManager.start();
OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager, registry);
try {
if (outputFormat == null) {
File inputFile = new File(fileNames[0]);
File outputFile = new File(fileNames[1]);
converter.convert(inputFile, outputFile);
} else {
for (int i = 0; i < fileNames.length; i++) {
File inputFile = new File(fileNames[i]);
String outputName = FilenameUtils.getBaseName(fileNames[i]) + "." + outputFormat;
File outputFile = new File(FilenameUtils.getFullPath(fileNames[i]) + outputName);
converter.convert(inputFile, outputFile);
}
}
} finally {
officeManager.stop();
}
}
}

View File

@@ -1,157 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.document;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
public class DefaultDocumentFormatRegistry extends SimpleDocumentFormatRegistry {
public DefaultDocumentFormatRegistry() {
DocumentFormat pdf = new DocumentFormat("Portable Document Format", "pdf", "application/pdf");
pdf.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "writer_pdf_Export"));
pdf.setStoreProperties(DocumentFamily.SPREADSHEET, Collections.singletonMap("FilterName", "calc_pdf_Export"));
pdf.setStoreProperties(DocumentFamily.PRESENTATION, Collections.singletonMap("FilterName", "impress_pdf_Export"));
pdf.setStoreProperties(DocumentFamily.DRAWING, Collections.singletonMap("FilterName", "draw_pdf_Export"));
addFormat(pdf);
DocumentFormat swf = new DocumentFormat("Macromedia Flash", "swf", "application/x-shockwave-flash");
swf.setStoreProperties(DocumentFamily.PRESENTATION, Collections.singletonMap("FilterName", "impress_flash_Export"));
swf.setStoreProperties(DocumentFamily.DRAWING, Collections.singletonMap("FilterName", "draw_flash_Export"));
addFormat(swf);
// disabled because it's not always available
//DocumentFormat xhtml = new DocumentFormat("XHTML", "xhtml", "application/xhtml+xml");
//xhtml.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "XHTML Writer File"));
//xhtml.setStoreProperties(DocumentFamily.SPREADSHEET, Collections.singletonMap("FilterName", "XHTML Calc File"));
//xhtml.setStoreProperties(DocumentFamily.PRESENTATION, Collections.singletonMap("FilterName", "XHTML Impress File"));
//addFormat(xhtml);
DocumentFormat html = new DocumentFormat("HTML", "html", "text/html");
// HTML is treated as Text when supplied as input, but as an output it is also
// available for exporting Spreadsheet and Presentation formats
html.setInputFamily(DocumentFamily.TEXT);
html.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "HTML (StarWriter)"));
html.setStoreProperties(DocumentFamily.SPREADSHEET, Collections.singletonMap("FilterName", "HTML (StarCalc)"));
html.setStoreProperties(DocumentFamily.PRESENTATION, Collections.singletonMap("FilterName", "impress_html_Export"));
addFormat(html);
DocumentFormat odt = new DocumentFormat("OpenDocument Text", "odt", "application/vnd.oasis.opendocument.text");
odt.setInputFamily(DocumentFamily.TEXT);
odt.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "writer8"));
addFormat(odt);
DocumentFormat sxw = new DocumentFormat("OpenOffice.org 1.0 Text Document", "sxw", "application/vnd.sun.xml.writer");
sxw.setInputFamily(DocumentFamily.TEXT);
sxw.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "StarOffice XML (Writer)"));
addFormat(sxw);
DocumentFormat doc = new DocumentFormat("Microsoft Word", "doc", "application/msword");
doc.setInputFamily(DocumentFamily.TEXT);
doc.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "MS Word 97"));
addFormat(doc);
DocumentFormat docx = new DocumentFormat("Microsoft Word 2007 XML", "docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
docx.setInputFamily(DocumentFamily.TEXT);
addFormat(docx);
DocumentFormat rtf = new DocumentFormat("Rich Text Format", "rtf", "text/rtf");
rtf.setInputFamily(DocumentFamily.TEXT);
rtf.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "Rich Text Format"));
addFormat(rtf);
DocumentFormat wpd = new DocumentFormat("WordPerfect", "wpd", "application/wordperfect");
wpd.setInputFamily(DocumentFamily.TEXT);
addFormat(wpd);
DocumentFormat txt = new DocumentFormat("Plain Text", "txt", "text/plain");
txt.setInputFamily(DocumentFamily.TEXT);
Map<String,Object> txtLoadAndStoreProperties = new LinkedHashMap<String,Object>();
txtLoadAndStoreProperties.put("FilterName", "Text (encoded)");
txtLoadAndStoreProperties.put("FilterOptions", "utf8");
txt.setLoadProperties(txtLoadAndStoreProperties);
txt.setStoreProperties(DocumentFamily.TEXT, txtLoadAndStoreProperties);
addFormat(txt);
DocumentFormat wikitext = new DocumentFormat("MediaWiki wikitext", "wiki", "text/x-wiki");
wikitext.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "MediaWiki"));
//addFormat(wikitext);
DocumentFormat ods = new DocumentFormat("OpenDocument Spreadsheet", "ods", "application/vnd.oasis.opendocument.spreadsheet");
ods.setInputFamily(DocumentFamily.SPREADSHEET);
ods.setStoreProperties(DocumentFamily.SPREADSHEET, Collections.singletonMap("FilterName", "calc8"));
addFormat(ods);
DocumentFormat sxc = new DocumentFormat("OpenOffice.org 1.0 Spreadsheet", "sxc", "application/vnd.sun.xml.calc");
sxc.setInputFamily(DocumentFamily.SPREADSHEET);
sxc.setStoreProperties(DocumentFamily.SPREADSHEET, Collections.singletonMap("FilterName", "StarOffice XML (Calc)"));
addFormat(sxc);
DocumentFormat xls = new DocumentFormat("Microsoft Excel", "xls", "application/vnd.ms-excel");
xls.setInputFamily(DocumentFamily.SPREADSHEET);
xls.setStoreProperties(DocumentFamily.SPREADSHEET, Collections.singletonMap("FilterName", "MS Excel 97"));
addFormat(xls);
DocumentFormat xlsx = new DocumentFormat("Microsoft Excel 2007 XML", "xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
xlsx.setInputFamily(DocumentFamily.SPREADSHEET);
addFormat(xlsx);
DocumentFormat csv = new DocumentFormat("Comma Separated Values", "csv", "text/csv");
csv.setInputFamily(DocumentFamily.SPREADSHEET);
Map<String,Object> csvLoadAndStoreProperties = new LinkedHashMap<String,Object>();
csvLoadAndStoreProperties.put("FilterName", "Text - txt - csv (StarCalc)");
csvLoadAndStoreProperties.put("FilterOptions", "44,34,0"); // Field Separator: ','; Text Delimiter: '"'
csv.setLoadProperties(csvLoadAndStoreProperties);
csv.setStoreProperties(DocumentFamily.SPREADSHEET, csvLoadAndStoreProperties);
addFormat(csv);
DocumentFormat tsv = new DocumentFormat("Tab Separated Values", "tsv", "text/tab-separated-values");
tsv.setInputFamily(DocumentFamily.SPREADSHEET);
Map<String,Object> tsvLoadAndStoreProperties = new LinkedHashMap<String,Object>();
tsvLoadAndStoreProperties.put("FilterName", "Text - txt - csv (StarCalc)");
tsvLoadAndStoreProperties.put("FilterOptions", "9,34,0"); // Field Separator: '\t'; Text Delimiter: '"'
tsv.setLoadProperties(tsvLoadAndStoreProperties);
tsv.setStoreProperties(DocumentFamily.SPREADSHEET, tsvLoadAndStoreProperties);
addFormat(tsv);
DocumentFormat odp = new DocumentFormat("OpenDocument Presentation", "odp", "application/vnd.oasis.opendocument.presentation");
odp.setInputFamily(DocumentFamily.PRESENTATION);
odp.setStoreProperties(DocumentFamily.PRESENTATION, Collections.singletonMap("FilterName", "impress8"));
addFormat(odp);
DocumentFormat sxi = new DocumentFormat("OpenOffice.org 1.0 Presentation", "sxi", "application/vnd.sun.xml.impress");
sxi.setInputFamily(DocumentFamily.PRESENTATION);
sxi.setStoreProperties(DocumentFamily.PRESENTATION, Collections.singletonMap("FilterName", "StarOffice XML (Impress)"));
addFormat(sxi);
DocumentFormat ppt = new DocumentFormat("Microsoft PowerPoint", "ppt", "application/vnd.ms-powerpoint");
ppt.setInputFamily(DocumentFamily.PRESENTATION);
ppt.setStoreProperties(DocumentFamily.PRESENTATION, Collections.singletonMap("FilterName", "MS PowerPoint 97"));
addFormat(ppt);
DocumentFormat pptx = new DocumentFormat("Microsoft PowerPoint 2007 XML", "pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
pptx.setInputFamily(DocumentFamily.PRESENTATION);
addFormat(pptx);
DocumentFormat odg = new DocumentFormat("OpenDocument Drawing", "odg", "application/vnd.oasis.opendocument.graphics");
odg.setInputFamily(DocumentFamily.DRAWING);
odg.setStoreProperties(DocumentFamily.DRAWING, Collections.singletonMap("FilterName", "draw8"));
addFormat(odg);
DocumentFormat svg = new DocumentFormat("Scalable Vector Graphics", "svg", "image/svg+xml");
svg.setStoreProperties(DocumentFamily.DRAWING, Collections.singletonMap("FilterName", "draw_svg_Export"));
addFormat(svg);
}
}

View File

@@ -1,19 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.document;
public enum DocumentFamily {
TEXT, SPREADSHEET, PRESENTATION, DRAWING
}

View File

@@ -1,99 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.document;
import java.util.HashMap;
import java.util.Map;
public class DocumentFormat {
private String name;
private String extension;
private String mediaType;
private DocumentFamily inputFamily;
private Map<String,?> loadProperties;
private Map<DocumentFamily,Map<String,?>> storePropertiesByFamily;
public DocumentFormat() {
// default
}
public DocumentFormat(String name, String extension, String mediaType) {
this.name = name;
this.extension = extension;
this.mediaType = mediaType;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public String getMediaType() {
return mediaType;
}
public void setMediaType(String mediaType) {
this.mediaType = mediaType;
}
public DocumentFamily getInputFamily() {
return inputFamily;
}
public void setInputFamily(DocumentFamily documentFamily) {
this.inputFamily = documentFamily;
}
public Map<String, ?> getLoadProperties() {
return loadProperties;
}
public void setLoadProperties(Map<String,?> loadProperties) {
this.loadProperties = loadProperties;
}
public Map<DocumentFamily, Map<String, ?>> getStorePropertiesByFamily() {
return storePropertiesByFamily;
}
public void setStorePropertiesByFamily(Map<DocumentFamily, Map<String,?>> storePropertiesByFamily) {
this.storePropertiesByFamily = storePropertiesByFamily;
}
public void setStoreProperties(DocumentFamily family, Map<String,?> storeProperties) {
if (storePropertiesByFamily == null) {
storePropertiesByFamily = new HashMap<DocumentFamily,Map<String,?>>();
}
storePropertiesByFamily.put(family, storeProperties);
}
public Map<String,?> getStoreProperties(DocumentFamily family) {
if (storePropertiesByFamily == null) {
return null;
}
return storePropertiesByFamily.get(family);
}
}

View File

@@ -1,25 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.document;
import java.util.Set;
public interface DocumentFormatRegistry {
public DocumentFormat getFormatByExtension(String extension);
public DocumentFormat getFormatByMediaType(String mediaType);
public Set<DocumentFormat> getOutputFormats(DocumentFamily family);
}

View File

@@ -1,73 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.document;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class JsonDocumentFormatRegistry extends SimpleDocumentFormatRegistry {
public JsonDocumentFormatRegistry(InputStream input) throws JSONException, IOException {
readJsonArray(IOUtils.toString(input));
}
public JsonDocumentFormatRegistry(String source) throws JSONException {
readJsonArray(source);
}
private void readJsonArray(String source) throws JSONException {
JSONArray array = new JSONArray(source);
for (int i = 0; i < array.length(); i++) {
JSONObject jsonFormat = array.getJSONObject(i);
DocumentFormat format = new DocumentFormat();
format.setName(jsonFormat.getString("name"));
format.setExtension(jsonFormat.getString("extension"));
format.setMediaType(jsonFormat.getString("mediaType"));
if (jsonFormat.has("inputFamily")) {
format.setInputFamily(DocumentFamily.valueOf(jsonFormat.getString("inputFamily")));
}
if (jsonFormat.has("loadProperties")) {
format.setLoadProperties(toJavaMap(jsonFormat.getJSONObject("loadProperties")));
}
if (jsonFormat.has("storePropertiesByFamily")) {
JSONObject jsonStorePropertiesByFamily = jsonFormat.getJSONObject("storePropertiesByFamily");
for (String key : JSONObject.getNames(jsonStorePropertiesByFamily)) {
Map<String,?> storeProperties = toJavaMap(jsonStorePropertiesByFamily.getJSONObject(key));
format.setStoreProperties(DocumentFamily.valueOf(key), storeProperties);
}
}
addFormat(format);
}
}
private Map<String,?> toJavaMap(JSONObject jsonMap) throws JSONException {
Map<String,Object> map = new HashMap<String,Object>();
for (String key : JSONObject.getNames(jsonMap)) {
Object value = jsonMap.get(key);
if (value instanceof JSONObject) {
map.put(key, toJavaMap((JSONObject) value));
} else {
map.put(key, value);
}
}
return map;
}
}

View File

@@ -1,65 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.document;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class SimpleDocumentFormatRegistry implements DocumentFormatRegistry {
private List<DocumentFormat> documentFormats = new ArrayList<DocumentFormat>();
public void addFormat(DocumentFormat documentFormat) {
documentFormats.add(documentFormat);
}
public DocumentFormat getFormatByExtension(String extension) {
if (extension == null) {
return null;
}
String lowerExtension = extension.toLowerCase();
//TODO keep a documentByExtension map instead
for (DocumentFormat format : documentFormats) {
if (format.getExtension().equals(lowerExtension)) {
return format;
}
}
return null;
}
public DocumentFormat getFormatByMediaType(String mediaType) {
if (mediaType == null) {
return null;
}
//TODO keep a documentByMediaType map instead
for (DocumentFormat format : documentFormats) {
if (format.getMediaType().equals(mediaType)) {
return format;
}
}
return null;
}
public Set<DocumentFormat> getOutputFormats(DocumentFamily family) {
Set<DocumentFormat> formats = new HashSet<DocumentFormat>();
for (DocumentFormat format : documentFormats) {
if (format.getStoreProperties(family) != null) {
formats.add(format);
}
}
return formats;
}
}

View File

@@ -1,223 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
import java.io.File;
import org.artofsolving.jodconverter.process.ProcessManager;
import org.artofsolving.jodconverter.process.PureJavaProcessManager;
import org.artofsolving.jodconverter.process.LinuxProcessManager;
import org.artofsolving.jodconverter.process.SigarProcessManager;
import org.artofsolving.jodconverter.util.PlatformUtils;
public class DefaultOfficeManagerConfiguration {
public static final long DEFAULT_RETRY_TIMEOUT = 120000L;
private File officeHome = OfficeUtils.getDefaultOfficeHome();
private OfficeConnectionProtocol connectionProtocol = OfficeConnectionProtocol.SOCKET;
private int[] portNumbers = new int[] { 2002 };
private String[] pipeNames = new String[] { "office" };
private String[] runAsArgs = null;
private File templateProfileDir = null;
private File workDir = new File(System.getProperty("java.io.tmpdir"));
private long taskQueueTimeout = 30000L; // 30 seconds
private long taskExecutionTimeout = 120000L; // 2 minutes
private int maxTasksPerProcess = 200;
private long retryTimeout = DEFAULT_RETRY_TIMEOUT;
private ProcessManager processManager = null; // lazily initialised
public DefaultOfficeManagerConfiguration setOfficeHome(String officeHome) throws NullPointerException, IllegalArgumentException {
checkArgumentNotNull("officeHome", officeHome);
return setOfficeHome(new File(officeHome));
}
public DefaultOfficeManagerConfiguration setOfficeHome(File officeHome) throws NullPointerException, IllegalArgumentException {
checkArgumentNotNull("officeHome", officeHome);
checkArgument("officeHome", officeHome.isDirectory(), "must exist and be a directory");
this.officeHome = officeHome;
return this;
}
public DefaultOfficeManagerConfiguration setConnectionProtocol(OfficeConnectionProtocol connectionProtocol) throws NullPointerException {
checkArgumentNotNull("connectionProtocol", connectionProtocol);
this.connectionProtocol = connectionProtocol;
return this;
}
public DefaultOfficeManagerConfiguration setPortNumber(int portNumber) {
this.portNumbers = new int[] { portNumber };
return this;
}
public DefaultOfficeManagerConfiguration setPortNumbers(int... portNumbers) throws NullPointerException, IllegalArgumentException {
checkArgumentNotNull("portNumbers", portNumbers);
checkArgument("portNumbers", portNumbers.length > 0, "must not be empty");
this.portNumbers = portNumbers;
return this;
}
public DefaultOfficeManagerConfiguration setPipeName(String pipeName) throws NullPointerException {
checkArgumentNotNull("pipeName", pipeName);
this.pipeNames = new String[] { pipeName };
return this;
}
public DefaultOfficeManagerConfiguration setPipeNames(String... pipeNames) throws NullPointerException, IllegalArgumentException {
checkArgumentNotNull("pipeNames", pipeNames);
checkArgument("pipeNames", pipeNames.length > 0, "must not be empty");
this.pipeNames = pipeNames;
return this;
}
public DefaultOfficeManagerConfiguration setRunAsArgs(String... runAsArgs) {
this.runAsArgs = runAsArgs;
return this;
}
public DefaultOfficeManagerConfiguration setTemplateProfileDir(File templateProfileDir) throws IllegalArgumentException {
if (templateProfileDir != null) {
checkArgument("templateProfileDir", templateProfileDir.isDirectory(), "must exist and be a directory");
}
this.templateProfileDir = templateProfileDir;
return this;
}
/**
* Sets the directory where temporary office profiles will be created.
* <p>
* Defaults to the system temporary directory as specified by the <code>java.io.tmpdir</code> system property.
*
* @param workDir
* @return
*/
public DefaultOfficeManagerConfiguration setWorkDir(File workDir) {
checkArgumentNotNull("workDir", workDir);
this.workDir = workDir;
return this;
}
public DefaultOfficeManagerConfiguration setTaskQueueTimeout(long taskQueueTimeout) {
this.taskQueueTimeout = taskQueueTimeout;
return this;
}
public DefaultOfficeManagerConfiguration setTaskExecutionTimeout(long taskExecutionTimeout) {
this.taskExecutionTimeout = taskExecutionTimeout;
return this;
}
public DefaultOfficeManagerConfiguration setMaxTasksPerProcess(int maxTasksPerProcess) {
this.maxTasksPerProcess = maxTasksPerProcess;
return this;
}
/**
* Provide a specific {@link ProcessManager} implementation
* <p>
* The default is to use {@link SigarProcessManager} if sigar.jar is
* available in the classpath, otherwise {@link LinuxProcessManager}
* on Linux and {@link PureJavaProcessManager} on other platforms.
*
* @param processManager
* @return
* @throws NullPointerException
*/
public DefaultOfficeManagerConfiguration setProcessManager(ProcessManager processManager) throws NullPointerException {
checkArgumentNotNull("processManager", processManager);
this.processManager = processManager;
return this;
}
/**
* Retry timeout set in milliseconds. Used for retrying office process calls.
* If not set, it defaults to 2 minutes
*
* @param retryTimeout in milliseconds
* @return
*/
public DefaultOfficeManagerConfiguration setRetryTimeout(long retryTimeout) {
this.retryTimeout = retryTimeout;
return this;
}
public OfficeManager buildOfficeManager() throws IllegalStateException {
if (officeHome == null) {
throw new IllegalStateException("officeHome not set and could not be auto-detected");
} else if (!officeHome.isDirectory()) {
throw new IllegalStateException("officeHome doesn't exist or is not a directory: " + officeHome);
} else if (!OfficeUtils.getOfficeExecutable(officeHome).isFile()) {
throw new IllegalStateException("invalid officeHome: it doesn't contain soffice.bin: " + officeHome);
}
if (templateProfileDir != null && !isValidProfileDir(templateProfileDir)) {
throw new IllegalStateException("templateProfileDir doesn't appear to contain a user profile: " + templateProfileDir);
}
if (!workDir.isDirectory()) {
throw new IllegalStateException("workDir doesn't exist or is not a directory: " + workDir);
}
if (processManager == null) {
processManager = findBestProcessManager();
}
int numInstances = connectionProtocol == OfficeConnectionProtocol.PIPE ? pipeNames.length : portNumbers.length;
UnoUrl[] unoUrls = new UnoUrl[numInstances];
for (int i = 0; i < numInstances; i++) {
unoUrls[i] = (connectionProtocol == OfficeConnectionProtocol.PIPE) ? UnoUrl.pipe(pipeNames[i]) : UnoUrl.socket(portNumbers[i]);
}
return new ProcessPoolOfficeManager(officeHome, unoUrls, runAsArgs, templateProfileDir, workDir, retryTimeout, taskQueueTimeout, taskExecutionTimeout, maxTasksPerProcess, processManager);
}
private ProcessManager findBestProcessManager() {
if (isSigarAvailable()) {
return new SigarProcessManager();
} else if (PlatformUtils.isLinux()) {
LinuxProcessManager processManager = new LinuxProcessManager();
if (runAsArgs != null) {
processManager.setRunAsArgs(runAsArgs);
}
return processManager;
} else {
// NOTE: UnixProcessManager can't be trusted to work on Solaris
// because of the 80-char limit on ps output there
return new PureJavaProcessManager();
}
}
private boolean isSigarAvailable() {
try {
Class.forName("org.hyperic.sigar.Sigar", false, getClass().getClassLoader());
return true;
} catch (ClassNotFoundException classNotFoundException) {
return false;
}
}
private void checkArgumentNotNull(String argName, Object argValue) throws NullPointerException {
if (argValue == null) {
throw new NullPointerException(argName + " must not be null");
}
}
private void checkArgument(String argName, boolean condition, String message) throws IllegalArgumentException {
if (!condition) {
throw new IllegalArgumentException(argName + " " + message);
}
}
private boolean isValidProfileDir(File profileDir) {
return new File(profileDir, "user").isDirectory();
}
}

View File

@@ -1,86 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
import java.net.ConnectException;
/**
* {@link OfficeManager} implementation that connects to an external Office process.
* <p>
* The external Office process needs to be started manually, e.g. from the command line with
*
* <pre>
* soffice -accept="socket,host=127.0.0.1,port=2002;urp;"
* </pre>
* <p>
* Since this implementation does not manage the Office process, it does not support auto-restarting the process if it exits unexpectedly.
* <p>
* It will however auto-reconnect to the external process if the latter is manually restarted.
* <p>
* This {@link OfficeManager} implementation basically provides the same behaviour as JODConverter 2.x, including using <em>synchronized</em> blocks for serialising office
* operations.
*/
class ExternalOfficeManager implements OfficeManager {
private final OfficeConnection connection;
private final boolean connectOnStart;
/**
* @param unoUrl
* @param connectOnStart
* should a connection be attempted on {@link #start()}? Default is <em>true</em>. If <em>false</em>, a connection will only be attempted the first time an
* {@link OfficeTask} is executed.
*/
public ExternalOfficeManager(UnoUrl unoUrl, boolean connectOnStart) {
connection = new OfficeConnection(unoUrl);
this.connectOnStart = connectOnStart;
}
public void start() throws OfficeException {
if (connectOnStart) {
synchronized (connection) {
connect();
}
}
}
public void stop() {
synchronized (connection) {
if (connection.isConnected()) {
connection.disconnect();
}
}
}
public void execute(OfficeTask task) throws OfficeException {
synchronized (connection) {
if (!connection.isConnected()) {
connect();
}
task.execute(connection);
}
}
private void connect() {
try {
connection.connect();
} catch (ConnectException connectException) {
throw new OfficeException("could not connect to external office process", connectException);
}
}
public boolean isRunning() {
return connection.isConnected();
}
}

View File

@@ -1,47 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
public class ExternalOfficeManagerConfiguration {
private OfficeConnectionProtocol connectionProtocol = OfficeConnectionProtocol.SOCKET;
private int portNumber = 2002;
private String pipeName = "office";
private boolean connectOnStart = true;
public ExternalOfficeManagerConfiguration setConnectionProtocol(OfficeConnectionProtocol connectionProtocol) {
this.connectionProtocol = connectionProtocol;
return this;
}
public ExternalOfficeManagerConfiguration setPortNumber(int portNumber) {
this.portNumber = portNumber;
return this;
}
public ExternalOfficeManagerConfiguration setPipeName(String pipeName) {
this.pipeName = pipeName;
return this;
}
public ExternalOfficeManagerConfiguration setConnectOnStart(boolean connectOnStart) {
this.connectOnStart = connectOnStart;
return this;
}
public OfficeManager buildOfficeManager() {
UnoUrl unoUrl = connectionProtocol == OfficeConnectionProtocol.SOCKET ? UnoUrl.socket(portNumber) : UnoUrl.pipe(pipeName);
return new ExternalOfficeManager(unoUrl, connectOnStart);
}
}

View File

@@ -1,176 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
import java.net.ConnectException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.sun.star.frame.XDesktop;
import com.sun.star.lang.DisposedException;
class ManagedOfficeProcess {
private static final Integer EXIT_CODE_NEW_INSTALLATION = Integer.valueOf(81);
private final ManagedOfficeProcessSettings settings;
private final OfficeProcess process;
private final OfficeConnection connection;
private ExecutorService executor = Executors.newSingleThreadExecutor(new NamedThreadFactory("OfficeProcessThread"));
private final Logger logger = Logger.getLogger(getClass().getName());
public ManagedOfficeProcess(ManagedOfficeProcessSettings settings) throws OfficeException {
this.settings = settings;
process = new OfficeProcess(settings.getOfficeHome(), settings.getUnoUrl(), settings.getRunAsArgs(), settings.getTemplateProfileDir(), settings.getWorkDir(), settings
.getProcessManager());
connection = new OfficeConnection(settings.getUnoUrl());
}
public OfficeConnection getConnection() {
return connection;
}
public void startAndWait() throws OfficeException {
Future<?> future = executor.submit(new Runnable() {
public void run() {
doStartProcessAndConnect();
}
});
try {
future.get();
} catch (Exception exception) {
throw new OfficeException("failed to start and connect", exception);
}
}
public void stopAndWait() throws OfficeException {
Future<?> future = executor.submit(new Runnable() {
public void run() {
doStopProcess();
}
});
try {
future.get();
} catch (Exception exception) {
throw new OfficeException("failed to start and connect", exception);
}
}
public void restartAndWait() {
Future<?> future = executor.submit(new Runnable() {
public void run() {
doStopProcess();
doStartProcessAndConnect();
}
});
try {
future.get();
} catch (Exception exception) {
throw new OfficeException("failed to restart", exception);
}
}
public void restartDueToTaskTimeout() {
executor.execute(new Runnable() {
public void run() {
doTerminateProcess();
// will cause unexpected disconnection and subsequent restart
}
});
}
public void restartDueToLostConnection() {
executor.execute(new Runnable() {
public void run() {
try {
doEnsureProcessExited();
doStartProcessAndConnect();
} catch (OfficeException officeException) {
logger.log(Level.SEVERE, "could not restart process", officeException);
}
}
});
}
private void doStartProcessAndConnect() throws OfficeException {
try {
process.start();
new Retryable() {
protected void attempt() throws TemporaryException, Exception {
try {
connection.connect();
} catch (ConnectException connectException) {
Integer exitCode = process.getExitCode();
if (exitCode == null) {
// process is running; retry later
throw new TemporaryException(connectException);
} else if (exitCode.equals(EXIT_CODE_NEW_INSTALLATION)) {
// restart and retry later
// see http://code.google.com/p/jodconverter/issues/detail?id=84
logger.log(Level.WARNING, "office process died with exit code 81; restarting it");
process.start(true);
throw new TemporaryException(connectException);
} else {
throw new OfficeException("office process died with exit code " + exitCode);
}
}
}
}.execute(settings.getRetryInterval(), settings.getRetryTimeout());
} catch (Exception exception) {
throw new OfficeException("could not establish connection", exception);
}
}
private void doStopProcess() {
try {
XDesktop desktop = OfficeUtils.cast(XDesktop.class, connection.getService(OfficeUtils.SERVICE_DESKTOP));
desktop.terminate();
} catch (DisposedException disposedException) {
// expected
} catch (Exception exception) {
// in case we can't get hold of the desktop
doTerminateProcess();
}
doEnsureProcessExited();
}
private void doEnsureProcessExited() throws OfficeException {
try {
int exitCode = process.getExitCode(settings.getRetryInterval(), settings.getRetryTimeout());
logger.info("process exited with code " + exitCode);
} catch (RetryTimeoutException retryTimeoutException) {
doTerminateProcess();
}
process.deleteProfileDir();
}
private void doTerminateProcess() throws OfficeException {
try {
int exitCode = process.forciblyTerminate(settings.getRetryInterval(), settings.getRetryTimeout());
logger.info("process forcibly terminated with code " + exitCode);
} catch (Exception exception) {
throw new OfficeException("could not terminate process", exception);
}
}
boolean isConnected() {
return connection.isConnected();
}
}

View File

@@ -1,97 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
import java.io.File;
import org.artofsolving.jodconverter.process.ProcessManager;
import org.artofsolving.jodconverter.process.PureJavaProcessManager;
class ManagedOfficeProcessSettings {
public static final long DEFAULT_RETRY_INTERVAL = 250L;
private final UnoUrl unoUrl;
private File officeHome = OfficeUtils.getDefaultOfficeHome();
private String[] runAsArgs;
private File templateProfileDir;
private File workDir = new File(System.getProperty("java.io.tmpdir"));
private ProcessManager processManager = new PureJavaProcessManager();
private long retryTimeout = DefaultOfficeManagerConfiguration.DEFAULT_RETRY_TIMEOUT;
private long retryInterval = DEFAULT_RETRY_INTERVAL;
public ManagedOfficeProcessSettings(UnoUrl unoUrl) {
this.unoUrl = unoUrl;
}
public UnoUrl getUnoUrl() {
return unoUrl;
}
public File getOfficeHome() {
return officeHome;
}
public void setOfficeHome(File officeHome) {
this.officeHome = officeHome;
}
public String[] getRunAsArgs() {
return runAsArgs;
}
public void setRunAsArgs(String[] runAsArgs) {
this.runAsArgs = runAsArgs;
}
public File getTemplateProfileDir() {
return templateProfileDir;
}
public void setTemplateProfileDir(File templateProfileDir) {
this.templateProfileDir = templateProfileDir;
}
public File getWorkDir() {
return workDir;
}
public void setWorkDir(File workDir) {
this.workDir = workDir;
}
public ProcessManager getProcessManager() {
return processManager;
}
public void setProcessManager(ProcessManager processManager) {
this.processManager = processManager;
}
public long getRetryTimeout() {
return retryTimeout;
}
public void setRetryTimeout(long retryTimeout) {
this.retryTimeout = retryTimeout;
}
public long getRetryInterval() {
return retryInterval;
}
public void setRetryInterval(long retryInterval) {
this.retryInterval = retryInterval;
}
}

View File

@@ -1,43 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
/**
* A {@link ThreadFactory} that allows for custom thread names
*/
class NamedThreadFactory implements ThreadFactory {
private static final AtomicInteger threadIndex = new AtomicInteger(0);
private final String baseName;
private final boolean daemon;
public NamedThreadFactory(String baseName) {
this(baseName, true);
}
public NamedThreadFactory(String baseName, boolean daemon) {
this.baseName = baseName;
this.daemon = daemon;
}
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable, baseName + "-" + threadIndex.getAndIncrement());
thread.setDaemon(daemon);
return thread;
}
}

View File

@@ -1,117 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
import java.net.ConnectException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;
import com.sun.star.beans.XPropertySet;
import com.sun.star.bridge.XBridge;
import com.sun.star.bridge.XBridgeFactory;
import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.connection.NoConnectException;
import com.sun.star.connection.XConnection;
import com.sun.star.connection.XConnector;
import com.sun.star.lang.EventObject;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XEventListener;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.XComponentContext;
class OfficeConnection implements OfficeContext {
private static AtomicInteger bridgeIndex = new AtomicInteger();
private final UnoUrl unoUrl;
private XComponent bridgeComponent;
private XMultiComponentFactory serviceManager;
private XComponentContext componentContext;
private final List<OfficeConnectionEventListener> connectionEventListeners = new ArrayList<OfficeConnectionEventListener>();
private volatile boolean connected = false;
private XEventListener bridgeListener = new XEventListener() {
public void disposing(EventObject event) {
if (connected) {
connected = false;
logger.info(String.format("disconnected: '%s'", unoUrl));
OfficeConnectionEvent connectionEvent = new OfficeConnectionEvent(OfficeConnection.this);
for (OfficeConnectionEventListener listener : connectionEventListeners) {
listener.disconnected(connectionEvent);
}
}
// else we tried to connect to a server that doesn't speak URP
}
};
private final Logger logger = Logger.getLogger(getClass().getName());
public OfficeConnection(UnoUrl unoUrl) {
this.unoUrl = unoUrl;
}
public void addConnectionEventListener(OfficeConnectionEventListener connectionEventListener) {
connectionEventListeners.add(connectionEventListener);
}
public void connect() throws ConnectException {
logger.fine(String.format("connecting with connectString '%s'", unoUrl));
try {
XComponentContext localContext = Bootstrap.createInitialComponentContext(null);
XMultiComponentFactory localServiceManager = localContext.getServiceManager();
XConnector connector = OfficeUtils.cast(XConnector.class, localServiceManager.createInstanceWithContext("com.sun.star.connection.Connector", localContext));
XConnection connection = connector.connect(unoUrl.getConnectString());
XBridgeFactory bridgeFactory = OfficeUtils.cast(XBridgeFactory.class, localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext));
String bridgeName = "jodconverter_" + bridgeIndex.getAndIncrement();
XBridge bridge = bridgeFactory.createBridge(bridgeName, "urp", connection, null);
bridgeComponent = OfficeUtils.cast(XComponent.class, bridge);
bridgeComponent.addEventListener(bridgeListener);
serviceManager = OfficeUtils.cast(XMultiComponentFactory.class, bridge.getInstance("StarOffice.ServiceManager"));
XPropertySet properties = OfficeUtils.cast(XPropertySet.class, serviceManager);
componentContext = OfficeUtils.cast(XComponentContext.class, properties.getPropertyValue("DefaultContext"));
connected = true;
logger.info(String.format("connected: '%s'", unoUrl));
OfficeConnectionEvent connectionEvent = new OfficeConnectionEvent(this);
for (OfficeConnectionEventListener listener : connectionEventListeners) {
listener.connected(connectionEvent);
}
} catch (NoConnectException connectException) {
throw new ConnectException(String.format("connection failed: '%s'; %s", unoUrl, connectException.getMessage()));
} catch (Exception exception) {
throw new OfficeException("connection failed: "+ unoUrl, exception);
}
}
public boolean isConnected() {
return connected;
}
public synchronized void disconnect() {
logger.fine(String.format("disconnecting: '%s'", unoUrl));
bridgeComponent.dispose();
}
public Object getService(String serviceName) {
try {
return serviceManager.createInstanceWithContext(serviceName, componentContext);
} catch (Exception exception) {
throw new OfficeException(String.format("failed to obtain service '%s'", serviceName), exception);
}
}
}

View File

@@ -1,25 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
import java.util.EventObject;
class OfficeConnectionEvent extends EventObject {
private static final long serialVersionUID = 2060652797570876077L;
public OfficeConnectionEvent(OfficeConnection source) {
super(source);
}
}

View File

@@ -1,23 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
import java.util.EventListener;
interface OfficeConnectionEventListener extends EventListener {
void connected(OfficeConnectionEvent event);
void disconnected(OfficeConnectionEvent event);
}

View File

@@ -1,15 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
public enum OfficeConnectionProtocol { PIPE, SOCKET }

View File

@@ -1,19 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
public interface OfficeContext {
Object getService(String serviceName);
}

View File

@@ -1,26 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
public class OfficeException extends RuntimeException {
private static final long serialVersionUID = 1L;
public OfficeException(String message) {
super(message);
}
public OfficeException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@@ -1,30 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
/**
* An OfficeManager knows how to execute {@link OfficeTask}s.
* <p>
* An OfficeManager implementation will typically manage one or more
* {@link OfficeConnection}s.
*/
public interface OfficeManager {
void execute(OfficeTask task) throws OfficeException;
void start() throws OfficeException;
void stop() throws OfficeException;
boolean isRunning();
}

View File

@@ -1,209 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
import static org.artofsolving.jodconverter.process.ProcessManager.PID_NOT_FOUND;
import static org.artofsolving.jodconverter.process.ProcessManager.PID_UNKNOWN;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.apache.commons.io.FileUtils;
import org.artofsolving.jodconverter.process.ProcessManager;
import org.artofsolving.jodconverter.process.ProcessQuery;
import org.artofsolving.jodconverter.util.PlatformUtils;
class OfficeProcess {
private final File officeHome;
private final UnoUrl unoUrl;
private final String[] runAsArgs;
private final File templateProfileDir;
private final File instanceProfileDir;
private final ProcessManager processManager;
private Process process;
private long pid = PID_UNKNOWN;
private final Logger logger = Logger.getLogger(getClass().getName());
public OfficeProcess(File officeHome, UnoUrl unoUrl, String[] runAsArgs, File templateProfileDir, File workDir, ProcessManager processManager) {
this.officeHome = officeHome;
this.unoUrl = unoUrl;
this.runAsArgs = runAsArgs;
this.templateProfileDir = templateProfileDir;
this.instanceProfileDir = getInstanceProfileDir(workDir, unoUrl);
this.processManager = processManager;
}
public void start() throws IOException {
start(false);
}
public void start(boolean restart) throws IOException {
ProcessQuery processQuery = new ProcessQuery("soffice.bin", unoUrl.getAcceptString());
long existingPid = processManager.findPid(processQuery);
if (!(existingPid == PID_NOT_FOUND || existingPid == PID_UNKNOWN)) {
throw new IllegalStateException(String.format("a process with acceptString '%s' is already running; pid %d",
unoUrl.getAcceptString(), existingPid));
}
if (!restart) {
prepareInstanceProfileDir();
}
List<String> command = new ArrayList<String>();
File executable = OfficeUtils.getOfficeExecutable(officeHome);
if (runAsArgs != null) {
command.addAll(Arrays.asList(runAsArgs));
}
command.add(executable.getAbsolutePath());
command.add("-accept=" + unoUrl.getAcceptString() + ";urp;");
command.add("-env:UserInstallation=" + OfficeUtils.toUrl(instanceProfileDir));
command.add("-headless");
command.add("-nocrashreport");
command.add("-nodefault");
command.add("-nofirststartwizard");
command.add("-nolockcheck");
command.add("-nologo");
command.add("-norestore");
ProcessBuilder processBuilder = new ProcessBuilder(command);
if (PlatformUtils.isWindows()) {
addBasisAndUrePaths(processBuilder);
}
logger.info(String.format("starting process with acceptString '%s' and profileDir '%s'", unoUrl, instanceProfileDir));
process = processBuilder.start();
pid = processManager.findPid(processQuery);
if (pid == PID_NOT_FOUND) {
throw new IllegalStateException(String.format("process with acceptString '%s' started but its pid could not be found",
unoUrl.getAcceptString()));
}
logger.info("started process" + (pid != PID_UNKNOWN ? "; pid = " + pid : ""));
}
private File getInstanceProfileDir(File workDir, UnoUrl unoUrl) {
String dirName = ".jodconverter_" + unoUrl.getAcceptString().replace(',', '_').replace('=', '-');
return new File(workDir, dirName);
}
private void prepareInstanceProfileDir() throws OfficeException {
if (instanceProfileDir.exists()) {
logger.warning(String.format("profile dir '%s' already exists; deleting", instanceProfileDir));
deleteProfileDir();
}
if (templateProfileDir != null) {
try {
FileUtils.copyDirectory(templateProfileDir, instanceProfileDir);
} catch (IOException ioException) {
throw new OfficeException("failed to create profileDir", ioException);
}
}
}
public void deleteProfileDir() {
if (instanceProfileDir != null) {
try {
FileUtils.deleteDirectory(instanceProfileDir);
} catch (IOException ioException) {
File oldProfileDir = new File(instanceProfileDir.getParentFile(), instanceProfileDir.getName() + ".old." + System.currentTimeMillis());
if (instanceProfileDir.renameTo(oldProfileDir)) {
logger.warning("could not delete profileDir: " + ioException.getMessage() + "; renamed it to " + oldProfileDir);
} else {
logger.severe("could not delete profileDir: " + ioException.getMessage());
}
}
}
}
private void addBasisAndUrePaths(ProcessBuilder processBuilder) throws IOException {
// see http://wiki.services.openoffice.org/wiki/ODF_Toolkit/Efforts/Three-Layer_OOo
File basisLink = new File(officeHome, "basis-link");
if (!basisLink.isFile()) {
logger.fine("no %OFFICE_HOME%/basis-link found; assuming it's OOo 2.x and we don't need to append URE and Basic paths");
return;
}
String basisLinkText = FileUtils.readFileToString(basisLink).trim();
File basisHome = new File(officeHome, basisLinkText);
File basisProgram = new File(basisHome, "program");
File ureLink = new File(basisHome, "ure-link");
String ureLinkText = FileUtils.readFileToString(ureLink).trim();
File ureHome = new File(basisHome, ureLinkText);
File ureBin = new File(ureHome, "bin");
Map<String,String> environment = processBuilder.environment();
// Windows environment variables are case insensitive but Java maps are not :-/
// so let's make sure we modify the existing key
String pathKey = "PATH";
for (String key : environment.keySet()) {
if ("PATH".equalsIgnoreCase(key)) {
pathKey = key;
}
}
String path = environment.get(pathKey) + ";" + ureBin.getAbsolutePath() + ";" + basisProgram.getAbsolutePath();
logger.fine(String.format("setting %s to \"%s\"", pathKey, path));
environment.put(pathKey, path);
}
public boolean isRunning() {
if (process == null) {
return false;
}
return getExitCode() == null;
}
private class ExitCodeRetryable extends Retryable {
private int exitCode;
protected void attempt() throws TemporaryException, Exception {
try {
exitCode = process.exitValue();
} catch (IllegalThreadStateException illegalThreadStateException) {
throw new TemporaryException(illegalThreadStateException);
}
}
public int getExitCode() {
return exitCode;
}
}
public Integer getExitCode() {
try {
return process.exitValue();
} catch (IllegalThreadStateException exception) {
return null;
}
}
public int getExitCode(long retryInterval, long retryTimeout) throws RetryTimeoutException {
try {
ExitCodeRetryable retryable = new ExitCodeRetryable();
retryable.execute(retryInterval, retryTimeout);
return retryable.getExitCode();
} catch (RetryTimeoutException retryTimeoutException) {
throw retryTimeoutException;
} catch (Exception exception) {
throw new OfficeException("could not get process exit code", exception);
}
}
public int forciblyTerminate(long retryInterval, long retryTimeout) throws IOException, RetryTimeoutException {
logger.info(String.format("trying to forcibly terminate process: '" + unoUrl + "'" + (pid != PID_UNKNOWN ? " (pid " + pid + ")" : "")));
processManager.kill(process, pid);
return getExitCode(retryInterval, retryTimeout);
}
}

View File

@@ -1,19 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
public interface OfficeTask {
void execute(OfficeContext context) throws OfficeException;
}

View File

@@ -1,111 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
import java.io.File;
import java.util.Map;
import org.artofsolving.jodconverter.util.PlatformUtils;
import com.sun.star.beans.PropertyValue;
import com.sun.star.uno.UnoRuntime;
public class OfficeUtils {
public static final String SERVICE_DESKTOP = "com.sun.star.frame.Desktop";
private OfficeUtils() {
throw new AssertionError("utility class must not be instantiated");
}
public static <T> T cast(Class<T> type, Object object) {
return (T) UnoRuntime.queryInterface(type, object);
}
public static PropertyValue property(String name, Object value) {
PropertyValue propertyValue = new PropertyValue();
propertyValue.Name = name;
propertyValue.Value = value;
return propertyValue;
}
@SuppressWarnings("unchecked")
public static PropertyValue[] toUnoProperties(Map<String,?> properties) {
PropertyValue[] propertyValues = new PropertyValue[properties.size()];
int i = 0;
for (Map.Entry<String,?> entry : properties.entrySet()) {
Object value = entry.getValue();
if (value instanceof Map) {
Map<String,Object> subProperties = (Map<String,Object>) value;
value = toUnoProperties(subProperties);
}
propertyValues[i++] = property((String) entry.getKey(), value);
}
return propertyValues;
}
public static String toUrl(File file) {
String path = file.toURI().getRawPath();
String url = path.startsWith("//") ? "file:" + path : "file://" + path;
return url.endsWith("/") ? url.substring(0, url.length() - 1) : url;
}
public static File getDefaultOfficeHome() {
if (System.getProperty("office.home") != null) {
return new File(System.getProperty("office.home"));
}
if (PlatformUtils.isWindows()) {
// %ProgramFiles(x86)% on 64-bit machines; %ProgramFiles% on 32-bit ones
String programFiles = System.getenv("ProgramFiles(x86)");
if (programFiles == null) {
programFiles = System.getenv("ProgramFiles");
}
return findOfficeHome(
programFiles + File.separator + "OpenOffice 4",
programFiles + File.separator + "LibreOffice 4"
);
} else if (PlatformUtils.isMac()) {
return findOfficeHome(
"/Applications/OpenOffice.org.app/Contents",
"/Applications/LibreOffice.app/Contents"
);
} else {
// Linux or other *nix variants
return findOfficeHome(
"/opt/openoffice.org3",
"/opt/libreoffice",
"/usr/lib/openoffice",
"/usr/lib/libreoffice"
);
}
}
private static File findOfficeHome(String... knownPaths) {
for (String path : knownPaths) {
File home = new File(path);
if (getOfficeExecutable(home).isFile()) {
return home;
}
}
return null;
}
public static File getOfficeExecutable(File officeHome) {
if (PlatformUtils.isMac()) {
return new File(officeHome, "MacOS/soffice.bin");
} else {
return new File(officeHome, "program/soffice.bin");
}
}
}

View File

@@ -1,110 +0,0 @@
//
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
class PooledOfficeManager implements OfficeManager {
private final PooledOfficeManagerSettings settings;
private final ManagedOfficeProcess managedOfficeProcess;
private final SuspendableThreadPoolExecutor taskExecutor;
private volatile boolean stopping = false;
private int taskCount;
private Future<?> currentTask;
private final Logger logger = Logger.getLogger(getClass().getName());
private OfficeConnectionEventListener connectionEventListener = new OfficeConnectionEventListener() {
public void connected(OfficeConnectionEvent event) {
taskCount = 0;
taskExecutor.setAvailable(true);
}
public void disconnected(OfficeConnectionEvent event) {
taskExecutor.setAvailable(false);
if (stopping) {
// expected
stopping = false;
} else {
logger.warning("connection lost unexpectedly; attempting restart");
if (currentTask != null) {
currentTask.cancel(true);
}
managedOfficeProcess.restartDueToLostConnection();
}
}
};
public PooledOfficeManager(UnoUrl unoUrl) {
this(new PooledOfficeManagerSettings(unoUrl));
}
public PooledOfficeManager(PooledOfficeManagerSettings settings) {
this.settings = settings;
managedOfficeProcess = new ManagedOfficeProcess(settings);
managedOfficeProcess.getConnection().addConnectionEventListener(connectionEventListener);
taskExecutor = new SuspendableThreadPoolExecutor(new NamedThreadFactory("OfficeTaskThread"));
}
public void execute(final OfficeTask task) throws OfficeException {
Future<?> futureTask = taskExecutor.submit(new Runnable() {
public void run() {
if (settings.getMaxTasksPerProcess() > 0 && ++taskCount == settings.getMaxTasksPerProcess() + 1) {
logger.info(String.format("reached limit of %d maxTasksPerProcess: restarting", settings.getMaxTasksPerProcess()));
taskExecutor.setAvailable(false);
stopping = true;
managedOfficeProcess.restartAndWait();
//FIXME taskCount will be 0 rather than 1 at this point
}
task.execute(managedOfficeProcess.getConnection());
}
});
currentTask = futureTask;
try {
futureTask.get(settings.getTaskExecutionTimeout(), TimeUnit.MILLISECONDS);
} catch (TimeoutException timeoutException) {
managedOfficeProcess.restartDueToTaskTimeout();
throw new OfficeException("task did not complete within timeout", timeoutException);
} catch (ExecutionException executionException) {
if (executionException.getCause() instanceof OfficeException) {
throw (OfficeException) executionException.getCause();
} else {
throw new OfficeException("task failed", executionException.getCause());
}
} catch (Exception exception) {
throw new OfficeException("task failed", exception);
}
}
public void start() throws OfficeException {
managedOfficeProcess.startAndWait();
}
public void stop() throws OfficeException {
taskExecutor.setAvailable(false);
stopping = true;
taskExecutor.shutdownNow();
managedOfficeProcess.stopAndWait();
}
public boolean isRunning() {
return managedOfficeProcess.isConnected();
}
}

View File

@@ -1,43 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
class PooledOfficeManagerSettings extends ManagedOfficeProcessSettings {
public static final long DEFAULT_TASK_EXECUTION_TIMEOUT = 120000L;
public static final int DEFAULT_MAX_TASKS_PER_PROCESS = 200;
private long taskExecutionTimeout = DEFAULT_TASK_EXECUTION_TIMEOUT;
private int maxTasksPerProcess = DEFAULT_MAX_TASKS_PER_PROCESS;
public PooledOfficeManagerSettings(UnoUrl unoUrl) {
super(unoUrl);
}
public long getTaskExecutionTimeout() {
return taskExecutionTimeout;
}
public void setTaskExecutionTimeout(long taskExecutionTimeout) {
this.taskExecutionTimeout = taskExecutionTimeout;
}
public int getMaxTasksPerProcess() {
return maxTasksPerProcess;
}
public void setMaxTasksPerProcess(int maxTasksPerProcess) {
this.maxTasksPerProcess = maxTasksPerProcess;
}
}

View File

@@ -1,110 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
import java.io.File;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import org.artofsolving.jodconverter.process.ProcessManager;
class ProcessPoolOfficeManager implements OfficeManager {
private final BlockingQueue<PooledOfficeManager> pool;
private final PooledOfficeManager[] pooledManagers;
private final long taskQueueTimeout;
private volatile boolean running = false;
private final Logger logger = Logger.getLogger(ProcessPoolOfficeManager.class.getName());
public ProcessPoolOfficeManager(File officeHome, UnoUrl[] unoUrls, String[] runAsArgs, File templateProfileDir, File workDir,
long retryTimeout, long taskQueueTimeout, long taskExecutionTimeout, int maxTasksPerProcess,
ProcessManager processManager) {
this.taskQueueTimeout = taskQueueTimeout;
pool = new ArrayBlockingQueue<PooledOfficeManager>(unoUrls.length);
pooledManagers = new PooledOfficeManager[unoUrls.length];
for (int i = 0; i < unoUrls.length; i++) {
PooledOfficeManagerSettings settings = new PooledOfficeManagerSettings(unoUrls[i]);
settings.setRunAsArgs(runAsArgs);
settings.setTemplateProfileDir(templateProfileDir);
settings.setWorkDir(workDir);
settings.setOfficeHome(officeHome);
settings.setRetryTimeout(retryTimeout);
settings.setTaskExecutionTimeout(taskExecutionTimeout);
settings.setMaxTasksPerProcess(maxTasksPerProcess);
settings.setProcessManager(processManager);
pooledManagers[i] = new PooledOfficeManager(settings);
}
logger.info("ProcessManager implementation is " + processManager.getClass().getSimpleName());
}
public synchronized void start() throws OfficeException {
for (int i = 0; i < pooledManagers.length; i++) {
pooledManagers[i].start();
releaseManager(pooledManagers[i]);
}
running = true;
}
public void execute(OfficeTask task) throws IllegalStateException, OfficeException {
if (!running) {
throw new IllegalStateException("this OfficeManager is currently stopped");
}
PooledOfficeManager manager = null;
try {
manager = acquireManager();
if (manager == null) {
throw new OfficeException("no office manager available");
}
manager.execute(task);
} finally {
if (manager != null) {
releaseManager(manager);
}
}
}
public synchronized void stop() throws OfficeException {
running = false;
logger.info("stopping");
pool.clear();
for (int i = 0; i < pooledManagers.length; i++) {
pooledManagers[i].stop();
}
logger.info("stopped");
}
private PooledOfficeManager acquireManager() {
try {
return pool.poll(taskQueueTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException interruptedException) {
throw new OfficeException("interrupted", interruptedException);
}
}
private void releaseManager(PooledOfficeManager manager) {
try {
pool.put(manager);
} catch (InterruptedException interruptedException) {
throw new OfficeException("interrupted", interruptedException);
}
}
public boolean isRunning() {
return running;
}
}

View File

@@ -1,23 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
class RetryTimeoutException extends Exception {
private static final long serialVersionUID = -3704437769955257514L;
public RetryTimeoutException(Throwable cause) {
super(cause);
}
}

View File

@@ -1,55 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
abstract class Retryable {
/**
* @throws TemporaryException for an error condition that can be temporary - i.e. retrying later could be successful
* @throws Exception for all other error conditions
*/
protected abstract void attempt() throws TemporaryException, Exception;
public void execute(long interval, long timeout) throws RetryTimeoutException, Exception {
execute(0L, interval, timeout);
}
public void execute(long delay, long interval, long timeout) throws RetryTimeoutException, Exception {
long start = System.currentTimeMillis();
if (delay > 0L) {
sleep(delay);
}
while (true) {
try {
attempt();
return;
} catch (TemporaryException temporaryException) {
if (System.currentTimeMillis() - start < timeout) {
sleep(interval);
// continue
} else {
throw new RetryTimeoutException(temporaryException.getCause());
}
}
}
}
private void sleep(long millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException interruptedException) {
// continue
}
}
}

View File

@@ -1,59 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
class SuspendableThreadPoolExecutor extends ThreadPoolExecutor {
private boolean available = false;
private ReentrantLock suspendLock = new ReentrantLock();
private Condition availableCondition = suspendLock.newCondition();
public SuspendableThreadPoolExecutor(ThreadFactory threadFactory) {
super(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), threadFactory);
}
@Override
protected void beforeExecute(Thread thread, Runnable task) {
super.beforeExecute(thread, task);
suspendLock.lock();
try {
while (!available) {
availableCondition.await();
}
} catch (InterruptedException interruptedException) {
thread.interrupt();
} finally {
suspendLock.unlock();
}
}
public void setAvailable(boolean available) {
suspendLock.lock();
try {
this.available = available;
if (available) {
availableCondition.signalAll();
}
} finally {
suspendLock.unlock();
}
}
}

View File

@@ -1,32 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
import java.math.BigDecimal;
/**
* Represents an error condition that can be temporary, i.e. that could go
* away by simply retrying the same operation after an interval.
*/
class TemporaryException extends Exception {
private static final long serialVersionUID = 7237380113208327295L;
public TemporaryException(Throwable cause) {
super(cause);
}
public static void main(String[] args) {
System.out.println(new BigDecimal("7412611111110.99"));
}
}

View File

@@ -1,62 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.office;
/**
* Encapsulates the UNO Interprocess Connection type and parameters.
* <p>
* OpenOffice.org supports two connection types: TCP sockets and named pipes.
* Named pipes are marginally faster and do not take up a TCP port, but they
* require native libraries, which means setting <em>java.library.path</em>
* when starting Java. E.g. on Linux
* <pre>
* java -Djava.library.path=/opt/openoffice.org/ure/lib ...
* </pre>
* <p>
* See <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Opening_a_Connection">Opening a Connection</a>
* in the OpenOffice.org Developer's Guide for more details.
*/
class UnoUrl {
private final String acceptString;
private final String connectString;
private UnoUrl(String acceptString, String connectString) {
this.acceptString = acceptString;
this.connectString = connectString;
}
public static UnoUrl socket(int port) {
String socketString = "socket,host=127.0.0.1,port=" + port;
return new UnoUrl(socketString, socketString + ",tcpNoDelay=1");
}
public static UnoUrl pipe(String pipeName) {
String pipeString = "pipe,name=" + pipeName;
return new UnoUrl(pipeString, pipeString);
}
public String getAcceptString() {
return acceptString;
}
public String getConnectString() {
return connectString;
}
@Override
public String toString() {
return connectString;
}
}

View File

@@ -1,82 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.process;
import java.io.IOException;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.io.IOUtils;
/**
* {@link ProcessManager} implementation for Linux. Uses the <tt>ps</tt>
* and <tt>kill</tt> commands.
* <p>
* Should Work on Solaris too, except that the command line string
* returned by <tt>ps</tt> there is limited to 80 characters and this affects
* {@link #findPid(String)}.
*/
public class LinuxProcessManager implements ProcessManager {
private static final Pattern PS_OUTPUT_LINE = Pattern.compile("^\\s*(\\d+)\\s+(.*)$");
private String[] runAsArgs;
public void setRunAsArgs(String... runAsArgs) {
this.runAsArgs = runAsArgs;
}
protected String[] psCommand() {
return new String[] { "/bin/ps", "-e", "-o", "pid,args" };
}
public long findPid(ProcessQuery query) throws IOException {
String regex = Pattern.quote(query.getCommand()) + ".*" + Pattern.quote(query.getArgument());
Pattern commandPattern = Pattern.compile(regex);
for (String line : execute(psCommand())) {
Matcher lineMatcher = PS_OUTPUT_LINE.matcher(line);
if (lineMatcher.matches()) {
String command = lineMatcher.group(2);
Matcher commandMatcher = commandPattern.matcher(command);
if (commandMatcher.find()) {
return Long.parseLong(lineMatcher.group(1));
}
}
}
return PID_NOT_FOUND;
}
public void kill(Process process, long pid) throws IOException {
if (pid <= 0) {
throw new IllegalArgumentException("invalid pid: " + pid);
}
execute("/bin/kill", "-KILL", Long.toString(pid));
}
private List<String> execute(String... args) throws IOException {
String[] command;
if (runAsArgs != null) {
command = new String[runAsArgs.length + args.length];
System.arraycopy(runAsArgs, 0, command, 0, runAsArgs.length);
System.arraycopy(args, 0, command, runAsArgs.length, args.length);
} else {
command = args;
}
Process process = new ProcessBuilder(command).start();
@SuppressWarnings("unchecked")
List<String> lines = IOUtils.readLines(process.getInputStream());
return lines;
}
}

View File

@@ -1,32 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.process;
import java.io.IOException;
public interface ProcessManager {
public static final long PID_NOT_FOUND = -2;
public static final long PID_UNKNOWN = -1;
void kill(Process process, long pid) throws IOException;
/**
* @param query
* @return the pid if found, {@link #PID_NOT_FOUND} if not,
* or {@link #PID_UNKNOWN} if this implementation is unable to find out
* @throws IOException
*/
long findPid(ProcessQuery query) throws IOException;
}

View File

@@ -1,33 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.process;
public class ProcessQuery {
private final String command;
private final String argument;
public ProcessQuery(String command, String argument) {
this.command = command;
this.argument = argument;
}
public String getCommand() {
return command;
}
public String getArgument() {
return argument;
}
}

View File

@@ -1,25 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.process;
public class PureJavaProcessManager implements ProcessManager {
public long findPid(ProcessQuery query) {
return PID_UNKNOWN;
}
public void kill(Process process, long pid) {
process.destroy();
}
}

View File

@@ -1,71 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.process;
import java.io.IOException;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.ptql.ProcessFinder;
/**
* {@link ProcessManager} implementation that uses the SIGAR library.
* <p>
* Requires the sigar.jar in the classpath and the appropriate system-specific
* native library (e.g. <tt>libsigar-x86-linux.so</tt> on Linux x86) available
* in the <em>java.library.path</em>.
* <p>
* See the <a href="http://support.hyperic.com/display/SIGAR">SIGAR site</a>
* for documentation and downloads.
*/
public class SigarProcessManager implements ProcessManager {
public long findPid(ProcessQuery query) throws IOException {
Sigar sigar = new Sigar();
try {
long[] pids = ProcessFinder.find(sigar, "State.Name.eq=" + query.getCommand());
for (int i = 0; i < pids.length; i++) {
String[] arguments = sigar.getProcArgs(pids[i]);
if (arguments != null && argumentMatches(arguments, query.getArgument())) {
return pids[i];
}
}
return PID_NOT_FOUND;
} catch (SigarException sigarException) {
throw new IOException("findPid failed", sigarException);
} finally {
sigar.close();
}
}
public void kill(Process process, long pid) throws IOException {
Sigar sigar = new Sigar();
try {
sigar.kill(pid, Sigar.getSigNum("KILL"));
} catch (SigarException sigarException) {
throw new IOException("kill failed", sigarException);
} finally {
sigar.close();
}
}
private boolean argumentMatches(String[] arguments, String expected) {
for (String argument : arguments) {
if (argument.contains(expected)) {
return true;
}
}
return false;
}
}

View File

@@ -1,35 +0,0 @@
//
// JODConverter - Java OpenDocument Converter
// Copyright 2004-2012 Mirko Nasato and contributors
//
// JODConverter is Open Source software, you can redistribute it and/or
// modify it under either (at your option) of the following licenses
//
// 1. The GNU Lesser General Public License v3 (or later)
// -> http://www.gnu.org/licenses/lgpl-3.0.txt
// 2. The Apache License, Version 2.0
// -> http://www.apache.org/licenses/LICENSE-2.0.txt
//
package org.artofsolving.jodconverter.util;
public class PlatformUtils {
private static final String OS_NAME = System.getProperty("os.name").toLowerCase();
private PlatformUtils() {
throw new AssertionError("utility class must not be instantiated");
}
public static boolean isLinux() {
return OS_NAME.startsWith("linux");
}
public static boolean isMac() {
return OS_NAME.startsWith("mac");
}
public static boolean isWindows() {
return OS_NAME.startsWith("windows");
}
}

View File

@@ -1,188 +0,0 @@
[
{
"name": "Portable Document Format",
"extension": "pdf",
"mediaType": "application/pdf",
"storePropertiesByFamily": {
"DRAWING": {"FilterName": "draw_pdf_Export"},
"SPREADSHEET": {"FilterName": "calc_pdf_Export"},
"PRESENTATION": {"FilterName": "impress_pdf_Export"},
"TEXT": {"FilterName": "writer_pdf_Export"}
}
},
{
"name": "Macromedia Flash",
"extension": "swf",
"mediaType": "application/x-shockwave-flash",
"storePropertiesByFamily": {
"DRAWING": {"FilterName": "draw_flash_Export"},
"PRESENTATION": {"FilterName": "impress_flash_Export"}
}
},
{
"name": "HTML",
"extension": "html",
"mediaType": "text/html",
"inputFamily": "TEXT",
"storePropertiesByFamily": {
"SPREADSHEET": {"FilterName": "HTML (StarCalc)"},
"PRESENTATION": {"FilterName": "impress_html_Export"},
"TEXT": {"FilterName": "HTML (StarWriter)"}
}
},
{
"name": "OpenDocument Text",
"extension": "odt",
"mediaType": "application/vnd.oasis.opendocument.text",
"inputFamily": "TEXT",
"storePropertiesByFamily": {"TEXT": {"FilterName": "writer8"}}
},
{
"name": "OpenOffice.org 1.0 Text Document",
"extension": "sxw",
"mediaType": "application/vnd.sun.xml.writer",
"inputFamily": "TEXT",
"storePropertiesByFamily": {"TEXT": {"FilterName": "StarOffice XML (Writer)"}}
},
{
"name": "Microsoft Word",
"extension": "doc",
"mediaType": "application/msword",
"inputFamily": "TEXT",
"storePropertiesByFamily": {"TEXT": {"FilterName": "MS Word 97"}}
},
{
"name": "Microsoft Word 2007 XML",
"extension": "docx",
"mediaType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"inputFamily": "TEXT"
},
{
"name": "Rich Text Format",
"extension": "rtf",
"mediaType": "text/rtf",
"inputFamily": "TEXT",
"storePropertiesByFamily": {"TEXT": {"FilterName": "Rich Text Format"}}
},
{
"name": "WordPerfect",
"extension": "wpd",
"mediaType": "application/wordperfect",
"inputFamily": "TEXT"
},
{
"name": "Plain Text",
"extension": "txt",
"mediaType": "text/plain",
"inputFamily": "TEXT",
"loadProperties": {
"FilterName": "Text (encoded)",
"FilterOptions": "utf8"
},
"storePropertiesByFamily": {"TEXT": {
"FilterName": "Text (encoded)",
"FilterOptions": "utf8"
}}
},
{
"name": "MediaWiki wikitext",
"extension": "wiki",
"mediaType": "text/x-wiki",
"storePropertiesByFamily": {"TEXT": {"FilterName": "MediaWiki"}}
},
{
"name": "OpenDocument Spreadsheet",
"extension": "ods",
"mediaType": "application/vnd.oasis.opendocument.spreadsheet",
"inputFamily": "SPREADSHEET",
"storePropertiesByFamily": {"SPREADSHEET": {"FilterName": "calc8"}}
},
{
"name": "OpenOffice.org 1.0 Spreadsheet",
"extension": "sxc",
"mediaType": "application/vnd.sun.xml.calc",
"inputFamily": "SPREADSHEET",
"storePropertiesByFamily": {"SPREADSHEET": {"FilterName": "StarOffice XML (Calc)"}}
},
{
"name": "Microsoft Excel",
"extension": "xls",
"mediaType": "application/vnd.ms-excel",
"inputFamily": "SPREADSHEET",
"storePropertiesByFamily": {"SPREADSHEET": {"FilterName": "MS Excel 97"}}
},
{
"name": "Microsoft Excel 2007 XML",
"extension": "xlsx",
"mediaType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"inputFamily": "SPREADSHEET"
},
{
"name": "Comma Separated Values",
"extension": "csv",
"mediaType": "text/csv",
"inputFamily": "SPREADSHEET",
"loadProperties": {
"FilterName": "Text - txt - csv (StarCalc)",
"FilterOptions": "44,34,0"
},
"storePropertiesByFamily": {"SPREADSHEET": {
"FilterName": "Text - txt - csv (StarCalc)",
"FilterOptions": "44,34,0"
}}
},
{
"name": "Tab Separated Values",
"extension": "tsv",
"mediaType": "text/tab-separated-values",
"inputFamily": "SPREADSHEET",
"loadProperties": {
"FilterName": "Text - txt - csv (StarCalc)",
"FilterOptions": "9,34,0"
},
"storePropertiesByFamily": {"SPREADSHEET": {
"FilterName": "Text - txt - csv (StarCalc)",
"FilterOptions": "9,34,0"
}}
},
{
"name": "OpenDocument Presentation",
"extension": "odp",
"mediaType": "application/vnd.oasis.opendocument.presentation",
"inputFamily": "PRESENTATION",
"storePropertiesByFamily": {"PRESENTATION": {"FilterName": "impress8"}}
},
{
"name": "OpenOffice.org 1.0 Presentation",
"extension": "sxi",
"mediaType": "application/vnd.sun.xml.impress",
"inputFamily": "PRESENTATION",
"storePropertiesByFamily": {"PRESENTATION": {"FilterName": "StarOffice XML (Impress)"}}
},
{
"name": "Microsoft PowerPoint",
"extension": "ppt",
"mediaType": "application/vnd.ms-powerpoint",
"inputFamily": "PRESENTATION",
"storePropertiesByFamily": {"PRESENTATION": {"FilterName": "MS PowerPoint 97"}}
},
{
"name": "Microsoft PowerPoint 2007 XML",
"extension": "pptx",
"mediaType": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
"inputFamily": "PRESENTATION"
},
{
"name": "OpenDocument Drawing",
"extension": "odg",
"mediaType": "application/vnd.oasis.opendocument.graphics",
"inputFamily": "DRAWING",
"storePropertiesByFamily": {"DRAWING": {"FilterName": "draw8"}}
},
{
"name": "Scalable Vector Graphics",
"extension": "svg",
"mediaType": "image/svg+xml",
"storePropertiesByFamily": {"DRAWING": {"FilterName": "draw_svg_Export"}}
}
]

View File

@@ -1,171 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jodconverter-web</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<ufile.sdk.verison>1.0-SNAPSHOT</ufile.sdk.verison>
<logging.path>${basedir}/target/classes/logs</logging.path>
<appName>file-preview</appName>
</properties>
<repositories>
<repository>
<!-- required for org.hyperic:sigar -->
<id>jboss-public-repository-group</id>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cn.keking</groupId>
<artifactId>jodconverter-core</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<artifactId>commons-io</artifactId>
<groupId>commons-io</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- REDISSON -->
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.12</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>3.12</version>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>org.apache.poi.xwpf.converter.core</artifactId>
<version>1.0.5</version>
<exclusions>
<exclusion>
<artifactId>poi</artifactId>
<groupId>org.apache.poi</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>org.apache.poi.xwpf.converter.xhtml</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>fr.opensagres.xdocreport.document</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<!-- 解压(apache) -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.9</version>
</dependency>
<!-- 解压(rar)-->
<dependency>
<groupId>com.github.junrar</groupId>
<artifactId>junrar</artifactId>
<version>0.7</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jchardet</groupId>
<artifactId>jchardet</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -1,18 +0,0 @@
package cn.keking;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.util.Properties;
@SpringBootApplication
@EnableScheduling
@ComponentScan(value = "cn.keking.*")
public class FilePreviewApplication {
public static void main(String[] args) {
Properties properties = System.getProperties();
System.out.println(properties.get("user.dir"));
SpringApplication.run(FilePreviewApplication.class, args);
}
}

View File

@@ -1,211 +0,0 @@
package cn.keking.extend;
import com.google.common.collect.Maps;
import com.sun.star.beans.PropertyValue;
import org.artofsolving.jodconverter.document.DocumentFamily;
import org.artofsolving.jodconverter.document.DocumentFormat;
import org.artofsolving.jodconverter.document.SimpleDocumentFormatRegistry;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 重写了DefaultDocumentFormatRegistry类因为要添加自定义行为比如字符编码。。。
* @author yudian-it
* @date 2017/12/5
*/
public class ControlDocumentFormatRegistry extends SimpleDocumentFormatRegistry {
public ControlDocumentFormatRegistry() {
DocumentFormat pdf = new DocumentFormat("Portable Document Format", "pdf", "application/pdf");
pdf.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "writer_pdf_Export"));
pdf.setStoreProperties(DocumentFamily.SPREADSHEET, Collections.singletonMap("FilterName", "calc_pdf_Export"));
pdf.setStoreProperties(DocumentFamily.PRESENTATION, Collections.singletonMap("FilterName", "impress_pdf_Export"));
pdf.setStoreProperties(DocumentFamily.DRAWING, Collections.singletonMap("FilterName", "draw_pdf_Export"));
addFormat(pdf);
DocumentFormat swf = new DocumentFormat("Macromedia Flash", "swf", "application/x-shockwave-flash");
swf.setStoreProperties(DocumentFamily.PRESENTATION, Collections.singletonMap("FilterName", "impress_flash_Export"));
swf.setStoreProperties(DocumentFamily.DRAWING, Collections.singletonMap("FilterName", "draw_flash_Export"));
addFormat(swf);
// disabled because it's not always available
//DocumentFormat xhtml = new DocumentFormat("XHTML", "xhtml", "application/xhtml+xml");
//xhtml.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "XHTML Writer File"));
//xhtml.setStoreProperties(DocumentFamily.SPREADSHEET, Collections.singletonMap("FilterName", "XHTML Calc File"));
//xhtml.setStoreProperties(DocumentFamily.PRESENTATION, Collections.singletonMap("FilterName", "XHTML Impress File"));
//addFormat(xhtml);
DocumentFormat html = new DocumentFormat("HTML", "html", "text/html");
// HTML is treated as Text when supplied as input, but as an output it is also
// available for exporting Spreadsheet and Presentation formats
html.setInputFamily(DocumentFamily.TEXT);
html.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "HTML (StarWriter)"));
Map<String,Object> htmlLoadAndStoreProperties = new LinkedHashMap<String,Object>();
htmlLoadAndStoreProperties.put("FilterName", "HTML (StarCalc)");
htmlLoadAndStoreProperties.put("FilterOptions", "utf8");
html.setStoreProperties(DocumentFamily.SPREADSHEET, htmlLoadAndStoreProperties);
html.setStoreProperties(DocumentFamily.PRESENTATION, Collections.singletonMap("FilterName", "impress_html_Export"));
addFormat(html);
DocumentFormat odt = new DocumentFormat("OpenDocument Text", "odt", "application/vnd.oasis.opendocument.text");
odt.setInputFamily(DocumentFamily.TEXT);
odt.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "writer8"));
addFormat(odt);
DocumentFormat sxw = new DocumentFormat("OpenOffice.org 1.0 Text Document", "sxw", "application/vnd.sun.xml.writer");
sxw.setInputFamily(DocumentFamily.TEXT);
sxw.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "StarOffice XML (Writer)"));
addFormat(sxw);
DocumentFormat doc = new DocumentFormat("Microsoft Word", "doc", "application/msword");
doc.setInputFamily(DocumentFamily.TEXT);
doc.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "MS Word 97"));
addFormat(doc);
DocumentFormat docx = new DocumentFormat("Microsoft Word 2007 XML", "docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
docx.setInputFamily(DocumentFamily.TEXT);
addFormat(docx);
DocumentFormat rtf = new DocumentFormat("Rich Text Format", "rtf", "text/rtf");
rtf.setInputFamily(DocumentFamily.TEXT);
rtf.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "Rich Text Format"));
addFormat(rtf);
DocumentFormat wpd = new DocumentFormat("WordPerfect", "wpd", "application/wordperfect");
wpd.setInputFamily(DocumentFamily.TEXT);
addFormat(wpd);
DocumentFormat txt = new DocumentFormat("Plain Text", "txt", "text/plain");
txt.setInputFamily(DocumentFamily.TEXT);
Map<String,Object> txtLoadAndStoreProperties = new LinkedHashMap<String,Object>();
txtLoadAndStoreProperties.put("FilterName", "Text (encoded)");
txtLoadAndStoreProperties.put("FilterOptions", "utf8");
txt.setLoadProperties(txtLoadAndStoreProperties);
txt.setStoreProperties(DocumentFamily.TEXT, txtLoadAndStoreProperties);
addFormat(txt);
DocumentFormat wikitext = new DocumentFormat("MediaWiki wikitext", "wiki", "text/x-wiki");
wikitext.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "MediaWiki"));
//addFormat(wikitext);
DocumentFormat ods = new DocumentFormat("OpenDocument Spreadsheet", "ods", "application/vnd.oasis.opendocument.spreadsheet");
ods.setInputFamily(DocumentFamily.SPREADSHEET);
ods.setStoreProperties(DocumentFamily.SPREADSHEET, Collections.singletonMap("FilterName", "calc8"));
addFormat(ods);
DocumentFormat sxc = new DocumentFormat("OpenOffice.org 1.0 Spreadsheet", "sxc", "application/vnd.sun.xml.calc");
sxc.setInputFamily(DocumentFamily.SPREADSHEET);
sxc.setStoreProperties(DocumentFamily.SPREADSHEET, Collections.singletonMap("FilterName", "StarOffice XML (Calc)"));
addFormat(sxc);
DocumentFormat xls = new DocumentFormat("Microsoft Excel", "xls", "application/vnd.ms-excel");
xls.setInputFamily(DocumentFamily.SPREADSHEET);
xls.setStoreProperties(DocumentFamily.SPREADSHEET, Collections.singletonMap("FilterName", "MS Excel 97"));
addFormat(xls);
DocumentFormat xlsx = new DocumentFormat("Microsoft Excel 2007 XML", "xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
xlsx.setInputFamily(DocumentFamily.SPREADSHEET);
addFormat(xlsx);
DocumentFormat csv = new DocumentFormat("Comma Separated Values", "csv", "text/csv");
csv.setInputFamily(DocumentFamily.SPREADSHEET);
Map<String,Object> csvLoadAndStoreProperties = new LinkedHashMap<String,Object>();
csvLoadAndStoreProperties.put("FilterName", "Text - txt - csv (StarCalc)");
csvLoadAndStoreProperties.put("FilterOptions", "44,34,0"); // Field Separator: ','; Text Delimiter: '"'
csv.setLoadProperties(csvLoadAndStoreProperties);
csv.setStoreProperties(DocumentFamily.SPREADSHEET, csvLoadAndStoreProperties);
addFormat(csv);
DocumentFormat tsv = new DocumentFormat("Tab Separated Values", "tsv", "text/tab-separated-values");
tsv.setInputFamily(DocumentFamily.SPREADSHEET);
Map<String,Object> tsvLoadAndStoreProperties = new LinkedHashMap<String,Object>();
tsvLoadAndStoreProperties.put("FilterName", "Text - txt - csv (StarCalc)");
tsvLoadAndStoreProperties.put("FilterOptions", "9,34,0"); // Field Separator: '\t'; Text Delimiter: '"'
tsv.setLoadProperties(tsvLoadAndStoreProperties);
tsv.setStoreProperties(DocumentFamily.SPREADSHEET, tsvLoadAndStoreProperties);
addFormat(tsv);
DocumentFormat odp = new DocumentFormat("OpenDocument Presentation", "odp", "application/vnd.oasis.opendocument.presentation");
odp.setInputFamily(DocumentFamily.PRESENTATION);
odp.setStoreProperties(DocumentFamily.PRESENTATION, Collections.singletonMap("FilterName", "impress8"));
addFormat(odp);
DocumentFormat sxi = new DocumentFormat("OpenOffice.org 1.0 Presentation", "sxi", "application/vnd.sun.xml.impress");
sxi.setInputFamily(DocumentFamily.PRESENTATION);
sxi.setStoreProperties(DocumentFamily.PRESENTATION, Collections.singletonMap("FilterName", "StarOffice XML (Impress)"));
addFormat(sxi);
DocumentFormat ppt = new DocumentFormat("Microsoft PowerPoint", "ppt", "application/vnd.ms-powerpoint");
ppt.setInputFamily(DocumentFamily.PRESENTATION);
ppt.setStoreProperties(DocumentFamily.PRESENTATION, Collections.singletonMap("FilterName", "MS PowerPoint 97"));
addFormat(ppt);
DocumentFormat pptx = new DocumentFormat("Microsoft PowerPoint 2007 XML", "pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
pptx.setInputFamily(DocumentFamily.PRESENTATION);
addFormat(pptx);
DocumentFormat odg = new DocumentFormat("OpenDocument Drawing", "odg", "application/vnd.oasis.opendocument.graphics");
odg.setInputFamily(DocumentFamily.DRAWING);
odg.setStoreProperties(DocumentFamily.DRAWING, Collections.singletonMap("FilterName", "draw8"));
addFormat(odg);
DocumentFormat svg = new DocumentFormat("Scalable Vector Graphics", "svg", "image/svg+xml");
svg.setStoreProperties(DocumentFamily.DRAWING, Collections.singletonMap("FilterName", "draw_svg_Export"));
addFormat(svg);
}
/**
* 创建默认的导出属性
* @return
*/
private PropertyValue[] getCommonPropertyValue() {
PropertyValue[] aFilterData = new PropertyValue[11];
// 不显示文档标题
aFilterData[0] = new PropertyValue();
aFilterData[0].Name = "DisplayPDFDocumentTitle";
aFilterData[0].Value= true;
// 导出文件编码方式
aFilterData[1] = new PropertyValue();
aFilterData[1].Name = "Encoding";
aFilterData[1].Value= "UTF-8";
// 隐藏工具条
aFilterData[2] = new PropertyValue();
aFilterData[2].Name = "HideViewerToolbar";
aFilterData[2].Value= false;
// 隐藏窗口控制条
aFilterData[3] = new PropertyValue();
aFilterData[3].Name = "HideViewerWindowControls";
aFilterData[3].Value= true;
// 全屏展示
aFilterData[4] = new PropertyValue();
aFilterData[4].Name = "OpenInFullScreenMode";
aFilterData[4].Value= false;
// 第一页左边展示
aFilterData[5] = new PropertyValue();
aFilterData[5].Name = "MathToMathType";
aFilterData[5].Value= true;
// 文档标题内容
aFilterData[6] = new PropertyValue();
aFilterData[6].Name = "Watermark";
aFilterData[6].Value= "KEKING.CN";
// 导出文件编码方式
aFilterData[7] = new PropertyValue();
aFilterData[7].Name = "CharacterSet";
aFilterData[7].Value= "UTF-8";
// 导出文件编码方式
aFilterData[8] = new PropertyValue();
aFilterData[8].Name = "Encoding";
aFilterData[8].Value= "UTF-8";
// 导出文件编码方式
aFilterData[9] = new PropertyValue();
aFilterData[9].Name = "CharSet";
aFilterData[9].Value= "UTF-8";
// 导出文件编码方式
aFilterData[10] = new PropertyValue();
aFilterData[10].Name = "charset";
aFilterData[10].Value= "UTF-8";
return aFilterData;
}
}

View File

@@ -1,33 +0,0 @@
package cn.keking.filters;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
*
* @author yudian-it
* @date 2017/11/30
*/
public class ChinesePathFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
StringBuilder pathBuilder = new StringBuilder();
pathBuilder.append(request.getScheme()).append("://").append(request.getServerName()).append(":")
.append(request.getServerPort()).append(((HttpServletRequest)request).getContextPath()).append("/");
request.setAttribute("baseUrl", pathBuilder.toString());
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
}

View File

@@ -1,23 +0,0 @@
package cn.keking.filters;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
*
* @author yudian-it
* @date 2017/11/30
*/
@Configuration
public class FilterConfiguration {
@Bean
public FilterRegistrationBean getChinesePathFilter(){
ChinesePathFilter filter = new ChinesePathFilter();
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
registrationBean.setFilter(filter);
return registrationBean;
}
}

View File

@@ -1,69 +0,0 @@
package cn.keking.model;
/**
* Created by kl on 2018/1/17.
* Content :
*/
public class FileAttribute {
private FileType type;
private String suffix;
private String name;
private String url;
private String decodedUrl;
public FileAttribute() {
}
public FileAttribute(FileType type, String suffix, String name, String url, String decodedUrl) {
this.type = type;
this.suffix = suffix;
this.name = name;
this.url = url;
this.decodedUrl = decodedUrl;
}
public FileType getType() {
return type;
}
public void setType(FileType type) {
this.type = type;
}
public String getSuffix() {
return suffix;
}
public void setSuffix(String suffix) {
this.suffix = suffix;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getDecodedUrl() {
return decodedUrl;
}
public void setDecodedUrl(String decodedUrl) {
this.decodedUrl = decodedUrl;
}
}

View File

@@ -1,28 +0,0 @@
package cn.keking.model;
/**
* Created by kl on 2018/1/17.
* Content :文件类型文本office压缩包等等
*/
public enum FileType {
picture("pictureFilePreviewImpl"),
compress("compressFilePreviewImpl"),
office("officeFilePreviewImpl"),
simText("simTextFilePreviewImpl"),
pdf("pdfFilePreviewImpl"),
other("otherFilePreviewImpl"),
media("mediaFilePreviewImpl");
private String instanceName;
FileType(String instanceName){
this.instanceName=instanceName;
}
public String getInstanceName() {
return instanceName;
}
public void setInstanceName(String instanceName) {
this.instanceName = instanceName;
}
}

View File

@@ -1,57 +0,0 @@
package cn.keking.model;
import java.io.Serializable;
/**
* 接口返回值结构
* @author yudian-it
* @date 2017/11/17
*/
public class ReturnResponse<T> implements Serializable{
private static final long serialVersionUID = 313975329998789878L;
/**
* 返回状态
* 0. 成功
* 1. 失败
*/
private int code;
/**
* 返回状态描述
* XXX成功
* XXX失败
*/
private String msg;
private T content;
public ReturnResponse(int code, String msg, T content) {
this.code = code;
this.msg = msg;
this.content = content;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getContent() {
return content;
}
public void setContent(T content) {
this.content = content;
}
}

View File

@@ -1,84 +0,0 @@
package cn.keking.service;
import cn.keking.model.FileAttribute;
import cn.keking.model.FileType;
import cn.keking.utils.FileUtils;
import org.redisson.api.RBlockingQueue;
import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.ExtendedModelMap;
import javax.annotation.PostConstruct;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Created by kl on 2018/1/19.
* Content :消费队列中的转换文件
*/
@Service
public class FileConverQueueTask {
Logger logger= LoggerFactory.getLogger(getClass());
public static final String queueTaskName="FileConverQueueTask";
@Autowired
FilePreviewFactory previewFactory;
@Autowired
RedissonClient redissonClient;
@Autowired
FileUtils fileUtils;
@PostConstruct
public void startTask(){
ExecutorService executorService = Executors.newFixedThreadPool(3);
executorService.submit(new ConverTask(previewFactory,redissonClient,fileUtils));
logger.info("队列处理文件转换任务启动完成 ");
}
class ConverTask implements Runnable{
FilePreviewFactory previewFactory;
RedissonClient redissonClient;
FileUtils fileUtils;
public ConverTask(FilePreviewFactory previewFactory, RedissonClient redissonClient,FileUtils fileUtils) {
this.previewFactory = previewFactory;
this.redissonClient = redissonClient;
this.fileUtils=fileUtils;
}
@Override
public void run() {
while (true) {
try {
final RBlockingQueue<String> queue = redissonClient.getBlockingQueue(FileConverQueueTask.queueTaskName);
String url = queue.take();
if(url!=null){
FileAttribute fileAttribute=fileUtils.getFileAttribute(url);
logger.info("正在处理转换任务,文件名称【{}】",fileAttribute.getName());
FileType fileType=fileAttribute.getType();
if(fileType.equals(FileType.compress) || fileType.equals(FileType.office)){
FilePreview filePreview=previewFactory.get(url);
filePreview.filePreviewHandle(url,new ExtendedModelMap());
}
}
} catch (Exception e) {
try {
Thread.sleep(1000*10);
}catch (Exception ex){
ex.printStackTrace();
}
e.printStackTrace();
}
}
}
}
}

View File

@@ -1,11 +0,0 @@
package cn.keking.service;
import org.springframework.ui.Model;
/**
* Created by kl on 2018/1/17.
* Content :
*/
public interface FilePreview {
String filePreviewHandle(String url, Model model);
}

View File

@@ -1,30 +0,0 @@
package cn.keking.service;
import cn.keking.model.FileAttribute;
import cn.keking.utils.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import java.util.Map;
/**
* Created by kl on 2018/1/17.
* Content :
*/
@Service
public class FilePreviewFactory {
@Autowired
FileUtils fileUtils;
@Autowired
ApplicationContext context;
public FilePreview get(String url) {
Map<String, FilePreview> filePreviewMap = context.getBeansOfType(FilePreview.class);
FileAttribute fileAttribute = fileUtils.getFileAttribute(url);
return filePreviewMap.get(fileAttribute.getType().getInstanceName());
}
}

View File

@@ -1,62 +0,0 @@
package cn.keking.service.impl;
import cn.keking.model.FileAttribute;
import cn.keking.model.ReturnResponse;
import cn.keking.service.FilePreview;
import cn.keking.utils.DownloadUtils;
import cn.keking.utils.FileUtils;
import cn.keking.utils.ZipReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
/**
* Created by kl on 2018/1/17.
* Content :处理压缩包文件
*/
@Service
public class CompressFilePreviewImpl implements FilePreview{
@Autowired
FileUtils fileUtils;
@Autowired
DownloadUtils downloadUtils;
@Autowired
ZipReader zipReader;
@Override
public String filePreviewHandle(String url, Model model) {
FileAttribute fileAttribute=fileUtils.getFileAttribute(url);
String fileName=fileAttribute.getName();
String decodedUrl=fileAttribute.getDecodedUrl();
String suffix=fileAttribute.getSuffix();
String fileTree = null;
// 判断文件名是否存在(redis缓存读取)
if (!StringUtils.hasText(fileUtils.getConvertedFile(fileName))) {
ReturnResponse<String> response = downloadUtils.downLoad(decodedUrl, suffix, fileName);
if (0 != response.getCode()) {
model.addAttribute("msg", response.getMsg());
return "fileNotSupported";
}
String filePath = response.getContent();
if ("zip".equalsIgnoreCase(suffix) || "jar".equalsIgnoreCase(suffix) || "gzip".equalsIgnoreCase(suffix)) {
fileTree = zipReader.readZipFile(filePath, fileName);
} else if ("rar".equalsIgnoreCase(suffix)) {
fileTree = zipReader.unRar(filePath, fileName);
}
fileUtils.addConvertedFile(fileName, fileTree);
} else {
fileTree = fileUtils.getConvertedFile(fileName);
}
if (null != fileTree) {
model.addAttribute("fileTree", fileTree);
return "compress";
} else {
model.addAttribute("msg", "压缩文件类型不受支持尝试在压缩的时候选择RAR4格式");
return "fileNotSupported";
}
}
}

View File

@@ -1,27 +0,0 @@
package cn.keking.service.impl;
import cn.keking.service.FilePreview;
import cn.keking.utils.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
/**
* @author : kl
* @authorboke : kailing.pub
* @create : 2018-03-25 上午11:58
* @description:
**/
@Service
public class MediaFilePreviewImpl implements FilePreview {
@Autowired
FileUtils fileUtils;
@Override
public String filePreviewHandle(String url, Model model) {
model.addAttribute("mediaUrl", url);
return "media";
}
}

Some files were not shown because too many files have changed in this diff Show More