问题描述
.vss,是 Microsoft Office Visio 2003 工具生成的绘图模板文件,如果保存为绘图是绘图文件,如果为模板就是这种 .vss 文件。
我们下载网元图标文件是 .vss 格式,里面包含各种图标。但我们是 Linux 桌面系统,无法使用 Visio 工具,因此需要提取其中的图标。
该笔记将记录:在 Linux 中,如何使用工具提取 .vss 文件中的全部图标,以及相关问题的处理方法。
解决方案
在 Linux 中,如何需要提取 .vss 文件的图标,使用 kakwa/libvisio2svg 工具。
在 Ubuntu 21.04 中,搜索无果,只能自行编译安装:
# vss2svg-conv # apt-file search -x bin/vss2svg-conv # apt-file search -x bin/vss burp: /usr/bin/vss_strip libvisio-tools: /usr/bin/vss2raw libvisio-tools: /usr/bin/vss2text libvisio-tools: /usr/bin/vss2xhtml
第一步、安装依赖
apt-get install -y librevenge-dev libvisio-dev libwmf-dev libxml2-dev apt-get install -y gsfonts # 安装 libemf2svg 类库(仓库未提供,只能自行编译安装) apt-get install -y gcc g++ cmake apt-get install -y libpng-dev libc6-dev libfontconfig1-dev libfreetype6-dev git clone https://github.com/kakwa/libemf2svg.git git checkout tags/1.1.0 -b 1.1.0 cmake . -DCMAKE_INSTALL_PREFIX=/usr/ make make install
第二步、安装 Libvisio2svg 工具
git clone https://github.com/kakwa/libvisio2svg.git git checkout tags/0.5.5 -b 0.5.5 cmake . -DCMAKE_INSTALL_PREFIX=/usr/ -DUNSAFE_FILENAME=ON make make install
注意事项:
1)因为我们要提取华为提供的 .vss 文件,图标名多为中文,所以需要开启 -DUNSAFE_FILENAME=ON 选项;
第三步、使用 vss2svg-conv 命令
# vss2svg-conv -i ./2960CX.vss -o ./out/ -s 4.5 # ls out/ 'Cisco R42610 Front.svg' 'WS-C2960CX-8PC-L Rear.svg' 'WS-C2960CX-8TC-L Rear.svg' 'WS-C2960CX-8PC-L Front.svg' 'WS-C2960CX-8TC-L Front.svg' # vss2svg-conv --help
已知问题
部分文件导出失败
按照我们编译方式,如果在图标名称中带有斜线,部分图标会导出失败:
# vss2svg-conv -i Enterprise_Networking_Product_Icons_AR\(Blue\).vss -o ./out/ -s 4.5 [ERROR] Failed to write file 'NG MSAN/MA56/OLT' [ERROR] Failed to write file '模块/区域(蓝色)' [ERROR] Failed to write file '分支/三级' [ERROR] Failed to write file '总部/一级' [ERROR] Failed to write file '模块/区域(渐变)' [ERROR] Failed to write file 'PC/Host' [ERROR] Failed to write file '隧道/Overlay隧道' [ERROR] Failed to write file 'ZigBee/RF' [ERROR] Failed to write file 'Radius服务器/RADIUS' [ERROR] Failed to write file '通用交换机/L3交换机' [ERROR] Failed to write file '通用交换机/L3交换机故障' [ERROR] Failed to write file 'IWG/GW故障' [ERROR] Failed to write file '机构/二级' [ERROR] Failed to write file '传输信号/5G信号' [ERROR] Failed to write file 'L2交换机/接入交换机' [ERROR] Failed to write file '模块/区域(绿色)' [ERROR] Failed to write file 'L2交换机故障/接入交换机故障' [ERROR] Failed to write file 'IWG/GW' [ERROR] Failed to write file 'IWG/GW(不纳管)' [ERROR] Failed to write file 'MME/SGW/RNC' [ERROR] Failed to write file '通用交换机/L3交换机(不纳管)' [ERROR] Failed to write file '日志/告警服务器' [ERROR] Failed to write file '模块/区域(蓝色可选)' # 我们的解决方法也很暴力,直接在 ./out 下创建这些目录: # 导出获取错误日志 vss2svg-conv -i Enterprise_Networking_Product_Icons_AR_Blue.vss -o ./out/ -s 4.5 2>error.log # 创建相关目录 cat error.log | grep -E "'.+'" --only-matching | xargs -i dirname '{}' | xargs -i mkdir -pv './out/{}' # 重新导出 vss2svg-conv -i Enterprise_Networking_Product_Icons_AR_Blue.vss -o ./out/ -s 4.5 2>error.log
参考文献
kakwa/libvisio2svg: Library/Tools to convert Microsoft (MS) Visio documents (VSS and VSD) to SVG
kakwa/libemf2svg: Microsoft (MS) EMF to SVG conversion library