【发布时间】:2013-09-03 21:37:41
【问题描述】:
我正在尝试使用 VB.NET 和 shell 将现有且格式良好的“output.ps”文件生成“c:\output.pdf”到当前目录中的 gswin32c.exe。
但我显然无法正确编写shell命令:
If LCase(p_printer).Contains("ghostscript") Then
' to not show old one
IO.File.Delete(OutputPDF)
If IO.File.Exists(InputPS) Then
Dim commandString As String = """gswin32c.exe -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dQUIET -sOUTPUTFILE=" & OutputPDF & " " & InputPS & """"
Debug.Print(commandString)
Shell(commandString, AppWinStyle.NormalFocus)
If IO.File.Exists(OutputPDF) And bln_showpdf Then
'show PDF
Start(OutputPDF)
End If
Else
MsgBox(InputPS + " do NOT exists.", MsgBoxStyle.Critical)
End If
End If
在 cmd 窗口中,这些命令会定期生成“output.pdf”
什么是不正确的以及如何使它工作?
【问题讨论】:
-
请不要更改您原来的问题,因为这会影响我的回答。你应该恢复原来的问题。然后在那个放下面:编辑:把你的新代码放在这里......这样我们就可以看到原始问题加上你的新代码。这样一来,一切都变得更加清晰。
-
好的,我会记住这一点,现在,不幸的是我永久删除了旧的命令字符串(因为它不起作用)。对不起。
-
没问题;查看我修改后的答案。我对其进行了测试,效果很好。