在工作中,我们大量使用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
原文链接:https://www.f2er.com/windows/364532.htmlhttp://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