forked from ofdrw/ofdrw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
81 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,59 @@ | ||
# OFD Reader & Writer 文档操作工具 | ||
|
||
## 文档合并 | ||
## 引入依赖 | ||
|
||
1. 创建空文档 | ||
2. 输入待合并文档 | ||
3. 选择页面 | ||
- 资源分析 | ||
- 资源复制 | ||
- 页面复制 | ||
- 页面资源替换 | ||
4. 合并成文件 | ||
```xml | ||
|
||
<dependency> | ||
<groupId>org.ofdrw</groupId> | ||
<artifactId>ofdrw-tool</artifactId> | ||
<version>1.17.0</version> | ||
</dependency> | ||
``` | ||
|
||
页面涉及资源: | ||
|
||
- 页面模板 | ||
- 绘制参数 (DrawParam) | ||
- 颜色空间 | ||
- 字体 | ||
- 多媒体 | ||
- 矢量图像 | ||
|
||
|
||
- 注释 | ||
|
||
相同资源 | ||
|
||
模板页 | ||
## 多文档合并 | ||
|
||
1. 提供合并文件输出位置。 | ||
2. 提供待合并文件。 | ||
3. 创建合并对象`OFDMerger`。 | ||
4. 添加合并文档和页面(支持添加多个文档)。 | ||
5. 关闭合并对象,生成文档。 | ||
|
||
```java | ||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
public class HelloMerge { | ||
public static void main(String[] args) throws IOException { | ||
// 1. 提供合并文件输出位置。 | ||
Path dst = Paths.get("dst.ofd"); | ||
// 2. 提供待合并文件。 | ||
Path d1Path = Paths.get("file1.ofd"); | ||
Path d2Path = Paths.get("file2.ofd"); | ||
// 3. 创建合并对象 | ||
try (OFDMerger ofdMerger = new OFDMerger(dst)) { | ||
// 4. 添加合并文档和页面。 | ||
ofdMerger.add(d1Path); | ||
ofdMerger.add(d2Path); | ||
} | ||
// 5. 关闭合并对象,生成文档 (try() 语法自动关闭) | ||
} | ||
} | ||
``` | ||
|
||
- 资源对象 | ||
- 资源文件 | ||
为了更加灵活的合并文档,`OFDMerger#add`方法支持可选参数,指定需要合并的页面页码(从1开始) | ||
|
||
相同文件 关联到不同页码 | ||
|
||
例如: | ||
|
||
每个文档 资源映射表 | ||
- 选取`file1.ofd`的第3、1页作为新文档的第1、2页。 | ||
- 选择`file2.ofd`的第1页作为新文档的第3、4页内容。 | ||
|
||
ID -> 资源对象 | 关联文件 (Hash) -> 新文档ID | ||
```java | ||
// Path d1Path = Paths.get("file1.ofd"); | ||
// Path d2Path = Paths.get("file2.ofd"); | ||
|
||
查表流程 | ||
``` | ||
原文档ID -> 查表 -> 新ID | ||
-> 对象关联文件 -> 计算文件Hash -> 查文件表 -> 存储 | ||
ofdMerger.add(d1Path, 3, 1); | ||
ofdMerger.add(d2Path, 1, 1); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters