Quantcast
Channel: Ghostscript.NET
Viewing all articles
Browse latest Browse all 393

New Post: Processing event of GhostscriptProcessor class

$
0
0
I am having difficulty subscribing to the Processing event of GhostscriptProcessor class. Any help would be greatly appreciated. Here's my code.

Public Class PostscriptToPDFConverter
Inherits Ghostscript.NET.Processor.GhostscriptProcessor

Public Event UpdateExtraInfo(ByRef lstrInfo As String, ByVal lblnLog As Boolean)

Public Sub Convert(lstrInputPSFile As String)

    Dim lstrOutputPDF As String = System.IO.Path.ChangeExtension(lstrInputPSFile, ".pdf")
    Dim lstrInfo As String = String.Empty

    lstrInfo = String.Format("Convert {0} to {1}", System.IO.Path.GetFileName(lstrInputPSFile), System.IO.Path.GetFileName(lstrOutputPDF))
    RaiseEvent UpdateExtraInfo(lstrInfo, True)

    Dim switches As New List(Of String)()
    switches.Add("-empty")
    switches.Add("-dQUIET")
    switches.Add("-dSAFER")
    switches.Add("-dBATCH")
    switches.Add("-dNOPAUSE")
    switches.Add("-dNOPROMPT")
    switches.Add("-sDEVICE=pdfwrite")
    switches.Add(String.Format("-sOutputFile={0}", lstrOutputPDF))
    switches.Add("-f")
    switches.Add(lstrInputPSFile)

    AddHandler MyBase.Processing, AddressOf GSProcessing
    MyBase.StartProcessing(switches.ToArray(), Nothing)
    RemoveHandler MyBase.Processing, AddressOf GSProcessing

End Sub

Private Sub GSProcessing(sender As Object, e As Ghostscript.NET.Processor.GhostscriptProcessorProcessingEventArgs)
    Dim lstrInfo As String = String.Format("Page: {0} out of {1}", e.CurrentPage, e.TotalPages)
    RaiseEvent UpdateExtraInfo(lstrInfo, True)
End Sub
End Class

Viewing all articles
Browse latest Browse all 393

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>