0

I've added a GhostScript.NET to my application, and have been able to successfully print PDFs using GSPrint on my local machine. Unfortunately, after deploying the updated application to the server as well as installing GSView (includes GSPrint), the function to print just hangs without any errors.

My first guess is that since I am writing to the filesystem in order for GSPrint to print the file, is that it has something to do with access security rights. I'm using IIS 8 on windows server 2012. If anyone has any experience with deploying GSPrint or on how to troubleshoot this issue, I'd appreciate it.

Here's the code:

 public static void PrintingQueue(Queue<byte[]> printQueue, string printer, int copies)
    {
        Parallel.ForEach(printQueue, (currentFile) =>
        {
            PrintWithGSPrint(currentFile, printer, copies);
        });
        printQueue.Clear();
    }

    private static void PrintWithGSPrint(byte[] pdfFormBytes, string printer, int copies)
    {
        try
        {
            var fileName = Path.GetTempFileName();
            using (var file = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite))
            {
                file.Write(pdfFormBytes, 0, pdfFormBytes.Length);
                //this uses GSPrint, which console commands are different from vanilla ghostscript.
                var gsArguments = $"-noquery -portrait -printer\"{printer}\" \"{fileName}\"";
                var gsLocation = @"C:\Program Files\Ghostgum\gsview\gsprint.exe";

                var gsProcessInfo = new ProcessStartInfo
                {
                    WindowStyle = ProcessWindowStyle.Hidden,
                    FileName = gsLocation,
                    Arguments = gsArguments
                };

                var gsProcess = Process.Start(gsProcessInfo);
                gsProcess.WaitForExit();
                file.Close();
            }
            File.Delete(fileName);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
Crumblenautjs
  • 169
  • 1
  • 3
  • 24
  • Ghostscript.NET is a simple ghostscript wrapper. I don't see anything in your code that would tell me you use Ghostscript.NET. – HABJAN Feb 24 '17 at 08:52
  • Nope, it appears to be a call out to gsprint.exe, which is a part of GSView 5, which was developed by GumTree software in Australia. It uses Ghostscript, but not Ghostscript.NET. Its also effectively unsupported, especially for free users. I don't know much about .NET but I wouldn't expect a filesystem write() to hang if there's a file permissions error though. – KenS Feb 24 '17 at 09:43

0 Answers0