windows – Visio到图像命令行转换
发布时间:2020-12-14 04:24:50 所属栏目:Windows 来源:网络整理
导读:在工作中,我们大量使用Visio绘图作为文档支持.不幸的是,vsd文件不能很好地使用我们的wiki或文档提取工具,如 javadoc,doxygen或naturaldocs.虽然可以手动将Visio文件转换为图像,但保持图像最新并且图像文件必然会过时是一件麻烦事.让我们面对现实:在版本控制
在工作中,我们大量使用Visio绘图作为文档支持.不幸的是,vsd文件不能很好地使用我们的wiki或文档提取工具,如
javadoc,doxygen或naturaldocs.虽然可以手动将Visio文件转换为图像,但保持图像最新并且图像文件必然会过时是一件麻烦事.让我们面对现实:在版本控制中生成文件感觉非常错误.
所以我正在寻找一个命令行工具,可以将vsd文件转换为jpeg,png,gif或任何可以转换为浏览器可以显示的图像的图像.最好是在unix下运行,但是窗口也可以.我可以处理自动化链的其余部分,cron作业,图像到图像转换以及ssh,scp,多个文件等. 这就是为什么我转向你:我找不到这样的工具.我认为我甚至不能为这样的工具买单.我的Google-fu完全关闭了?你能帮助我吗? 我的意思是,它必须是可能的.必须有一种方法可以使用COM挂钩到Visio并将其保存为图像.顺便说一句,我正在使用Visio 2007. 提前致谢.
我用VB6快速打了一下东西,你可以在以下网址下载:
http://fournier.jonathan.googlepages.com/Vis2Img.exe 您只需传入输入的visio文件路径,然后输入文件路径(基于文件扩展名的visio导出)和可选的导出页码. 另外这里是我使用的源代码,如果你想搞乱它或将它变成VBScript或其他东西,它应该工作,虽然你需要完成将它转换为后期绑定代码. 希望有所帮助, 乔恩 Dim TheCmd As String Const visOpenRO = 2 Const visOpenMinimized = 16 Const visOpenHidden = 64 Const visOpenMacrosDisabled = 128 Const visOpenNoWorkspace = 256 Sub Main() ' interpret command line arguments - separated by spaces outside of double quotes TheCmd = Command Dim TheCmds() As String If SplitCommandArg(TheCmds) Then If UBound(TheCmds) > 1 Then Dim PageNum As Long If UBound(TheCmds) >= 3 Then PageNum = Val(TheCmds(3)) Else PageNum = 1 End If ' if the input or output file doesn't contain a file path,then assume the same If InStr(1,TheCmds(1),"") = 0 Then TheCmds(1) = App.Path & "" & TheCmds(1) End If If InStr(1,TheCmds(2),"") = 0 Then TheCmds(2) = App.Path & "" & TheCmds(2) End If ConvertVisToImg TheCmds(1),PageNum Else ' no good - need an in and out file End If End If End Sub Function ConvertVisToImg(ByVal InVisPath As String,ByVal OutImgPath As String,PageNum As Long) As Boolean ConvertVisToImg = True On Error GoTo PROC_ERR ' create a new visio instance Dim VisApp As Visio.Application Set VisApp = CreateObject("Visio.Application") ' open invispath Dim ConvDoc As Visio.Document Set ConvDoc = VisApp.Documents.OpenEx(InVisPath,visOpenRO + visOpenMinimized + visOpenHidden + visOpenMacrosDisabled + visOpenNoWorkspace) ' export to outimgpath If Not ConvDoc.Pages(PageNum) Is Nothing Then ConvDoc.Pages(PageNum).Export OutImgPath Else MsgBox "Invalid export page" ConvertVisToImg = False GoTo PROC_END End If ' close it off PROC_END: On Error Resume Next VisApp.Quit Set VisApp = Nothing Exit Function PROC_ERR: MsgBox Err.Description & vbCr & "Num:" & Err.Number GoTo PROC_END End Function Function SplitCommandArg(ByRef Commands() As String) As Boolean SplitCommandArg = True 'read through command and break it into an array delimited by space characters only when we're not inside double quotes Dim InDblQts As Boolean Dim CmdToSplit As String CmdToSplit = TheCmd 'for debugging command line parser 'CmdToSplit = Command Dim CharIdx As Integer ReDim Commands(1 To 1) For CharIdx = 1 To Len(CmdToSplit) Dim CurrChar As String CurrChar = Mid(CmdToSplit,CharIdx,1) If CurrChar = " " And Not InDblQts Then 'add another element to the commands array if InDblQts is false If Commands(UBound(Commands)) <> "" Then ReDim Preserve Commands(LBound(Commands) To UBound(Commands) + 1) ElseIf CurrChar = Chr(34) Then 'set InDblQts = true If Not InDblQts Then InDblQts = True Else InDblQts = False Else Commands(UBound(Commands)) = Commands(UBound(Commands)) & CurrChar End If Next CharIdx End Function (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows-8 – 类似GridView的页面但具有静态组,每个组部分将
- 如何通过Windows shell(bat,cmd)获取系统上的驱动器号列表?
- haskell – 无法在Windows上安装cailo with cabal – 如何在
- ms-access – 在Microsoft Access 2010中创建关系时“表上的
- windows – HKLM注册表疑问
- Windows支持的语言开箱即用
- Windows – 命令行将文件名打印到输出文件
- IIS 7.5虚拟目录托管在第二台服务器上
- Windows写代码,Linux运行 (WSL & VS Code)
- .net – 了解Windows中的AppDomains
推荐文章
站长推荐
- windows-server-2008 – 忽略主机文件的Squid代理
- Windows-8 – WinRT是否直接访问NT内核(需要操作
- Windows – Active Directory站点 – 设计和连接
- 在Windows上用R中的SUB(1a)(Control-Z)字符读取文
- Windows Azure计划程序(预览)
- windows-7 – Windows 7上的64位TortoiseSVN说“
- 团队正在从XP32转向XP64进行.NET开发 – 任何陷阱
- windows-phone-7 – 如何在WP7上制作XNA可移动掩
- Windows Azure定价不明确
- windows-phone-7 – 在WindowsPhone 7应用程序中
热点阅读