When I try to convert PDF to PDF/A using GhostScript.NET and I start debuging the project brings this exception:
"Additional information: An error occured when call to 'gsapi_init_with_args' is made: -100"
My code is:
Public Sub Start()
Dim gv As GhostscriptVersionInfo = New GhostscriptVersionInfo("C:\Program Files\gs\gs9.18\bin\gsdll64.dll")
Dim proc As GhostscriptProcessor = New GhostscriptProcessor(gv)
Dim switches As List(Of String) = New List(Of String)()
switches.Add("-dPDFA=1")
switches.Add("-dNoCancel")
switches.Add("-dNOPAUSE")
switches.Add("-dNOOUTERSAVE")
switches.Add("-sProcessColorModel=DeviceRGB")
switches.Add("-sDEVICE=pdfwrite")
switches.Add("-sOutputFile=pdfa.pdf")
switches.Add("C:\Program Files\gs\gs9.18\bin\PDFA_def.ps")
switches.Add("-dPDFACompatibilityPolicy=1")
switches.Add("C:\Program Files\gs\gs9.18\bin\teste.pdf")
proc.StartProcessing(switches.ToArray, Nothing)
MsgBox("ok")
End Sub
If I run the code to convert PDF to PDF / A through CMD, it works perfectly.
gswin64 -q -dPDFA=1 -dNoCancel -dNOPAUSE -dNOOUTERSAVE -sProcessColorModel=DeviceRGB -sDEVICE=pdfwrite -sOutputFile=pdfa.pdf PDFA_def.ps -dPDFACompatibilityPolicy=1 teste.pdf
However, running with the above code brings this error.
If I change the parameters to convert PDF to image, it works well with the code below.
switches.Add("-dSAFER")
switches.Add("-dBATCH")
switches.Add("-dNOPAUSE")
switches.Add("-sDEVICE=jpeg")
switches.Add("-sOutputFile=figure.jpg")
switches.Add("teste.pdf")
So it seems that there is some problem in the parameters, at the same time that through the CMD these parameters are working perfectly.
Any suggestions for making the code work?
The problem of running CMD directly is that it opens a GhostScript popup.