我一直在尝试使PODConverter作为服务工作,但它就是不想工作。有趣的是,我们使用了运行良好的旧版本,或者让我们说它至少在做一些事情。我们现在必须切换,因为办公室.exe随机崩溃了。
所以我用新版本的JODConverter(jodconverter-core-3.0-beta-4-dist)做了一个新的测试项目,但我保留了基本版本。例如服务参数
。我的测试项目没有做那么多。它只将一堆.odt文件复制到另一个文件夹,然后尝试将它们转换为 .pdf,但没有任何反应。没有pdf,没有错误..无。
我不知道为什么这行不通,我真的希望你们能在这里帮助我,因为这真的让我发疯了。
[编辑] 好的,我发现了一个问题,我知道为什么它不起作用:显然输出是空的,但我不知道为什么。
[编辑2] 发现错误..忘记了罐子的部分路径。法典:
Imports System
Imports System.Configuration
Imports System.IO
Imports System.Text
Imports System.Collections.Generic
Module Module1
Private OutputMsg As System.Text.StringBuilder = Nothing
Private ErrorMsg As System.Text.StringBuilder = Nothing
Sub Main()
Dim FilesToDelete = Directory.GetFiles("D:temp")
For Each File In FilesToDelete
System.IO.File.Delete(File)
Next
Dim FilesToConvert = System.IO.Directory.GetFiles("D:Source", "*.odt", IO.SearchOption.TopDirectoryOnly)
Dim loopCounter As Integer = 0
Dim fileCounter As Integer = 0
Try
For Each file In FilesToConvert
loopCounter += 1
fileCounter += 1
System.IO.File.Copy(file, "D:temp" + System.IO.Path.GetFileName(file))
'Prüfe, ob die Blockgröße erreicht ist oder die letzte Datei übertragen wurde!
If fileCounter = FilesToConvert.Count Then
convertFiles()
loopCounter = 0
End If
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub convertFiles()
Try
Dim proc As New Process
proc.StartInfo.WorkingDirectory = "D:jodconverter-core-3.0-beta-4-distjodconverter-core-3.0-beta-4"
proc.StartInfo.FileName = "C:Program Files (x86)Javajre6binjava.exe"
proc.StartInfo.Arguments = "java -jar lib/jodconverter-core-3.0-beta-4.jar -o pdf d:temp*.odt"
proc.StartInfo.UseShellExecute = False
proc.StartInfo.RedirectStandardOutput = True
proc.StartInfo.RedirectStandardError = True
proc.StartInfo.RedirectStandardInput = True
OutputMsg = New System.Text.StringBuilder()
AddHandler proc.OutputDataReceived, AddressOf OutputHandler
AddHandler proc.ErrorDataReceived, AddressOf ErrorHandler
proc.Start()
proc.BeginOutputReadLine()
proc.WaitForExit()
'Me.SetExitCode(proc.ExitCode)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub OutputHandler(ByVal sendingProcess As Object, _
ByVal outLine As DataReceivedEventArgs)
Try
' Collect the sort command output.
If Not String.IsNullOrEmpty(outLine.Data) Then
' Add the text to the collected output.
OutputMsg.Append(Environment.NewLine + outLine.Data)
Else
MsgBox("Outline is empty!")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub ErrorHandler(ByVal sendingProcess As Object, _
ByVal outLine As DataReceivedEventArgs)
' Collect the sort command output.
If Not String.IsNullOrEmpty(outLine.Data) Then
' Add the text to the collected output.
ErrorMsg.Append(Environment.NewLine + outLine.Data)
Else
MsgBox("Error is empty!")
End If
End Sub
End Module
Dim InstruccionJava As String = "java -jar libjodconverter-core-3.0-beta-4.jar "
Dim RutaConvertidor As String = rutaServer & "Convertidor"
Dim proc As New Process
proc.StartInfo.WorkingDirectory = RutaConvertidor & "lib"
Dim Argunment As String = "-jar " & RutaConvertidor & "libjodconverter-core-3.0-beta-4.jar " & Ruta & " " & Rutahtml
proc.StartInfo.FileName = "java" '"C:Archivos de programaJavajre7binjava.exe"
proc.StartInfo.Arguments = Argunment
proc.StartInfo.UseShellExecute = False
proc.StartInfo.RedirectStandardOutput = True
proc.StartInfo.RedirectStandardError = True
proc.StartInfo.RedirectStandardInput = True
proc.Start()
proc.BeginOutputReadLine()
proc.WaitForExit()
Dim OutputMsg As System.Text.StringBuilder = Nothing
OutputMsg = New System.Text.StringBuilder()
Dim redireccion As String = "Descargas/" & nombre & ".pdf"
Me.visor.Attributes("src") = redireccion
lberror.Text = OutputMsg.ToString