0

我一直在尝试使 PODConverter 作为服务工作,但它就是不想工作。有趣的是,我们使用了一个运行良好的旧版本,或者我们只是说它至少在做某事。我们现在必须切换,因为 soffice.exe 随机崩溃。

因此,我使用新版本的 JODConverter (jodconverter-core-3.0-beta-4-dist) 制作了一个新的测试项目,但我保留了基本构建。例如服务的参数。

我的测试项目没有做那么多。它仅将一堆 .odt 文件复制到另一个文件夹,然后尝试将它们转换为 .pdf,但没有任何反应。没有pdf,没有错误..什么都没有。

我不知道为什么这不起作用,我真的希望你们能在这里帮助我,因为这真的让我发疯。

[编辑] 好的,我发现了一个问题,我有点知道它为什么不起作用:显然输出是空的,但我不知道为什么。

[EDIT2] 发现错误..忘记了 jar 的部分路径。代码:

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-dist\jodconverter-core-3.0-beta-4"
            proc.StartInfo.FileName = "C:\Program Files (x86)\Java\jre6\bin\java.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
4

1 回答 1

0
Dim InstruccionJava As String = "java -jar lib\jodconverter-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 & "\lib\jodconverter-core-3.0-beta-4.jar " & Ruta & " " & Rutahtml
proc.StartInfo.FileName = "java" '"C:\Archivos de programa\Java\jre7\bin\java.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
于 2012-07-04T19:31:48.020 回答