我已经在我的电脑上安装了draw.io应用程序。我想将所有带有绘图的选项卡导出到单独的文件中。我发现的唯一选择是:
"c:\Program Files\draw.io\draw.io.exe" --crop -x -f jpg c:\Users\user-name\Documents\_xxx_\my-file.drawio
帮助draw.io
Usage: draw.io [options] [input file/folder]
Options:
(...)
-x, --export export the input file/folder based on the
given options
-r, --recursive for a folder input, recursively convert
all files in sub-folders also
-o, --output <output file/folder> specify the output file/folder. If
omitted, the input file name is used for
output with the specified format as
extension
-f, --format <format> if output file name extension is
specified, this option is ignored (file
type is determined from output extension,
possible export formats are pdf, png, jpg,
svg, vsdx, and xml) (default: "pdf")
(default: 0)
-a, --all-pages export all pages (for PDF format only)
-p, --page-index <pageIndex> selects a specific page, if not specified
and the format is an image, the first page
is selected
-g, --page-range <from>..<to> selects a page range (for PDF format only)
(...)
Run Code Online (Sandbox Code Playgroud)
不支持。我可以使用其中之一:
-p, --page-index <pageIndex> selects a specific page, if not specified
and the format is an image, the first page
is selected
-g, --page-range <from>..<to> selects a page range (for PDF format only)
Run Code Online (Sandbox Code Playgroud)
但如何获取页面范围或页数来选择索引?
edd*_*ves 15
使用 Draw.io 的 CLI 选项无法轻松找到开箱即用的页数。
一种解决方案是将图表导出为 XML。
draw.io --export --format xml --uncompressed test-me.drawio
Run Code Online (Sandbox Code Playgroud)
然后数一下diagram有多少个元素。它应该等于页数(我对此进行了简要测试,但我不能 100% 确定diagram元素是否每页只出现一次)。
grep -o "<diagram" "test-me.xml" | wc -l
Run Code Online (Sandbox Code Playgroud)
这是将所有内容放在 bash 脚本中的示例(我在 MacOS 10.15 上尝试过)
#!/bin/bash
file=test-me # File name excluding extension
# Export diagram to plain XML
draw.io --export --format xml --uncompressed "$file.drawio"
# Count how many pages based on <diagram element
count=$(grep -o "<diagram" "$file.xml" | wc -l)
# Export each page as an PNG
# Page index is zero based
for ((i = 0 ; i <= $count-1; i++)); do
draw.io --export --page-index $i --output "$file-$i.png" "$file.drawio"
done
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10018 次 |
| 最近记录: |