Created attachment 13026 [details] Local newspaper source When converting PDF to JPG, GhostScript process hangs on certain PDFs. There is something wrong with the PDF i assume, although it is displayed correctly on Chrome or other PDF viewers. Here is the command i run; "c:\Program Files\gs\gs9.20\bin\gswin64c.exe" -dNOPAUSE -dDEBUG -sDEVICE=jpeg -r144 -sOutputFile=p%03d.jpg test.pdf 1. What can i do to gracefully exit the process if it can't convert a page in 1 minute (timeout parameter)? 2. What is the source of this problem? Is the PDF corrupt? (If yes, why is it displayed correctly on PDF viewers) Is it a bug in GS?
(In reply to 1.44mb from comment #0) > 1. What can i do to gracefully exit the process if it can't convert a page > in 1 minute (timeout parameter)? Well, you could write your own code around the Ghostscript interpreter and library. Since the interpreter hasn't actually hung it will call back to the parent application at regular intervals and a watchdog timer in the parent would enable you to close the application. > 2. What is the source of this problem? Is the PDF corrupt? (If yes, why is > it displayed correctly on PDF viewers) Is it a bug in GS? If I attempt to open the attached PDF file with Acrobat it tells me "A drawing error occurred" which is a pretty good indication that your PDF file is broken. Badly broken in fact, since Acrobat habitually opens all sorts of corrupted and damaged PDF files. The problem seems to exist because of an image mask which is painted using a Pattern which itself uses an image and the pattern has a crazy Matrix: /Matrix[1.20756 0 45595027918153.2 1.20756 211.9743 1212.9919] which looks like an uninitialised number in index 3 to me, I very strongly suspect that massive number should be a zero. If I correct that Matrix to something sensible (eg 0) then the file runs to completion. Note that there are two occurrences of this crazy value. I doubt Ghostscript has actually hung, its valiantly painting a monstrously large pattern billions of times to satisfy the request. The PDF file claims to have been created by PDFSharp 1.50.4000, I'd suggest you take the problem up with them.