Reputation: 47
I have an application that converts multiple Postscript Files simultaneously to PDF.
To do this I call ps2pdf input.ps output.pdf
.
Sometimes when I have many (let's say >4) files that need to be converted, i get only one pdf and the other conversions fail.
The Problem is, that the failed convertsions will not result to an exitcode of ps2pdf other than 0.
My Version of Ghostscript is 9.16 for Windows x64.
I could not find any bugs in bugzilla that would explain that behavior.
Is there a better solution than checking if output.pdf exists and retry if it doesn't?
Upvotes: 0
Views: 1712
Reputation: 1444
we found workaround:
var attempts = 0;
while (true)
{
try
{
attempts++;
Ghost.Pdf2Image.Convert(pdf_filename);
break;
}
catch
{
//prevent forever loops
if (attempts > 99) break;
}
}
This leads to delayed response of hundre ms depending on number of simultanous call. You can work around the delayed response by doing this as async task :)
Upvotes: 0
Reputation: 11
ps2pdf.exe
internally calls gs.exe
or mgs.exe
which is ghostscript
. You do not need ps2pdf.exe
you can obtain the same functionality using gs.exe
. ps2pdf.exe
does NOT work properly with several instances. In fact, ps2pdf.exe
will execute only once instance at a time.
Upvotes: 1
Reputation: 31139
Well, we don't normally expect people to run multiple instances of Ghostscript. However.....
Most likely you have some kind of collision with temporary files, you can probably get around the problem by specifying a temporary file location (a different one for each instance obviously).
Given that the standard version of Ghostscript uses a single DLL its possible also (though much less likely IMO, because the context should not be shared) that you have a problem caused by sharing the DLL. You could set up several directories and use each one individually to see if that helps.
Using a script is probably also not the smartest idea in the world for a complex setup. Invoke Ghostscript directly instead, you will get much more control.
And what messages do you get returned when your conversions fail ? What version of Ghostscript are you using ? On what Operating System ?
Upvotes: 0