maybe you might want to resolve the printer name first and actually use that instead of the %printer% because that is not going to get resolved as far as I know.
Use the printer's name as you would like a PRN file.
In the old days it used to be LPT1, don't know about now.
No no, that's not how gswin64c works.
BTW, I made a workaround.
From the CGI, instead of calling gswin64c.exe I call the command line program I created for testing and it works as expected. So, it's a shame gswin64c cannot be called from a CGI, but at least this workaround solves the issue.
Here's the DoRun method of the command line program:
procedure TMyApplication.DoRun;
var
lProcess: TProcess;
lPrinter: string;
lPaperName: string;
lFile: string;
begin
lPrinter := ParamStr(1);
lPaperName := ParamStr(2);
lFile := ParamStr(3);
with TStringList.Create do
begin
Add('Printer: ' + lPrinter);
Add('PaperName: ' + lPaperName);
Add('File: ' + lFile);
SaveToFile('params.txt');
Free;
end;
lProcess := TProcess.Create(nil);
try
lProcess.Executable:='C:\Program Files\gs\gs9.27\bin\gswin64c.exe';
lProcess.Options := [poWaitOnExit];
lProcess.Parameters.Add('-dINITDEBUG');
lProcess.Parameters.Add('-dNOSAFER');
lProcess.Parameters.Add('-dNOGC');
lProcess.Parameters.Add('-dNOPAUSE');
lProcess.Parameters.Add('-dBATCH');
lProcess.Parameters.Add('-dDisplayResolution=600');
lProcess.Parameters.Add('-sPAPERSIZE=a3');
lProcess.Parameters.Add('-sDEVICE=mswinpr2');
lProcess.Parameters.Add('-sOutputFile="%printer%' + lPrinter + '"');
lProcess.Parameters.Add('-sstdout=salida.out');
lProcess.Parameters.Add('-sstderr=salida.err');
lProcess.Parameters.Add(lFile);
lProcess.Execute;
finally
lProcess.Free;
end;
// stop program loop
Terminate;
end;