Page 1 of 1
Launching Ghostscript with parameters How to ?
Posted: Fri Dec 09, 2016 6:34 pm
by loulou2522
Here is what walk with a cmd files
"C:\Program Files (x86)\gs\gs9.20\bin\gswin32c.exe " -dBATCH -dPDFSETTINGS=/screen -dPDFA=3 -dNOOUTERSAVE -sProcessColorModel=DeviceRGB -dUseCIEColor -sDEVICE=pdfwrite -o "C:\Users\Patrick\Desktop\avis1.pdf" -dPDFACompatibilityPolicy=1 "C:\Users\Patrick\Documents\SEPA\SEPA_EN_COURS\SEPAMAIL\pdfa\PDFA_def.ps" "C:\Users\Patrick\Desktop\factureun.pdf" >toto.txt
I don't arrive to launch the program with purebasic and i don't know ho to do ?
Can someone help me
Re: Launching Ghostscript with parameters How to ?
Posted: Fri Dec 09, 2016 7:19 pm
by Michael Vogel
Maybe you can try something like this...
Code: Select all
GhostHandle=RunProgram("gswinc.exe","....","",#PB_Program_Read|#PB_Program_Open|#PB_Program_Hide)
If GhostHandle
While ProgramRunning(GhostHandle)
If AvailableProgramOutput(GhostHandle)
s=ReadProgramString(GhostHandle)
EndIf
Wend
GhostExitcode=ProgramExitCode(GhostHandle)
KillProgram(GhostHandle)
CloseProgram(GhostHandle)
Delay(50)
EndIf
Re: Launching Ghostscript with parameters How to ?
Posted: Fri Dec 09, 2016 7:49 pm
by infratec
Code: Select all
Program$ = "C:\Program Files (x86)\gs\gs9.20\bin\gswin32c.exe"
Parameter$ = "-dBATCH -dPDFSETTINGS=/screen -dPDFA=3 -dNOOUTERSAVE -sProcessColorModel=DeviceRGB -dUseCIEColor -sDEVICE=pdfwrite -o " + #DQUOTE$ + "C:\Users\Patrick\Desktop\avis1.pdf" + #DQUOTE$ + " -dPDFACompatibilityPolicy=1 " + #DQUOTE$ + "C:\Users\Patrick\Documents\SEPA\SEPA_EN_COURS\SEPAMAIL\pdfa\PDFA_def.ps" + #DQUOTE$ + " " + #DQUOTE$ + "C:\Users\Patrick\Desktop\factureun.pdf" + #DQUOTE$
RunProgram(Program$, Parameter$)
If you want to redirect the output to the text file, then you have to open the program with
Like Michael showed you.
Bernd
Re: Launching Ghostscript with parameters How to ?
Posted: Thu Dec 29, 2016 10:24 am
by elwood
infratec wrote: #DQUOTE$
I don't know what these are. You should give loulou2522 "Chr(34)" instead.
@Michael Vogel
it should be:
s$ = ReadProgramString....
@loulou2522
This worked for me i.e. it generated the "log.txt" file containing an error:
Code: Select all
prog = RunProgram("C:\Program Files (x86)\GPLGS\gswin32c.exe","-dBATCH -dPDFSETTINGS=/screen -dPDFA=3 -dNOOUTERSAVE -sProcessColorModel=DeviceRGB -dUseCIEColor -sDEVICE=pdfwrite -o " + Chr(34) + "C:\Users\phil\AppData\Local\Temp\gswin.pdf" + Chr(34) + " -dPDFACompatibilityPolicy=1 " + Chr(34) + "C:\Program Files (x86)\GPLGS\align.ps" + Chr(34) + " " + Chr(34) + "C:\Users\phil\AppData\Local\Temp\gswin2.pdf" + Chr(34) + " >C:\Users\phil\AppData\Local\Temp\log.txt","c:\",#PB_Program_Read|#PB_Program_Open)
If prog = 0
Debug "Error"
Else
CloseProgram(prog)
EndIf
What's strange is that it worked only once. Strange...
So I changed my program to follow Michael proposal and it works like a charm:
Code: Select all
prog = RunProgram("C:\Program Files (x86)\GPLGS\gswin32c.exe","-dBATCH -dPDFSETTINGS=/screen -dPDFA=3 -dNOOUTERSAVE -sProcessColorModel=DeviceRGB -dUseCIEColor -sDEVICE=pdfwrite -o " + Chr(34) + "C:\Users\phil\AppData\Local\Temp\gswin.pdf" + Chr(34) + " -dPDFACompatibilityPolicy=1 " + Chr(34) + "C:\Program Files (x86)\GPLGS\align.ps" + Chr(34) + " " + Chr(34) + "C:\Users\phil\AppData\Local\Temp\gswin2.pdf" + Chr(34) + " >C:\Users\phil\AppData\Local\Temp\gswin.txt","c:\",#PB_Program_Read|#PB_Program_Open)
If prog
While ProgramRunning(prog)
If AvailableProgramOutput(prog)
s$ = ReadProgramString(prog)
EndIf
Wend
Debug s$
KillProgram(prog)
CloseProgram(prog)
EndIf
Re: Launching Ghostscript with parameters How to ?
Posted: Thu Dec 29, 2016 11:53 am
by infratec
elwood wrote:infratec wrote: #DQUOTE$
I don't know what these are. You should give loulou2522 "Chr(34)" instead.
#DQUOTE$ is a constant which represents the value of Chr(34)
But if you read #D(ouble)QUOTE$ you know what it is. Chr(34) is only a number converted to a Character.
So for better reading of the code I prefer
#DQUOTE$ for Chr(34)
and
#CRLF$ for Chr(10) + Chr(13)
Bernd
Re: Launching Ghostscript with parameters How to ?
Posted: Thu Dec 29, 2016 1:26 pm
by elwood
Oh, these constants are not listed in the constant section of the PB manual.
Thanks for the hint.
Re: Launching Ghostscript with parameters How to ?
Posted: Thu Dec 29, 2016 2:43 pm
by blueb
elwood wrote:Oh, these constants are not listed in the constant section of the PB manual.
In the IDE...take a look at the 'Structure Viewer' on the Tools menu (or simply press Alt-S), then select the 'Constants' tab.
Type in what you need in the box provided, etc.